4.12 OPAMP - Analog Signal Conditioning

4.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.

4.12.2 Supported Device Families

AVR® DB

4.12.3 Required header files

#include "mcc_generated_files/opamp/opamp.h"

4.12.4 Module Documentation

4.12.4.1 OPAMP

This file contains API prototypes and other data types for the OPAMP module.

4.12.4.1.1 Module description

This file contains API prototypes and other data types for the OPAMP module.

Version: OPAMP Driver Version v1.0.0
Functions

4.12.4.1.2 Function Documentation

OPAMP_DisableSystem()

void OPAMP_DisableSystem (void )

Disables the OPAMP system.

Parameters:
None.
Returns:

None.

OPAMP_EnableSystem()

void OPAMP_EnableSystem (void )

Enables the OPAMP system.

Parameters:
None.
Returns:

None.

OPAMP_Initialize()

void OPAMP_Initialize (void )

Initializes the OPAMP module. This is called only once before calling other OPAMP APIs.

Parameters:
None.
Returns:

None.

OPAMP_IsOP0Settled()

bool OPAMP_IsOP0Settled (void )

Checks if the OP0 settling time is finished.

Parameters:
None.
Return values:
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.

Parameters:
None.
Return values:
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.

Parameters:
None.
Return values:
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.

Parameters:
value

- Desired bottom resistor connection. For the available bottom resistor connections, refer to the OPAMP_MUXBOT_t enum in the device header file.

Returns:

None.

OPAMP_SetOP0NegativeInMux()

void OPAMP_SetOP0NegativeInMux (OPAMP_OP0INMUX_MUXNEG_t value)

Sets the OP0 negative input.

Parameters:
value

- Desired negative input. For the available negative inputs, refer to the OPAMP_MUXNEG_t enum from the device header file.

Returns:

None.

OPAMP_SetOP0OffsetCalibration()

void OPAMP_SetOP0OffsetCalibration (uint8_t calValue)

Sets the OP0 offset calibration.

Parameters:
calValue

- Desired input offset calibration value

Returns:

None.

OPAMP_SetOP0PositiveInMux()

void OPAMP_SetOP0PositiveInMux (OPAMP_OP0INMUX_MUXPOS_t value)

Sets the OP0 positive input.

Parameters:
value

- Desired positive input. For the available positive inputs, refer to the OPAMP_MUXPOS_t enum from the device header file.

Returns:

None.

OPAMP_SetOP0SettleTime()

void OPAMP_SetOP0SettleTime (uint8_t settleTime)

Sets the OP0 settle time.

Parameters:
settleTime

- Desired settle time of 0 to 127 μs

Returns:

None.

OPAMP_SetOP0TopResMux()

void OPAMP_SetOP0TopResMux (OPAMP_OP0RESMUX_MUXTOP_t value)

Sets the top resistor connection of the OP0 internal resistor ladder.

Parameters:
value

- Desired top resistor connection. For the available top resistor connections, refer to the OPAMP_MUXTOP_t enum in the device header file.

Returns:

None.

OPAMP_SetOP0WiperResMux()

void OPAMP_SetOP0WiperResMux (OPAMP_OP0RESMUX_MUXWIP_t value)

Sets the R1 and R2 values of the OP0 internal resistor ladder.

Parameters:
value

- Desired resistor selection. For the available resistor values, refer to the OPAMP_MUXWIP_t enum in the device header file.

Returns:

None.

OPAMP_SetOP1BottomResMux()

void OPAMP_SetOP1BottomResMux (OPAMP_OP1RESMUX_MUXBOT_t value)

Sets the bottom resistor connection of the OP1 internal resistor ladder.

Parameters:
value

- Desired bottom resistor connection. For the available bottom resistor connections, refer to the OPAMP_MUXBOT_t enum in the device header file.

Returns:

None.

OPAMP_SetOP1NegativeInMux()

void OPAMP_SetOP1NegativeInMux (OPAMP_OP1INMUX_MUXNEG_t value)

Sets the OP1 negative input.

Parameters:
value

- Desired negative input. For the available negative inputs, refer to the OPAMP_MUXNEG_t enum from the device header file.

Returns:

None.

OPAMP_SetOP1OffsetCalibration()

void OPAMP_SetOP1OffsetCalibration (uint8_t calValue)

Sets the OP1 offset calibration.

Parameters:
calValue

- Desired input offset calibration value

Returns:

None.

OPAMP_SetOP1PositiveInMux()

void OPAMP_SetOP1PositiveInMux (OPAMP_OP1INMUX_MUXPOS_t value)

Sets the OP1 positive input.

Parameters:
value

- Desired positive input. For the available positive inputs, refer to the OPAMP_MUXPOS_t enum from the device header file.

Returns:

None.

OPAMP_SetOP1SettleTime()

void OPAMP_SetOP1SettleTime (uint8_t settleTime)

Sets the OP1 settle time.

Parameters:
settleTime

- Desired settle time of 0 to 127 μs

Returns:

None.

OPAMP_SetOP1TopResMux()

void OPAMP_SetOP1TopResMux (OPAMP_OP1RESMUX_MUXTOP_t value)

Sets the top resistor connection of the OP1 internal resistor ladder.

Parameters:
value

- Desired top resistor connection. For the available top resistor connections, refer to the OPAMP_MUXTOP_t enum in the device header file.

Returns:

None.

OPAMP_SetOP1WiperResMux()

void OPAMP_SetOP1WiperResMux (OPAMP_OP1RESMUX_MUXWIP_t value)

Sets the R1 and R2 values of the OP1 internal resistor ladder.

Parameters:
value

- Desired resistor selection. For the available resistor values, refer to the OPAMP_MUXWIP_t enum in the device header file.

Returns:

None.

OPAMP_SetOP2BottomResMux()

void OPAMP_SetOP2BottomResMux (OPAMP_OP2RESMUX_MUXBOT_t value)

Sets the bottom resistor connection of the OP2 internal resistor ladder.

Parameters:
value

- Desired bottom resistor connection. For the available bottom resistor connections, refer to the OPAMP_MUXBOT_t enum in the device header file.

Returns:

None.

OPAMP_SetOP2NegativeInMux()

void OPAMP_SetOP2NegativeInMux (OPAMP_OP2INMUX_MUXNEG_t value)

Sets the OP2 negative input.

Parameters:
value

- Desired negative input. For the available negative inputs, refer to the OPAMP_MUXNEG_t enum from the device header file.

Returns:

None.

OPAMP_SetOP2OffsetCalibration()

void OPAMP_SetOP2OffsetCalibration (uint8_t calValue)

Sets the OP2 offset calibration.

Parameters:
calValue

- Desired input offset calibration value

Returns:

None.

OPAMP_SetOP2PositiveInMux()

void OPAMP_SetOP2PositiveInMux (OPAMP_OP2INMUX_MUXPOS_t value)

Sets the OP2 positive input.

Parameters:
value

- Desired positive input. For the available positive inputs, refer to the OPAMP_MUXPOS_t enum from the device header file.

Returns:

None.

OPAMP_SetOP2SettleTime()

void OPAMP_SetOP2SettleTime (uint8_t settleTime)

Sets the OP2 settle time.

Parameters:
settleTime

- Desired settle time of 0 to 127 μs

Returns:

None.

OPAMP_SetOP2TopResMux()

void OPAMP_SetOP2TopResMux (OPAMP_OP2RESMUX_MUXTOP_t value)

Sets the top resistor connection of the OP2 internal resistor ladder.

Parameters:
value

- Desired top resistor connection. For the available top resistor connections, refer to the OPAMP_MUXTOP_t enum in the device header file.

Returns:

None.

OPAMP_SetOP2WiperResMux()

void OPAMP_SetOP2WiperResMux (OPAMP_OP2RESMUX_MUXWIP_t value)

Sets the R1 and R2 values of the OP2 internal resistor ladder.

Parameters:
value

- Desired resistor selection. For the available resistor values, refer to the OPAMP_MUXWIP_t enum in the device header file.

Returns:

None.

4.12.5 File Documentation

4.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"

4.12.5.1.1 Functions

4.12.5.1.2 Detailed Description

This is the generated driver implementation file for the OPAMP driver using AVR MCUs.

OPAMP Generated Driver File

Version: OPAMP Driver Version v1.0.0

4.12.5.2 source/opamp.h File Reference

#include "../system/utils/compiler.h"
#include <stdbool.h>

4.12.5.2.1 Functions

4.12.5.2.3 Detailed Description

OPAMP Generated Driver API Header File

4.12.5.2.4 Macro Definition Documentation

OPAMP_TIMEBASE_VALUE

#define OPAMP_TIMEBASE_VALUE (3)