3.12 OPAMP - Analog Signal Conditioning
3.12.1 Introduction
The MPLAB® Code Configurator Melody OPAMP PLIB (Peripheral Library) driver generates API to support the Analog Signal Conditioning functionality on AVR® target MCUs.
The Analog Signal Conditioning (OPAMP) peripheral features three operational amplifiers (op amps), designated OPn where n is zero, one or two. These op amps are implemented with a flexible connection scheme using analog multiplexers and resistor ladders. This allows a large number of analog signal conditioning configurations to be achieved, many of which require no external components.
3.12.2 Supported Device Families
AVR® DB |
3.12.3 Required header files
#include "mcc_generated_files/opamp/opamp.h"
3.12.4 Module Documentation
3.12.4.1 OPAMP
This file contains API prototypes and other data types for the OPAMP module.
3.12.4.1.1 Module description
This file contains API prototypes and other data types for the OPAMP module.
Functions
void OPAMP_Initialize (void)
Initializes the OPAMP module. This is called only once before calling other OPAMP APIs.
void OPAMP_EnableSystem (void)
Enables the OPAMP system.
void OPAMP_DisableSystem (void)
Disables the OPAMP system.
void OPAMP_SetOP0PositiveInMux (OPAMP_OP0INMUX_MUXPOS_t value)
Sets the OP0 positive input.
void OPAMP_SetOP0NegativeInMux (OPAMP_OP0INMUX_MUXNEG_t value)
Sets the OP0 negative input.
void OPAMP_SetOP0TopResMux (OPAMP_OP0RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP0 internal resistor ladder.
void OPAMP_SetOP0BottomResMux (OPAMP_OP0RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP0 internal resistor ladder.
void OPAMP_SetOP0WiperResMux (OPAMP_OP0RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP0 internal resistor ladder.
void OPAMP_SetOP0SettleTime (uint8_t settleTime)
Sets the OP0 settle time.
bool OPAMP_IsOP0Settled (void)
Checks if the OP0 settling time is finished.
void OPAMP_SetOP0OffsetCalibration (uint8_t calValue)
Sets the OP0 offset calibration.
void OPAMP_SetOP1PositiveInMux (OPAMP_OP1INMUX_MUXPOS_t value)
Sets the OP1 positive input.
void OPAMP_SetOP1NegativeInMux (OPAMP_OP1INMUX_MUXNEG_t value)
Sets the OP1 negative input.
void OPAMP_SetOP1TopResMux (OPAMP_OP1RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP1 internal resistor ladder.
void OPAMP_SetOP1BottomResMux (OPAMP_OP1RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP1 internal resistor ladder.
void OPAMP_SetOP1WiperResMux (OPAMP_OP1RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP1 internal resistor ladder.
void OPAMP_SetOP1SettleTime (uint8_t settleTime)
Sets the OP1 settle time.
bool OPAMP_IsOP1Settled (void)
Checks if the OP1 settling time is finished.
void OPAMP_SetOP1OffsetCalibration (uint8_t calValue)
Sets the OP1 offset calibration.
void OPAMP_SetOP2PositiveInMux (OPAMP_OP2INMUX_MUXPOS_t value)
Sets the OP2 positive input.
void OPAMP_SetOP2NegativeInMux (OPAMP_OP2INMUX_MUXNEG_t value)
Sets the OP2 negative input.
void OPAMP_SetOP2TopResMux (OPAMP_OP2RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP2 internal resistor ladder.
void OPAMP_SetOP2BottomResMux (OPAMP_OP2RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP2 internal resistor ladder.
void OPAMP_SetOP2WiperResMux (OPAMP_OP2RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP2 internal resistor ladder.
void OPAMP_SetOP2SettleTime (uint8_t settleTime)
Sets the OP2 settle time.
bool OPAMP_IsOP2Settled (void)
Checks if the OP2 settling time is finished.
void OPAMP_SetOP2OffsetCalibration (uint8_t calValue)
Sets the OP2 offset calibration.
3.12.4.1.2 Function Documentation
OPAMP_DisableSystem()
void OPAMP_DisableSystem (void )
Disables the OPAMP system.
None. |
None. |
OPAMP_EnableSystem()
void OPAMP_EnableSystem (void )
Enables the OPAMP system.
None. |
None. |
OPAMP_Initialize()
void OPAMP_Initialize (void )
Initializes the OPAMP module. This is called only once before calling other OPAMP APIs.
None. |
None. |
OPAMP_IsOP0Settled()
bool OPAMP_IsOP0Settled (void )
Checks if the OP0 settling time is finished.
None. |
True |
- The allowed settling time is finished |
False |
- OP0 is still waiting for settling related to enabling or configuration changes |
OPAMP_IsOP1Settled()
bool OPAMP_IsOP1Settled (void )
Checks if the OP1 settling time is finished.
None. |
True |
- The allowed settling time is finished |
False |
- OP1 is still waiting for settling related to enabling or configuration changes |
OPAMP_IsOP2Settled()
bool OPAMP_IsOP2Settled (void )
Checks if the OP2 settling time is finished.
None. |
True |
- The allowed settling time is finished |
False |
- OP2 is still waiting for settling related to enabling or configuration changes |
OPAMP_SetOP0BottomResMux()
void OPAMP_SetOP0BottomResMux (OPAMP_OP0RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP0 internal resistor ladder.
value |
- Desired bottom resistor connection. For the available bottom resistor connections, refer to the OPAMP_MUXBOT_t enum in the device header file. |
None. |
OPAMP_SetOP0NegativeInMux()
void OPAMP_SetOP0NegativeInMux (OPAMP_OP0INMUX_MUXNEG_t value)
Sets the OP0 negative input.
value |
- Desired negative input. For the available negative inputs, refer to the OPAMP_MUXNEG_t enum from the device header file. |
None. |
OPAMP_SetOP0OffsetCalibration()
void OPAMP_SetOP0OffsetCalibration (uint8_t calValue)
Sets the OP0 offset calibration.
calValue |
- Desired input offset calibration value |
None. |
OPAMP_SetOP0PositiveInMux()
void OPAMP_SetOP0PositiveInMux (OPAMP_OP0INMUX_MUXPOS_t value)
Sets the OP0 positive input.
value |
- Desired positive input. For the available positive inputs, refer to the OPAMP_MUXPOS_t enum from the device header file. |
None. |
OPAMP_SetOP0SettleTime()
void OPAMP_SetOP0SettleTime (uint8_t settleTime)
Sets the OP0 settle time.
settleTime |
- Desired settle time of 0 to 127 μs |
None. |
OPAMP_SetOP0TopResMux()
void OPAMP_SetOP0TopResMux (OPAMP_OP0RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP0 internal resistor ladder.
value |
- Desired top resistor connection. For the available top resistor connections, refer to the OPAMP_MUXTOP_t enum in the device header file. |
None. |
OPAMP_SetOP0WiperResMux()
void OPAMP_SetOP0WiperResMux (OPAMP_OP0RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP0 internal resistor ladder.
value |
- Desired resistor selection. For the available resistor values, refer to the OPAMP_MUXWIP_t enum in the device header file. |
None. |
OPAMP_SetOP1BottomResMux()
void OPAMP_SetOP1BottomResMux (OPAMP_OP1RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP1 internal resistor ladder.
value |
- Desired bottom resistor connection. For the available bottom resistor connections, refer to the OPAMP_MUXBOT_t enum in the device header file. |
None. |
OPAMP_SetOP1NegativeInMux()
void OPAMP_SetOP1NegativeInMux (OPAMP_OP1INMUX_MUXNEG_t value)
Sets the OP1 negative input.
value |
- Desired negative input. For the available negative inputs, refer to the OPAMP_MUXNEG_t enum from the device header file. |
None. |
OPAMP_SetOP1OffsetCalibration()
void OPAMP_SetOP1OffsetCalibration (uint8_t calValue)
Sets the OP1 offset calibration.
calValue |
- Desired input offset calibration value |
None. |
OPAMP_SetOP1PositiveInMux()
void OPAMP_SetOP1PositiveInMux (OPAMP_OP1INMUX_MUXPOS_t value)
Sets the OP1 positive input.
value |
- Desired positive input. For the available positive inputs, refer to the OPAMP_MUXPOS_t enum from the device header file. |
None. |
OPAMP_SetOP1SettleTime()
void OPAMP_SetOP1SettleTime (uint8_t settleTime)
Sets the OP1 settle time.
settleTime |
- Desired settle time of 0 to 127 μs |
None. |
OPAMP_SetOP1TopResMux()
void OPAMP_SetOP1TopResMux (OPAMP_OP1RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP1 internal resistor ladder.
value |
- Desired top resistor connection. For the available top resistor connections, refer to the OPAMP_MUXTOP_t enum in the device header file. |
None. |
OPAMP_SetOP1WiperResMux()
void OPAMP_SetOP1WiperResMux (OPAMP_OP1RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP1 internal resistor ladder.
value |
- Desired resistor selection. For the available resistor values, refer to the OPAMP_MUXWIP_t enum in the device header file. |
None. |
OPAMP_SetOP2BottomResMux()
void OPAMP_SetOP2BottomResMux (OPAMP_OP2RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP2 internal resistor ladder.
value |
- Desired bottom resistor connection. For the available bottom resistor connections, refer to the OPAMP_MUXBOT_t enum in the device header file. |
None. |
OPAMP_SetOP2NegativeInMux()
void OPAMP_SetOP2NegativeInMux (OPAMP_OP2INMUX_MUXNEG_t value)
Sets the OP2 negative input.
value |
- Desired negative input. For the available negative inputs, refer to the OPAMP_MUXNEG_t enum from the device header file. |
None. |
OPAMP_SetOP2OffsetCalibration()
void OPAMP_SetOP2OffsetCalibration (uint8_t calValue)
Sets the OP2 offset calibration.
calValue |
- Desired input offset calibration value |
None. |
OPAMP_SetOP2PositiveInMux()
void OPAMP_SetOP2PositiveInMux (OPAMP_OP2INMUX_MUXPOS_t value)
Sets the OP2 positive input.
value |
- Desired positive input. For the available positive inputs, refer to the OPAMP_MUXPOS_t enum from the device header file. |
None. |
OPAMP_SetOP2SettleTime()
void OPAMP_SetOP2SettleTime (uint8_t settleTime)
Sets the OP2 settle time.
settleTime |
- Desired settle time of 0 to 127 μs |
None. |
OPAMP_SetOP2TopResMux()
void OPAMP_SetOP2TopResMux (OPAMP_OP2RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP2 internal resistor ladder.
value |
- Desired top resistor connection. For the available top resistor connections, refer to the OPAMP_MUXTOP_t enum in the device header file. |
None. |
OPAMP_SetOP2WiperResMux()
void OPAMP_SetOP2WiperResMux (OPAMP_OP2RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP2 internal resistor ladder.
value |
- Desired resistor selection. For the available resistor values, refer to the OPAMP_MUXWIP_t enum in the device header file. |
None. |
3.12.5 File Documentation
3.12.5.1 source/opamp.c File Reference
This is the generated driver implementation file for the OPAMP driver using AVR MCUs.
#include "../opamp.h"
3.12.5.1.1 Functions
void OPAMP_Initialize (void)
Initializes the OPAMP module. This is called only once before calling other OPAMP APIs.
void OPAMP_EnableSystem (void)
Enables the OPAMP system.
void OPAMP_DisableSystem (void)
Disables the OPAMP system.
void OPAMP_SetOP0PositiveInMux (OPAMP_OP0INMUX_MUXPOS_t value)
Sets the OP0 positive input.
void OPAMP_SetOP0NegativeInMux (OPAMP_OP0INMUX_MUXNEG_t value)
Sets the OP0 negative input.
void OPAMP_SetOP0TopResMux (OPAMP_OP0RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP0 internal resistor ladder.
void OPAMP_SetOP0BottomResMux (OPAMP_OP0RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP0 internal resistor ladder.
void OPAMP_SetOP0WiperResMux (OPAMP_OP0RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP0 internal resistor ladder.
void OPAMP_SetOP0SettleTime (uint8_t settleTime)
Sets the OP0 settle time.
bool OPAMP_IsOP0Settled (void)
Checks if the OP0 settling time is finished.
void OPAMP_SetOP0OffsetCalibration (uint8_t calValue)
Sets the OP0 offset calibration.
void OPAMP_SetOP1PositiveInMux (OPAMP_OP1INMUX_MUXPOS_t value)
Sets the OP1 positive input.
void OPAMP_SetOP1NegativeInMux (OPAMP_OP1INMUX_MUXNEG_t value)
Sets the OP1 negative input.
void OPAMP_SetOP1TopResMux (OPAMP_OP1RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP1 internal resistor ladder.
void OPAMP_SetOP1BottomResMux (OPAMP_OP1RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP1 internal resistor ladder.
void OPAMP_SetOP1WiperResMux (OPAMP_OP1RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP1 internal resistor ladder.
void OPAMP_SetOP1SettleTime (uint8_t settleTime)
Sets the OP1 settle time.
bool OPAMP_IsOP1Settled (void)
Checks if the OP1 settling time is finished.
void OPAMP_SetOP1OffsetCalibration (uint8_t calValue)
Sets the OP1 offset calibration.
void OPAMP_SetOP2PositiveInMux (OPAMP_OP2INMUX_MUXPOS_t value)
Sets the OP2 positive input.
void OPAMP_SetOP2NegativeInMux (OPAMP_OP2INMUX_MUXNEG_t value)
Sets the OP2 negative input.
void OPAMP_SetOP2TopResMux (OPAMP_OP2RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP2 internal resistor ladder.
void OPAMP_SetOP2BottomResMux (OPAMP_OP2RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP2 internal resistor ladder.
void OPAMP_SetOP2WiperResMux (OPAMP_OP2RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP2 internal resistor ladder.
void OPAMP_SetOP2SettleTime (uint8_t settleTime)
Sets the OP2 settle time.
bool OPAMP_IsOP2Settled (void)
Checks if the OP2 settling time is finished.
void OPAMP_SetOP2OffsetCalibration (uint8_t calValue)
Sets the OP2 offset calibration.
3.12.5.1.2 Detailed Description
This is the generated driver implementation file for the OPAMP driver using AVR MCUs.
OPAMP Generated Driver File
3.12.5.2 source/opamp.h File Reference
#include "../system/utils/compiler.h" #include <stdbool.h>
3.12.5.2.1 Functions
void OPAMP_Initialize (void)
Initializes the OPAMP module. This is called only once before calling other OPAMP APIs.
void OPAMP_EnableSystem (void)
Enables the OPAMP system.
void OPAMP_DisableSystem (void)
Disables the OPAMP system.
void OPAMP_SetOP0PositiveInMux (OPAMP_OP0INMUX_MUXPOS_t value)
Sets the OP0 positive input.
void OPAMP_SetOP0NegativeInMux (OPAMP_OP0INMUX_MUXNEG_t value)
Sets the OP0 negative input.
void OPAMP_SetOP0TopResMux (OPAMP_OP0RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP0 internal resistor ladder.
void OPAMP_SetOP0BottomResMux (OPAMP_OP0RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP0 internal resistor ladder.
void OPAMP_SetOP0WiperResMux (OPAMP_OP0RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP0 internal resistor ladder.
void OPAMP_SetOP0SettleTime (uint8_t settleTime)
Sets the OP0 settle time.
bool OPAMP_IsOP0Settled (void)
Checks if the OP0 settling time is finished.
void OPAMP_SetOP0OffsetCalibration (uint8_t calValue)
Sets the OP0 offset calibration.
void OPAMP_SetOP1PositiveInMux (OPAMP_OP1INMUX_MUXPOS_t value)
Sets the OP1 positive input.
void OPAMP_SetOP1NegativeInMux (OPAMP_OP1INMUX_MUXNEG_t value)
Sets the OP1 negative input.
void OPAMP_SetOP1TopResMux (OPAMP_OP1RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP1 internal resistor ladder.
void OPAMP_SetOP1BottomResMux (OPAMP_OP1RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP1 internal resistor ladder.
void OPAMP_SetOP1WiperResMux (OPAMP_OP1RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP1 internal resistor ladder.
void OPAMP_SetOP1SettleTime (uint8_t settleTime)
Sets the OP1 settle time.
bool OPAMP_IsOP1Settled (void)
Checks if the OP1 settling time is finished.
void OPAMP_SetOP1OffsetCalibration (uint8_t calValue)
Sets the OP1 offset calibration.
void OPAMP_SetOP2PositiveInMux (OPAMP_OP2INMUX_MUXPOS_t value)
Sets the OP2 positive input.
void OPAMP_SetOP2NegativeInMux (OPAMP_OP2INMUX_MUXNEG_t value)
Sets the OP2 negative input.
void OPAMP_SetOP2TopResMux (OPAMP_OP2RESMUX_MUXTOP_t value)
Sets the top resistor connection of the OP2 internal resistor ladder.
void OPAMP_SetOP2BottomResMux (OPAMP_OP2RESMUX_MUXBOT_t value)
Sets the bottom resistor connection of the OP2 internal resistor ladder.
void OPAMP_SetOP2WiperResMux (OPAMP_OP2RESMUX_MUXWIP_t value)
Sets the R1 and R2 values of the OP2 internal resistor ladder.
void OPAMP_SetOP2SettleTime (uint8_t settleTime)
Sets the OP2 settle time.
bool OPAMP_IsOP2Settled (void)
Checks if the OP2 settling time is finished.
void OPAMP_SetOP2OffsetCalibration (uint8_t calValue)
Sets the OP2 offset calibration.
3.12.5.2.2 Macros
#define OPAMP_TIMEBASE_VALUE (3)
3.12.5.2.3 Detailed Description
OPAMP Generated Driver API Header File
3.12.5.2.4 Macro Definition Documentation
OPAMP_TIMEBASE_VALUE
#define OPAMP_TIMEBASE_VALUE (3)