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() .

  • 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).

  • HAL_OPAMP_CalibrateParallel()

    • 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:

How to start and stop the OPAMP instances:

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.