3.13 OPA Driver
Overview
The Operational Amplifier (Op Amp) module provides the ability to condition analog input signals. It can be configured to run in High or Low-Power mode, depending on the user specifications.
Features
- Op-amp is enabled by default.
- Enabling an op-amp instance configures the corresponding input and output pins.
- Positive and Negative channel for each op-amp is user configurable.
3.13.1 Module Documentation
3.13.1.1 OPA Driver
Operational Amplifier Driver used for a wide variety of purposes, including signal conditioning and filtering using dsPIC MCUs.
3.13.1.1.1 Module description
Operational Amplifier Driver used for a wide variety of purposes, including signal conditioning and filtering using dsPIC MCUs.
Data structures
struct OPA_INTERFACE
Structure containing the function pointers of OPA driver.
Enumerations
enum OPA_DIFFERENTIAL_INPUT_MODE { OPA_DIFFERENTIAL_INPUT_NMOS_PMOS_PAIR = 0, OPA_DIFFERENTIAL_INPUT_NMOS_INPUT_PAIR = 1, OPA_DIFFERENTIAL_INPUT_PMOS_INPUT_PAIR = 2, OPA_DIFFERENTIAL_INPUT_NONE = 3 }
This defines Differential input mode enumeration for OPA.
enum OPA_OFFSET_INPUT_TYPE { OPA_PMOS_OFFSET_IN_HIGH_POWER_MODE, OPA_NMOS_OFFSET_IN_HIGH_POWER_MODE, OPA_PMOS_OFFSET_IN_LOW_POWER_MODE, OPA_NMOS_OFFSET_IN_LOW_POWER_MODE }
This defines offset input type enumeration for OPA.
enum OPA_OFFSET_CORRECTION_VOLTAGE { POSITIVE_15_UNIT_VOLTAGE = 0xf, POSITIVE_14_UNIT_VOLTAGE = 0xe, POSITIVE_13_UNIT_VOLTAGE = 0xd, POSITIVE_12_UNIT_VOLTAGE = 0xc, POSITIVE_11_UNIT_VOLTAGE = 0xb, POSITIVE_10_UNIT_VOLTAGE = 0xa, POSITIVE_9_UNIT_VOLTAGE = 0x9, POSITIVE_8_UNIT_VOLTAGE = 0x8, POSITIVE_7_UNIT_VOLTAGE = 0x7, POSITIVE_6_UNIT_VOLTAGE = 0x6, POSITIVE_5_UNIT_VOLTAGE = 0x5, POSITIVE_4_UNIT_VOLTAGE = 0x4, POSITIVE_3_UNIT_VOLTAGE = 0x3, POSITIVE_2_UNIT_VOLTAGE = 0x2, POSITIVE_1_UNIT_VOLTAGE = 0x1, NONE = 0x0, NEGATIVE_1_UNIT_VOLTAGE = 0x1f, NEGATIVE_2_UNIT_VOLTAGE = 0x1e, NEGATIVE_3_UNIT_VOLTAGE = 0x1d, NEGATIVE_4_UNIT_VOLTAGE = 0x1c, NEGATIVE_5_UNIT_VOLTAGE = 0x1b, NEGATIVE_6_UNIT_VOLTAGE = 0x1a, NEGATIVE_7_UNIT_VOLTAGE = 0x19, NEGATIVE_8_UNIT_VOLTAGE = 0x18, NEGATIVE_9_UNIT_VOLTAGE = 0x17, NEGATIVE_10_UNIT_VOLTAGE = 0x16, NEGATIVE_11_UNIT_VOLTAGE = 0x15, NEGATIVE_12_UNIT_VOLTAGE = 0x14, NEGATIVE_13_UNIT_VOLTAGE = 0x13, NEGATIVE_14_UNIT_VOLTAGE = 0x12, NEGATIVE_15_UNIT_VOLTAGE = 0x11, NEGATIVE_16_UNIT_VOLTAGE = 0x10 }
This defines offset correction unit voltage enumeration for OPA @Note Unit voltage = trim step voltage 3 mV.
Functions
void OPA1_Initialize (void)
Initializes the OPA module.
void OPA1_Deinitialize (void)
Deinitializes the OPA1 to POR values.
static void OPA1_Enable (void)
This inline function enables OPA1 module.
static void OPA1_Disable (void)
This inline function disables OPA1 module.
static void OPA1_UnityGainEnable (bool enable)
This inline function enables/disables unity gain of OPA1 module.
static void OPA1_HighPowerModeEnable (bool enable)
This inline function enables/disables high power mode of OPA1 module.
static void OPA1_InputMonitorEnable (bool enable)
This inline function enables/disables positive input of OPA1 module to ADC.
static void OPA1_OutputMonitorEnable (bool enable)
This inline function enables/disables Enables output of OPA1 module to ADC.
static void OPA1_DifferentialInputModeSet (enum OPA_DIFFERENTIAL_INPUT_MODE input)
This inline function enables/disables Enables output of OPA1 module to ADC.
static void OPA1_OffsetCorrection (enum OPA_OFFSET_INPUT_TYPE inputType, enum OPA_OFFSET_CORRECTION_VOLTAGE unitVoltage)
This inline function enables/disables Enables output of OPA1 module to ADC.
Variables
const struct OPA_INTERFACE OPA1
Structure object of type OPA_INTERFACE with the custom name given by the user in the Melody Driver User interface. The default name e.g. OPA can be changed by the user in the OPA user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.
3.13.1.1.2 Function Documentation
OPA1_Deinitialize()
void OPA1_Deinitialize (void )
Deinitializes the OPA1 to POR values.
none |
none |
OPA1_DifferentialInputModeSet()
inline static void OPA1_DifferentialInputModeSet (enum OPA_DIFFERENTIAL_INPUT_MODE input)
This inline function enables/disables Enables output of OPA1 module to ADC.
in | input |
- selected differential input mode |
none |
OPA1_Disable()
inline static void OPA1_Disable (void )
This inline function disables OPA1 module.
none |
none |
OPA1_Enable()
inline static void OPA1_Enable (void )
This inline function enables OPA1 module.
The OPA1_Initialize function should be called for the specified OPA1 driver instance. |
none |
none |
OPA1_HighPowerModeEnable()
inline static void OPA1_HighPowerModeEnable (bool enable)
This inline function enables/disables high power mode of OPA1 module.
in | enable |
- true, enables High Power Mode |
in | enable |
- false, disables High Power Mode |
none |
OPA1_Initialize()
void OPA1_Initialize (void )
Initializes the OPA module.
none |
none |
OPA1_InputMonitorEnable()
inline static void OPA1_InputMonitorEnable (bool enable)
This inline function enables/disables positive input of OPA1 module to ADC.
in | enable |
- true, enables input Monitor |
in | enable |
- false, disables input Monitor |
none |
OPA1_OffsetCorrection()
inline static void OPA1_OffsetCorrection (enum OPA_OFFSET_INPUT_TYPE inputType, enum OPA_OFFSET_CORRECTION_VOLTAGE unitVoltage)
This inline function enables/disables Enables output of OPA1 module to ADC.
in | inputType |
- selected differential input offset register type |
in | unitVoltage |
- selected unit voltage |
none @Note Unit voltage = trim step voltage 3 mV |
OPA1_OutputMonitorEnable()
inline static void OPA1_OutputMonitorEnable (bool enable)
This inline function enables/disables Enables output of OPA1 module to ADC.
in | enable |
- true, enables output Monitor |
in | enable |
- false, disables output Monitor |
none |
OPA1_UnityGainEnable()
inline static void OPA1_UnityGainEnable (bool enable)
This inline function enables/disables unity gain of OPA1 module.
in | enable |
- true, enables unity gain |
in | enable |
- false, disables unity gain |
none |
3.13.1.1.3 Enumeration Type Documentation
OPA_DIFFERENTIAL_INPUT_MODE
enum OPA_DIFFERENTIAL_INPUT_MODE
This defines Differential input mode enumeration for OPA.
OPA_DIFFERENTIAL_INPUT_NMOS_PMOS_PAIR |
Use both NMOS and PMOS differential input pair |
OPA_DIFFERENTIAL_INPUT_NMOS_INPUT_PAIR |
Turn NMOS differntial input pair ON and turn PMOS differential input pair off |
OPA_DIFFERENTIAL_INPUT_PMOS_INPUT_PAIR |
Turn PMOS differntial input pair ON and turn NMOS differential input pair off |
OPA_DIFFERENTIAL_INPUT_NONE |
No differential input pair selected |
OPA_OFFSET_CORRECTION_VOLTAGE
enum OPA_OFFSET_CORRECTION_VOLTAGE
This defines offset correction unit voltage enumeration for OPA @Note Unit voltage = trim step voltage 3 mV.
POSITIVE_15_UNIT_VOLTAGE |
Correct offset by +15 unit voltage |
POSITIVE_14_UNIT_VOLTAGE |
Correct offset by +14 unit voltage |
POSITIVE_13_UNIT_VOLTAGE |
Correct offset by +13 unit voltage |
POSITIVE_12_UNIT_VOLTAGE |
Correct offset by +12 unit voltage |
POSITIVE_11_UNIT_VOLTAGE |
Correct offset by +11 unit voltage |
POSITIVE_10_UNIT_VOLTAGE |
Correct offset by +10 unit voltage |
POSITIVE_9_UNIT_VOLTAGE |
Correct offset by +9 unit voltage |
POSITIVE_8_UNIT_VOLTAGE |
Correct offset by +8 unit voltage |
POSITIVE_7_UNIT_VOLTAGE |
Correct offset by +7 unit voltage |
POSITIVE_6_UNIT_VOLTAGE |
Correct offset by +6 unit voltage |
POSITIVE_5_UNIT_VOLTAGE |
Correct offset by +5 unit voltage |
POSITIVE_4_UNIT_VOLTAGE |
Correct offset by +4 unit voltage |
POSITIVE_3_UNIT_VOLTAGE |
Correct offset by +3 unit voltage |
POSITIVE_2_UNIT_VOLTAGE |
Correct offset by +2 unit voltage |
POSITIVE_1_UNIT_VOLTAGE |
Correct offset by +1 unit voltage |
NONE |
Correct offset by 0 unit voltage |
NEGATIVE_1_UNIT_VOLTAGE |
Correct offset by -1 unit voltage |
NEGATIVE_2_UNIT_VOLTAGE |
Correct offset by -2 unit voltage |
NEGATIVE_3_UNIT_VOLTAGE |
Correct offset by -3 unit voltage |
NEGATIVE_4_UNIT_VOLTAGE |
Correct offset by -4 unit voltage |
NEGATIVE_5_UNIT_VOLTAGE |
Correct offset by -5 unit voltage |
NEGATIVE_6_UNIT_VOLTAGE |
Correct offset by -6 unit voltage |
NEGATIVE_7_UNIT_VOLTAGE |
Correct offset by -7 unit voltage |
NEGATIVE_8_UNIT_VOLTAGE |
Correct offset by -8 unit voltage |
NEGATIVE_9_UNIT_VOLTAGE |
Correct offset by -9 unit voltage |
NEGATIVE_10_UNIT_VOLTAGE |
Correct offset by -10 unit voltage |
NEGATIVE_11_UNIT_VOLTAGE |
Correct offset by -11 unit voltage |
NEGATIVE_12_UNIT_VOLTAGE |
Correct offset by -12 unit voltage |
NEGATIVE_13_UNIT_VOLTAGE |
Correct offset by -13 unit voltage |
NEGATIVE_14_UNIT_VOLTAGE |
Correct offset by -14 unit voltage |
NEGATIVE_15_UNIT_VOLTAGE |
Correct offset by -15 unit voltage |
NEGATIVE_16_UNIT_VOLTAGE |
Correct offset by -16 unit voltage |
OPA_OFFSET_INPUT_TYPE
enum OPA_OFFSET_INPUT_TYPE
This defines offset input type enumeration for OPA.
OPA_PMOS_OFFSET_IN_HIGH_POWER_MODE |
Offset Correction for PMOS Differential Input Pair (High-Power mode) |
OPA_NMOS_OFFSET_IN_HIGH_POWER_MODE |
Offset Correction for NMOS Differential Input Pair (High-Power mode) |
OPA_PMOS_OFFSET_IN_LOW_POWER_MODE |
Offset Correction for PMOS Differential Input Pair (Low-Power mode) |
OPA_NMOS_OFFSET_IN_LOW_POWER_MODE |
Offset Correction for NMOS Differential Input Pair (Low-Power mode) |
3.13.1.1.4 Variable Documentation
OPA1
const struct OPA_INTERFACE OPA1
Structure object of type OPA_INTERFACE with the custom name given by the user in the Melody Driver User interface. The default name e.g. OPA can be changed by the user in the OPA user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.
3.13.2 Data Structure Documentation
3.13.2.1 OPA_INTERFACE Struct Reference
Structure containing the function pointers of OPA driver.
3.13.2.1.1 Detailed Description
Structure containing the function pointers of OPA driver.
#include <opa_interface.h>
Data Fields
void(* Intitialize )(void)
Pointer to OPAx_Initialize e.g. OPA1_Initialize.
void(* Deintitialize )(void)
Pointer to OPAx_Deinitialize e.g. OPA1_Deinitialize.
void(* Enable )(void)
Pointer to OPAx_Enable e.g. OPA1_Enable.
void(* Disable )(void)
Pointer to OPAx_Disable e.g. OPA1_Disable.
void(* UnityGainEnable )(bool enable)
Pointer to OPAx_UnityGainEnable e.g. OPA1_UnityGainEnable.
void(* HighPowerModeEnable )(bool enable)
Pointer to OPAx_HighPowerModeEnable e.g. OPA1_HighPowerModeEnable.
void(* InputMonitorEnable )(bool enable)
Pointer to OPAx_InputMonitorEnable e.g. OPA1_InputMonitorEnable.
void(* OutputMonitorEnable )(bool enable)
Pointer to OPAx_OutputMonitorEnable e.g. OPA1_OutputMonitorEnable.
void(* DifferentialInputModeSet )(enum OPA_DIFFERENTIAL_INPUT_MODE input)
Pointer to OPAx_DifferentialInputModeSet e.g. OPA1_DifferentialInputModeSet.
void(* OffsetCorrection )(enum OPA_OFFSET_INPUT_TYPE inputType, enum OPA_OFFSET_CORRECTION_VOLTAGE unitVoltage)
Pointer to OPAx_OffsetCorrection e.g. OPA1_OffsetCorrection.
3.13.2.1.2 Field Documentation
Deintitialize
void(* Deintitialize) (void)
Pointer to OPAx_Deinitialize e.g. OPA1_Deinitialize.
DifferentialInputModeSet
void(* DifferentialInputModeSet) (enum OPA_DIFFERENTIAL_INPUT_MODE input)
Pointer to OPAx_DifferentialInputModeSet e.g. OPA1_DifferentialInputModeSet.
Disable
void(* Disable) (void)
Pointer to OPAx_Disable e.g. OPA1_Disable.
Enable
void(* Enable) (void)
Pointer to OPAx_Enable e.g. OPA1_Enable.
HighPowerModeEnable
void(* HighPowerModeEnable) (bool enable)
Pointer to OPAx_HighPowerModeEnable e.g. OPA1_HighPowerModeEnable.
InputMonitorEnable
void(* InputMonitorEnable) (bool enable)
Pointer to OPAx_InputMonitorEnable e.g. OPA1_InputMonitorEnable.
Intitialize
void(* Intitialize) (void)
Pointer to OPAx_Initialize e.g. OPA1_Initialize.
OffsetCorrection
void(* OffsetCorrection) (enum OPA_OFFSET_INPUT_TYPE inputType, enum OPA_OFFSET_CORRECTION_VOLTAGE unitVoltage)
Pointer to OPAx_OffsetCorrection e.g. OPA1_OffsetCorrection.
OutputMonitorEnable
void(* OutputMonitorEnable) (bool enable)
Pointer to OPAx_OutputMonitorEnable e.g. OPA1_OutputMonitorEnable.
UnityGainEnable
void(* UnityGainEnable) (bool enable)
Pointer to OPAx_UnityGainEnable e.g. OPA1_UnityGainEnable.
3.13.3 File Documentation
3.13.3.1 source/opa1.h File Reference
This is the generated driver header file for the OPA1 driver.
#include <xc.h> #include <stdint.h> #include "opa_interface.h"
3.13.3.1.1 Functions
void OPA1_Initialize (void)
Initializes the OPA module.
void OPA1_Deinitialize (void)
Deinitializes the OPA1 to POR values.
static void OPA1_Enable (void)
This inline function enables OPA1 module.
static void OPA1_Disable (void)
This inline function disables OPA1 module.
static void OPA1_UnityGainEnable (bool enable)
This inline function enables/disables unity gain of OPA1 module.
static void OPA1_HighPowerModeEnable (bool enable)
This inline function enables/disables high power mode of OPA1 module.
static void OPA1_InputMonitorEnable (bool enable)
This inline function enables/disables positive input of OPA1 module to ADC.
static void OPA1_OutputMonitorEnable (bool enable)
This inline function enables/disables Enables output of OPA1 module to ADC.
static void OPA1_DifferentialInputModeSet (enum OPA_DIFFERENTIAL_INPUT_MODE input)
This inline function enables/disables Enables output of OPA1 module to ADC.
static void OPA1_OffsetCorrection (enum OPA_OFFSET_INPUT_TYPE inputType, enum OPA_OFFSET_CORRECTION_VOLTAGE unitVoltage)
This inline function enables/disables Enables output of OPA1 module to ADC.
3.13.3.1.2 Variables
const struct OPA_INTERFACE OPA1
Structure object of type OPA_INTERFACE with the custom name given by the user in the Melody Driver User interface. The default name e.g. OPA can be changed by the user in the OPA user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.
3.13.3.1.3 Detailed Description
This is the generated driver header file for the OPA1 driver.
OPA1 Generated Driver Header File
PLIB Version 1.0.0-rc.1 |
3.13.3.2 source/opa_interface.h File Reference
#include <stdbool.h> #include "opa_types.h"
3.13.3.2.1 Data structures
struct OPA_INTERFACE
Structure containing the function pointers of OPA driver.
3.13.3.2.2 Detailed Description
OPA Generated Driver Interface Header File
3.13.3.3 source/opa_types.h File Reference
This is the generated driver interface header file for the OPA driver.
3.13.3.3.1 Enumerations
enum OPA_DIFFERENTIAL_INPUT_MODE { OPA_DIFFERENTIAL_INPUT_NMOS_PMOS_PAIR = 0, OPA_DIFFERENTIAL_INPUT_NMOS_INPUT_PAIR = 1, OPA_DIFFERENTIAL_INPUT_PMOS_INPUT_PAIR = 2, OPA_DIFFERENTIAL_INPUT_NONE = 3 }
This defines Differential input mode enumeration for OPA.
enum OPA_OFFSET_INPUT_TYPE { OPA_PMOS_OFFSET_IN_HIGH_POWER_MODE, OPA_NMOS_OFFSET_IN_HIGH_POWER_MODE, OPA_PMOS_OFFSET_IN_LOW_POWER_MODE, OPA_NMOS_OFFSET_IN_LOW_POWER_MODE }
This defines offset input type enumeration for OPA.
enum OPA_OFFSET_CORRECTION_VOLTAGE { POSITIVE_15_UNIT_VOLTAGE = 0xf, POSITIVE_14_UNIT_VOLTAGE = 0xe, POSITIVE_13_UNIT_VOLTAGE = 0xd, POSITIVE_12_UNIT_VOLTAGE = 0xc, POSITIVE_11_UNIT_VOLTAGE = 0xb, POSITIVE_10_UNIT_VOLTAGE = 0xa, POSITIVE_9_UNIT_VOLTAGE = 0x9, POSITIVE_8_UNIT_VOLTAGE = 0x8, POSITIVE_7_UNIT_VOLTAGE = 0x7, POSITIVE_6_UNIT_VOLTAGE = 0x6, POSITIVE_5_UNIT_VOLTAGE = 0x5, POSITIVE_4_UNIT_VOLTAGE = 0x4, POSITIVE_3_UNIT_VOLTAGE = 0x3, POSITIVE_2_UNIT_VOLTAGE = 0x2, POSITIVE_1_UNIT_VOLTAGE = 0x1, NONE = 0x0, NEGATIVE_1_UNIT_VOLTAGE = 0x1f, NEGATIVE_2_UNIT_VOLTAGE = 0x1e, NEGATIVE_3_UNIT_VOLTAGE = 0x1d, NEGATIVE_4_UNIT_VOLTAGE = 0x1c, NEGATIVE_5_UNIT_VOLTAGE = 0x1b, NEGATIVE_6_UNIT_VOLTAGE = 0x1a, NEGATIVE_7_UNIT_VOLTAGE = 0x19, NEGATIVE_8_UNIT_VOLTAGE = 0x18, NEGATIVE_9_UNIT_VOLTAGE = 0x17, NEGATIVE_10_UNIT_VOLTAGE = 0x16, NEGATIVE_11_UNIT_VOLTAGE = 0x15, NEGATIVE_12_UNIT_VOLTAGE = 0x14, NEGATIVE_13_UNIT_VOLTAGE = 0x13, NEGATIVE_14_UNIT_VOLTAGE = 0x12, NEGATIVE_15_UNIT_VOLTAGE = 0x11, NEGATIVE_16_UNIT_VOLTAGE = 0x10 }
This defines offset correction unit voltage enumeration for OPA @Note Unit voltage = trim step voltage 3 mV.
3.13.3.3.2 Detailed Description
This is the generated driver interface header file for the OPA driver.
OPA Generated Driver Interface Header File