HAL OPAMP How to Use ¶
- group OPAMP_How_To_Use
-
OPAMP peripheral main features ¶
OPAMP instances ¶
The U5 device integrates one or two operational amplifiers: OPAMP1 & OPAMP2
OPAMP configuration mode ¶
The OPAMP provide(s) several exclusive configuration modes.
-
Standalone mode
-
Programmable Gain Amplifier (PGA) mode, with or without external filtering (A capacitor can be connected between OPAMP output and inverting input for filtering purpose, refer to reference manual)
-
Follower mode
OPAMP power mode ¶
Each OPAMP instance can be configured in normal-power or low-power mode.
OPAMP speed mode ¶
Each OPAMP instance can be configured in normal speed or high speed.
OPAMP calibration feature ¶
The OPAMP provide(s) calibration capabilities.
-
Calibration aims at improving voltage offset accuracy
-
The OPAMP uses either factory calibration settings or user defined calibration settings (i.e. trimming mode).
-
The user trimming values can be figured out by calling calibration handled by HAL_OPAMP_Calibrate() .
-
-
Run automatically the calibration.
-
Enables the user trimming mode.
-
Updates the trimming registers values with fresh calibration results. The user might store the calibration results for latter usage (for example, monitoring the trimming based on temperature).
-
-
-
Run calibration in parallel for linked HAL OPAMP handles to speed up calibration processing time.
-
OPAMP configuration mode: ¶
Standalone mode ¶
-
OPAMP input and output are not internally connected. User can implement any circuitry using external components.
Follower mode ¶
-
Inverting Input is connected internally, no external connection on inverting input.
Programmable Gain Amplifier (PGA) mode (Resistor feedback output) ¶
-
The OPAMP output(s) is internally connected to resistor feedback.
-
OPAMP internal programmable gain is either x2, x4, x8 or x16. Two usages:
-
inverting output not used, only programmable gain.
-
inverting input used for external filtering coupled with programmable gain (ex: connected capacitor for low-pass filtering).
-
The OPAMPs inverting input ¶
The OPAMPs inverting input can be selected according to the Reference Manual “OPAMP functional description” chapter.
The OPAMPs non inverting input ¶
The OPAMPs non inverting input can be selected according to the Reference Manual “OPAMP functional description” chapter.
How to use HAL OPAMP module driver ¶
The OPAMP HAL driver can be used as follows: ¶
How to initialize the OPAMP low level resources: ¶
-
OPAMP bus clock must be enabled to get read and write access to OPAMP registers.
-
Configure the OPAMP input pins and output pin in analog mode using HAL_GPIO_Init() to map the OPAMP output to the GPIO pin.
-
Declare a hal_opamp_handle_t handle structure.
-
Initialize OPAMP instance using HAL_OPAMP_Init() .
-
Configure the OPAMP instance with HAL_OPAMP_SetConfig() function.
-
Select the inverting input and the non-inverting input using HAL_OPAMP_SetConfigInputConnection()
-
By default factory trimming is set, else, call HAL_OPAMP_Calibrate() or HAL_OPAMP_SetConfigTrimming() functions to use “user trimming” mode with the user PMOS and NMOS trimming values.
How to start and stop the OPAMP instances: ¶
-
Start the OPAMP instance using HAL_OPAMP_Start() function.
-
Stop the OPAMP instance using HAL_OPAMP_Stop() function.
Operational amplifier possible pin connections: ¶
-
Cf Reference Manual
Note
clock is enabled inside HAL_OPAMP_Init() whenever USE_HAL_OPAMP_CLK_ENABLE_MODEL is not set to HAL_CLK_ENABLE_NO.
-