24. Operational amplifier (OPAMP)
This section applies only to STM32C53x/54x devices.
24.1 Introduction
The devices embed one operational amplifier instance, OPAMP1.
OPAMP contains an operational amplifier, an internal resistor divider, and multiplexers to set the OPAMP peripheral into a specific operating mode. In one of these, the operational amplifier inputs (INP and INM) and the output (OUT) are connected to external pins, which allows the use of OPAMP as a standalone operational amplifier device. The other OPAMP configurations allow the operation as a follower and as noninverting or inverting operational amplifier with programmable gain (with or without external filtering and/or biasing).
The programmable gain and the operating mode can be controlled through primary and secondary control register sets that can be activated in a time multiplex by the timer.
The operational amplifier output can be connected, through a multiplexer, to the OPAMP_VOUT pin or internally to a COMP input channel.
The INP input of OPAMP1 can be connected to an output of the internal DAC.
The operational amplifier operates at normal and high speed (slew rate). Its input offset is compensated through factory trimming, which can be modified by the user if needed.
As long as OPAMP is not required, it can be disabled to save power.
24.2 OPAMP main features
- • Rail-to-rail input voltage range
- • Low input bias current
- • Low input offset voltage (factory compensated for)
- • High frequency bandwidth
- • Normal and high speed (slew rate)
- • Timer-controlled operation
Note: Refer to the product datasheet for detailed OPAMP characteristics.
24.3 OPAMP implementation
The device has one OPAMP instance, OPAMP1. Table 179 shows the pin and internal signal specific naming, and provides the assignment to I/Os and the possible connection of the internal signals:
- • Generic name provides the pin and internal signal names as per Figure 156.
- • Instance-specific name provides pin and internal signal names pertaining to each instance.
- • Assignment or possible connection provides the assignment to I/O pins for signals on pins (in upper-case letters), and the possible connections of internal signals (in lower-case letters).
Table 179. OPAMP pin and signal assignment per instance
| Generic name | Instance-specific name | Assignment or possible connection | Comment | |
|---|---|---|---|---|
| OPAMP1 | OPAMP_VINM0 | OPAMP1_VINM0 | PA2 | Selected as additional I/O function |
| OPAMP_VINM1 | OPAMP1_VINM1 | PB1 | ||
| OPAMP_VINP0 | OPAMP1_VINP0 | PA1 | ||
| OPAMP_VINP1 | OPAMP1_VINP1 | PB0 | ||
| OPAMP_VINP2 | OPAMP1_VINP2 | PB15 | ||
| opamp_dac_in | opamp1_dac_in | dac2_int | - | |
| OPAMP_VOUT | OPAMP1_VOUT | PA6 | Selected as additional I/O function | |
| opamp_out | opamp1_out | comp2_inn8 | Selected in the COMP | |
| opamp_pclk | opamp1_pclk1 | - | Enabled/disabled through RCC |
24.4 OPAMP functional description
Each OPAMP instance can individually be enabled. When disabled, its output is in a high-impedance state. When enabled, it can operate in functional or in calibration mode.
In functional mode, the inputs and the output of the operational amplifier are connected as described in Section 24.4.8. In calibration mode, they are all disconnected.
Caution: The GPIOs connected to the operational amplifier terminals through the OPAMP multiplexers must be configured in analog mode (default state), through the corresponding GPIOx_MODER register.
24.4.1 OPAMP block diagram
Figure 156 shows the block diagram of the OPAMP peripheral. The calibration multiplexers and some control bitfields are not shown.
Figure 156. OPAMP block diagram

The diagram illustrates the internal architecture of the OPAMP. It features an operational amplifier with non-inverting (INP) and inverting (INM) inputs. The INP input is selected from either an external pin (OPAMP_VINP3) or a DAC output (opamp_dac_in) via a multiplexer. The INM input is selected from pins OPAMP_VINM0 or OPAMP_VINM1. Control signals include CALON, OPAHSM, USERTRIM, TRIMOFFSETN[4:0], TRIMOFFSETP[4:0], and CALSEL[1:0]. The output (OUT) is connected to a switch controlled by OPAINTOEN, leading to opamp_out to COMP. A resistor divider middle point is also shown. The diagram includes various selection registers: VPS_SEL[1:0], VP_SEL[1:0], VMS_SEL, and VM_SEL[1:0], which are controlled by bits [2:0] and [4:3]. A Register interface block is connected to the 32-bit APB bus and receives opamp_pclk. Other signals include opamp_tc7 to opamp_tc1, opamp_tp7 to opamp_tp1, and TIMCM_SEL[2:0] and TIMPGA_SEL[2:0]. A legend at the bottom defines BITFIELDS (grey box), control signals (arrow with open head), and controls (arrow with closed head). The reference ID MSv56834V1 is located in the bottom right corner.
1. Either OPAMP_VINP3 pin or DAC output, depending on the OPAMP instance. Refer to Section 24.3.
24.4.2 OPAMP pins and internal signals
Table 180 shows the pins used by the OPAMP peripheral. Their names correspond to the configuration for use as inputs or outputs. Refer to Section 24.3 for the assignment of each to an I/O.
Table 180. OPAMP pins
| Name | Type | Description |
|---|---|---|
| OPAMP_VINP0 OPAMP_VINP1 OPAMP_VINP2 OPAMP_VINP3 | I | Selectable as INP noninverting input of the operational amplifier. |
| OPAMP_VINM0 OPAMP_VINM1 | I | Selectable as INM inverting input of the operational amplifier. |
| Name | Type | Description |
|---|---|---|
| OPAMP_VOUT | O | Operational amplifier output. Usable for other purposes when output OUT is redirected to an internal COMP channel. |
Caution: The input and output pins connected, through the OPAMP multiplexers, to the operational amplifier terminals INP, INM, and OUT must be configured in analog mode (default state), through the corresponding GPIOx_MODER register.
Table 181 lists the OPAMP internal signals. Refer to Section 24.3 for the possible connection of each to internal resources and for specialization of the signal name.
Table 181. OPAMP internal input/output signals| Name | Type | Description |
|---|---|---|
| opamp_tc1 opamp_tc2 opamp_tc3 opamp_tc4 opamp_tc5 opamp_tc6 opamp_tc7 | I | Signal from a timer channel, selectable as control signal switching between primary and secondary controls for the input multiplexers. |
| opamp_tp1 opamp_tp2 opamp_tp3 opamp_tp4 opamp_tp5 opamp_tp6 opamp_tp7 | I | Signal from a timer channel, selectable as control signal switching between primary and secondary controls for the programmable gain and for setting the PGA flavor. |
| opamp_dac_in | I | Output of a DAC channel, selectable as noninverting operational amplifier input. Exclusive with the OPAMP_VINP3 pin. |
| opamp_pclk | I | Clock for OPAMP registers. |
| opamp_out | O | Operational amplifier output to an internal COMP channel, when redirected through the OPAINTOEN bit. |
24.4.3 OPAMP reset and clocks
The OPAMP clock opamp_pclk provided by the clock controller is generated from the PCLK1 (APB1 clock). To access the OPAMP control registers, it is necessary to set the corresponding OPAMPxEN bit of the RCC_APB1ENR register.
The OPAMP registers can be reset through the corresponding OPAMPxRST bit of the RCC_APB1RSTR register.
24.4.4 OPAMP output redirection to an internal COMP channel
The operational amplifier output OUT can be redirected internally to a COMP channel, by setting the OPAINTOEN bit of the OPAMP_CSR register. In this case, the I/O pin OPAMP_VOUT on which the operational amplifier output OUT is mapped can be used for another purpose. See Table 179 for possible COMP input channel assignment to OPAMP instances.
When OUT is connected to a COMP input channel, it is not connected to the OPAMP_VOUT pin.
24.4.5 OPAMP initial configuration
By default (upon reset):
- • The operational amplifier inputs INP/INM and output OUT are connected to I/O pins.
- • The registers for offset compensation contain factory trimming values and are in read-only access mode.
- • The speed (slew rate) is set to normal.
- • The timer-controlled operation of multiplexers is disabled.
- • OPAMP is disabled.
24.4.6 OPAMP operational amplifier speed
The initial operational amplifier speed (slew rate, response) is normal. Setting the OPAHSM bit of the OPAMP_CSR register increases the speed. Both normal and high-speed mode characteristics are defined in the datasheet.
24.4.7 OPAMP enable
When disabled (default upon reset), the OPAMP control and calibration registers can still be modified. The operational amplifier output OUT is in high-Z state.
It is recommended to update the OPAMP registers while the OPAMP peripheral is disabled, to avoid spurious effects on the output.
OPAMP is enabled by setting the OPAEN bit of the OPAMP_CSR register. The INP and INM inputs and the OUT output are connected through the embedded multiplexers according to the control register settings and the timer control signals.
24.4.8 OPAMP operating modes
OPAMP can be configured to different operating modes or use cases, through:
- • OPAMP control registers
- • GPIOx_MODER registers, configuring the I/Os selected as OPAMP inputs and output
- • COMP registers, selecting a COMP input channel when the operational amplifier output is redirected to the COMP
- • External components, defining the gain, bias, or filtering parameters
The principal operating modes are:
- • Stand-alone operational amplifier
- • Follower
- • Programmable-gain amplifier (PGA)
Refer to the following subsections for details and for different PGA flavors.
Through the OPAINTOEN bit of the OPAMP control/status register (OPAMP_CSR), the operational amplifier output OUT can be connected to the I/O pin selected as OPAMP output (default) or to an internal COMP input channel. However, the latter option cannot be used when the operational amplifier output on the pin is required.
The OPAHSM bit (0 by default) allows increasing the operational amplifier speed (slew rate).
The USERTRIM bit can enable writing to the input offset trimming register, to allow modifying the by-default factory trimming values by the user.
The impedance of the input signal must be low enough to prevent the OPAMP input current from creating a voltage drop in the source, thus altering the input voltage. Refer to the electrical characteristics section in the datasheet for further details.
Standalone operational amplifier
For this use, ensure the following settings.
- • Select a pin for the INP input (as opposed to a DAC output), with VP_SEL[2:0] and VPS_SEL[2:0] bitfields.
- • Set the VM_SEL[1:0] bitfield to 0X, to ensure that a pin is selected for the INM input.
- • Clear OPAINTOEN bit, to direct the operational amplifier output to the OPAMP_VOUT pin.
With these settings, the INP, INM inputs, and the OUT output of the operational amplifier are connected to pins and to no other internal structure.
Note: The OPAMP_CSR, OPAMP_TCMR, and GPIOx_MODER registers in their default state configure OPAMP as standalone operational amplifier, with normal speed, factory offset trimming values, and with OPAMP_VINP0 and OPAMP_VINM0 selected for INP and INM, respectively. The OPAMP is disabled so the OUT and OPAMP_OUT are in high-Z state.
Once enabled, OPAMP operates as a standalone operational amplifier, with the gain, filtering, and biasing determined by external routing and components.
For this use, the operational amplifier output OUT must be directed to the OPAMP_VOUT pin, and not to the internal COMP channel.
Figure 157. Standalone operational amplifier
![Block diagram of a standalone operational amplifier (OPAMP) configuration. The diagram shows the internal structure of the OPAMP block, including input multiplexers for INP and INM, the operational amplifier core, and an output multiplexer. External pins OPAMP_VINP3 to OPAMP_VINP0 are connected to the INP multiplexer. OPAMP_VINM1 and OPAMP_VINM0 are connected to the INM multiplexer. The INM multiplexer is controlled by VM_SEL[1:0] = 0X. The output of the operational amplifier core is connected to a multiplexer controlled by OPAINTOEN = 0, which selects between the internal OUT and the external OPAMP_VOUT pin. A legend indicates that BITFIELDS are represented by boxes and controls by arrows. The diagram is labeled MSv72541V2.](/RM0522-STM32C5/7522eba3fc61742f5c50db39514aff5e_img.jpg)
Follower
To use OPAMP as a follower with an internal feedback, set the following bitfields as indicated:
- • VM_SEL[1:0] to 11 and VMS_SEL to 1, to loop the operational amplifier output back to its inverting input INM
- • VP_SEL[1:0] and VPS_SEL[1:0] according to the pin or internal DAC output to select for the noninverting input INP
Once enabled, the operational amplifier buffers the voltage selected on its noninverting input INP.
Note: The GPIOs corresponding to OPAMP_VINMy are free for another use.
In this mode, OPAMP takes two pins if a pin is selected for INP noninverting input. It takes a single pin if an internal DAC output is selected for INP noninverting input (on instances supporting this). Refer to Section 24.3.
Figure 158. Follower
![Block diagram of the OPAMP in follower mode. The diagram shows an operational amplifier with noninverting input (INP) and inverting input (INM). The INP is selected from four pins: OPAMP_VINP3, OPAMP_VINP2, OPAMP_VINP1, and OPAMP_VINP0. The INM is selected from two pins: OPAMP_VINM1 and OPAMP_VINM0. A feedback loop is shown from the output (OUT) back to the INM input, controlled by bitfields VM_SEL[1:0] = 11 and VMS_SEL = 1. The output (OUT) is connected to a switch controlled by OPAINTOEN, which can route the signal to opamp_out or to COMP. The output is also connected to OPAMP_VOUT. A legend indicates that BITFIELDS control the switch. The diagram is labeled MSv56835V1.](/RM0522-STM32C5/2a44e5be0458e118584338d76bc1d166_img.jpg)
Programmable-gain amplifier
When OPAMP is configured as a programmable-gain amplifier (PGA), the internal resistor divider with a programmable resistor value determines the amplifier gain. Refer to the datasheet for the values of the internal resistors.
The following sections describe different PGA flavors.
Noninverting PGA
To use OPAMP as a noninverting PGA without filtering, set the following bitfields as indicated:
- • VM_SEL[1:0] to 10 and VMS_SEL to 0, to connect the resistor divider middle point to the inverting operational amplifier input
- • PGA_GAIN[4:0] and PGAS_GAIN[4:0] to 00XXX, with XXX according to the desired positive gain
- • VP_SEL[1:0] and VPS_SEL[1:0] according to the pin or internal DAC output to select as noninverting operational amplifier input
Once enabled, OPAMP outputs a voltage that corresponds to the selected input pin voltage multiplied by the selected gain value.
Note: To avoid saturation, keep the product of the input voltage and the selected gain value below \(V_{DDA}\).
Figure 159. Noninverting PGA
![Block diagram of the Noninverting PGA configuration within the OPAMP. The diagram shows an operational amplifier with a non-inverting input (INP) and an inverting input (INM). The INP is connected to a multiplexer selecting from OPAMP_VINP3, OPAMP_VINP2, OPAMP_VINP1, and OPAMP_VINP0. The INM is connected to a multiplexer selecting from OPAMP_VINM1 and OPAMP_VINM0, with a feedback path from the output. Control bitfields are shown: VM_SEL[1:0] = 10, VMS_SEL = 0, PGA_GAIN[4:3] = 00, and PGAS_GAIN[4:3] = 00. The output (OUT) is connected to a switch controlled by OPAINTOEN (values 1 and 0) and a variable gain resistor. The final output is opamp_out to COMP. The OPAMP_VOUT pin is also shown. A legend indicates that BITFIELDS control the components.](/RM0522-STM32C5/3f799c131ff6d51661ee6d8b75cbf6ad_img.jpg)
Noninverting PGA with filtering
To use OPAMP as a noninverting PGA with filtering, set the following bitfields as indicated:
- • VM_SEL[1:0] to 10 and VMS_SEL to 0, to connect the resistor divider middle point to the inverting operational amplifier input
- • PGA_GAIN[4:0] and PGAS_GAIN[4:0] to 10XXX, with XXX according to the desired positive gain
- • VP_SEL[1:0] and VPS_SEL[1:0] according to the pin or internal DAC output to select as noninverting operational amplifier input
Once enabled, OPAMP outputs a voltage that corresponds to the selected input pin voltage multiplied with the selected gain (for static signals).
External components connected between the OPAMP_VOUT pin and the OPAMP_VINM0 pin are put in parallel with the internal programmable resistor. For example, connecting a capacitor \(C_F\) as shown in Figure 160 has a filtering effect equivalent to \(C_F'\) of the same
capacitance. The gain for dynamic signals then also depends on the signal frequency and the cutoff frequency of the filter.
For this use, the operational amplifier output OUT must be directed to the OPAMP_VOUT pin and not to the internal COMP channel.
Figure 160. Noninverting PGA with filtering
![Schematic diagram of a Noninverting PGA with filtering. The diagram shows an OPAMP block with inputs OPAMP_VINP3, OPAMP_VINP2, OPAMP_VINP1, OPAMP_VINP0, OPAMP_VINM1, and OPAMP_VINM0. The non-inverting input (INP) is connected to a resistor divider network. The inverting input (INM) is connected to a feedback network consisting of a capacitor C_F and a variable resistor. The output (OUT) is connected to a switch controlled by OPAINTOEN, which can route the output to opamp_out or to COMP. The diagram also shows control signals for VM_SEL[1:0] = 10, VMS_SEL = 0, PGA_GAIN[4:3] = 10, PGAS_GAIN[4:3] = 10, and PGA_GAIN[2:0].](/RM0522-STM32C5/3760fcfbd2c2609d8dd262ec065e6762_img.jpg)
The diagram illustrates the internal structure of the OPAMP for noninverting PGA with filtering. It shows the input pins (OPAMP_VINP3 to OPAMP_VINP0 and OPAMP_VINM1 to OPAMP_VINM0) connected to a resistor divider network. The non-inverting input (INP) is connected to the top of the divider, and the inverting input (INM) is connected to the bottom. The output (OUT) is connected to a switch controlled by OPAINTOEN, which can route the output to opamp_out or to COMP. The diagram also shows control signals for VM_SEL[1:0] = 10, VMS_SEL = 0, PGA_GAIN[4:3] = 10, PGAS_GAIN[4:3] = 10, and PGA_GAIN[2:0].
Noninverting PGA with external bias, or inverting PGA
To use OPAMP as a noninverting PGA with external bias or as an inverting PGA, set the following bitfields as indicated:
- • VM_SEL[1:0] to 10 and VMS_SEL to 0, to connect the resistor divider middle point to the inverting operational amplifier input
- • PGA_GAIN[4:0] and PGAS_GAIN[4:0] to 01XXX, with XXX according to the desired positive gain
- • VP_SEL[1:0] and VPS_SEL[1:0] according to the pin or internal DAC output to select as noninverting operational amplifier input
For the signal on the selected OPAMP_VINPy pin, OPAMP operates as a noninverting amplifier with the selected positive gain. The OPAMP_VINM0 pin is used as a reference (bias).
For the signal on the OPAMP_VINM0 pin, OPAMP operates as an inverting amplifier with the selected negative gain. The selected OPAMP_VINPy pin is used as a reference.
Note: The final gain depends upon the output impedance of the source connected to the OPAMP_VINM0 pin.
For this use, the operational amplifier output OUT must be directed to the OPAMP_VOUT pin, and not to the internal COMP channel.
Figure 161. Noninverting PGA with external bias, or inverting PGA
![Schematic diagram of an OPAMP configured as a noninverting or inverting PGA with external bias. The diagram shows an operational amplifier with inputs INP (+) and INM (-). INP is connected to a multiplexer selecting from OPAMP_VINP3, OPAMP_VINP2, OPAMP_VINP1, and OPAMP_VINP0. INM is connected to a multiplexer selecting from OPAMP_VINM1 and OPAMP_VINM0. A resistor divider is connected between OPAMP_VOUT and OPAMP_VINM0, with its midpoint connected to INM. The output OUT is connected to a switch controlled by OPAINTOEN, which can route the signal to opamp_out or to COMP. Bitfields are indicated: VM_SEL[1:0] = 10, VMS_SEL = 0, PGA_GAIN[4:3] = 01, PGAS_GAIN[4:3] = 01, and PGA_GAIN[2:0] / PGAS_GAIN[2:0].](/RM0522-STM32C5/4404b46dac18960c034d364f9153b49a_img.jpg)
OPAMP
OPAMP_VINP3
OPAMP_VINP2
OPAMP_VINP1
OPAMP_VINP0
OPAMP_VINM1
OPAMP_VINM0
INP +
INM -
Operational amplifier
OUT
OPAINTOEN
opamp_out
to COMP
VM_SEL[1:0] = 10
VMS_SEL = 0
PGA_GAIN[4:3] = 01
PGAS_GAIN[4:3] = 01
PGA_GAIN[2:0]
PGAS_GAIN[2:0]
OPAMP_VOUT
BITFIELDS → controls
MSv56838V1
Inverting or noninverting PGA with external bias or/and filtering
To use OPAMP as a noninverting PGA with external bias, or as an inverting PGA with filtering, set the following bitfields as indicated:
- • VM_SEL[1:0] to 10 and VMS_SEL to 0, to connect the resistor divider middle point to the inverting operational amplifier input
- • PGA_GAIN[4:0] and PGAS_GAIN[4:0] to 11XXX, with XXX according to the desired positive gain
- • VP_SEL[1:0] and VPS_SEL[1:0] according to the pin or internal DAC output to select as noninverting operational amplifier input
For the signal on the selected OPAMP_VINPy pin, OPAMP operates as a noninverting amplifier with the selected positive gain. The voltage on the OPAMP_VINM0 pin is used as a reference (bias).
For the signal on the OPAMP_VINM0 pin, OPAMP operates as an inverting amplifier with the selected negative gain. The voltage on the selected OPAMP_VINPy pin is used as a reference (bias). The output impedance of the biasing voltage source impacts the total gain.
In both cases, any external components connected between the OPAMP_VOUT pin and the OPAMP_VINM1 pin are put in parallel with the internal programmable resistor. For example, connecting a capacitor \(C_F\) as shown in the following figure has a filtering effect equivalent to \(C_F'\) of the same capacitance. The gain for dynamic signals then also depends on the signal frequency and the cutoff frequency of the filter.
For this use, the operational amplifier output OUT must be directed to the OPAMP_VOUT pin and not to the internal COMP channel.
Figure 162. Inverting or noninverting PGA with external bias or/and filtering![Figure 162: Detailed schematic of an OPAMP peripheral showing PGA configuration with external bias or/and filtering. Includes input selector for INP+, INM- multiplexer, operational amplifier, external capacitor C_F, feedback network, switch for internal/external connection controlled by OPAINTOEN, and bitfields controls VM_SEL[1:0] = 10, VMS_SEL = 0, PGA_GAIN[4:3] = 11, PGAS_GAIN[4:3] = 11, PGA_GAIN[2:0], PGAS_GAIN[2:0].](/RM0522-STM32C5/9f69b82d06f359a2b58dfd23e02e42c2_img.jpg)

24.4.9 OPAMP programmable gain
In PGA mode, OPAMP allows selecting one of discrete positive (noninverting configuration) or negative (inverting configuration) gain values. The selection is done through the bits [2:0] of the PGA_GAIN[4:0] bitfield of the OPAMP_CSR register or through the bits [2:0] of the PGAS_GAIN[4:0] bitfield of the OPAMP_TCMR register. The control bitfield is selected with the control signal at the output of the opamp_tpX selector.
In noninverting mode, the programmable gain depends only upon the internal resistive divider. In inverting mode, depends upon the internal resistors, and upon the output impedance of the signal source. The higher it is, the greater impact it has on the final gain.
24.4.10 OPAMP operational amplifier offset compensation
The peripheral incorporates a trimming circuitry that impacts the operational amplifier input offset. The trimming circuitry is controlled through the TRIMOFFSETN[4:0] (for the N differential pair) and TRIMOFFSETP[4:0] (for the P differential pair) bitfields of the OPAMP control/status register (OPAMP_CSR).
The TRIMOFFSETN[4:0] and TRIMOFFSETP[4:0] bitfields keep the trimming value for the N differential pair and P differential pair, respectively.
Upon reset, these registers are loaded with factory trimming values stored in the nonvolatile memory. As the USERTRIM bit is low, the TRIMOFFSETN[4:0] and TRIMOFFSETP[4:0] control bitfields are read-only.
Note: The factory trimming values result from a calibration procedure run on the production line in specific production conditions.
When the offset compensation obtained with the factory trimming values is not acceptable for a specific use case (supply voltage, operating temperature), the user software can apply different trimming values.
To modify the trimming values, the user software has first to set the USERTRIM bit to allow writing into the TRIMOFFSETN[4:0] and TRIMOFFSETP[4:0] control bitfields.
To retain the user trimming values, the user software has to write them into a nonvolatile memory. It typically retrieves them from the nonvolatile memory and writes into TRIMOFFSETN[4:0] and TRIMOFFSETP[4:0] at the startup, before the first use of OPAMP.
The resolution of the offset trimming allows reducing the input offset voltage to a value defined in the datasheet, at a defined supply voltage and die temperature.
24.4.11 OPAMP calibration
The calibration allows finding the trimming values that minimize the operational amplifier offset.
Setting the CALON bit isolates the operational amplifier INP and INM inputs and connects them to the internal reference voltage level selected through the CALSEL[1:0] bitfield. The operational amplifier is in a comparator (high gain, open loop) mode in which its output transits from one rail to another when the voltage level on one input crosses the voltage level on the other input.
The CALOUT flag reflects this digital value (lower rail or upper rail) of the OPAMP_VOUT pin.
The CALSEL[1:0] bitfield values 01 (low reference voltage) and 11 (high reference voltage) are intended for use in the calibration procedure. The value 01 is for trimming the PMOS through the TRIMOFFSETP[4:0] bitfield, the value 11 for trimming the NMOS through the TRIMOFFSETN[4:0] bitfield.
The calibration is carried out by software. Starting from the trimming bitfield at 0 and the CALOUT flag at one, the procedure consists in incrementing the trimming value until the CALOUT flag toggles to 0. The last trimming value is the one that compensates for the operational amplifier offset of the given OPAMP instance, and for the given supply voltage, die temperature, and differential pair stage (PMOS or NMOS). Upon each trimming value incrementation, the software must wait for at least the \(t_{OFFTRIMmax}\) period defined in the product datasheet, before reading the CALOUT flag and potentially proceeding to the next incrementation step.
Note: The closer is the trimming value to the offset compensation point, the longer the output voltage takes to respond (without ever exceeding \(t_{OFFTRIMmax}\)).
The full calibration consists of four calibration loops, as listed in Table 182. They can be executed in any order. The CALON bit must be set for executing any calibration loop. The calibration loops for the operational amplifier speed (slew rate) not required in the application can be omitted.
Table 182. Calibration loops
| Calibration loop | Control bitfield | ||
|---|---|---|---|
| CALSEL[1:0] | TRIMOFFSETN[4:0] | TRIMOFFSETP[4:0] | |
| NMOS | 11 | Increment | Keep as is |
| PMOS | 01 | Keep as is | Increment |
Different OPAMP instances can be calibrated at any time, even at the same time.
Calibration initialization
To initialize the offset trimming value calibration:
- • Enable OPAMP, by setting OPAEN.
- • Make the trimming bitfields writable, by setting USERTRIM.
- • Write TRIMOFFSETN[4:0] and TRIMOFFSETP[4:0] bitfields with 0b00000.
Calibration loop sequence
To execute a calibration loop, go through the following steps:
- 1. Select the calibration loop, with the CALSEL[1:0] bitfield. That is, the speed (slew rate) and the differential pair end (NMOS or PMOS) to calibrate.
- 2. Increment the appropriate trimming bitfield (TRIMOFFSETN[4:0] for NMOS, TRIMOFFSETP[4:0] for PMOS), keeping the other trimming bitfield as is.
- 3. Wait for at least the \(t_{OFFTRIMmax}\) period.
- 4. Check the CALOUT flag (OPAINTOEN = 0). If high, go to step 2 (loop back).
- 5. The trimming bitfield is calibrated. Store the calibrated trimming value if required.
For a given speed (slew rate), execute both the NMOS and the PMOS calibration loops.
Note: During the calibration loop execution, the external connection of the operational amplifier output must not pull up or down currents exceeding 500 μA.
Calibrating when operational amplifier output goes to a COMP input
With the operational amplifier output redirected to an internal COMP input channel (OPAINTOEN bit set), the CALOUT flag does not reflect the operational amplifier output. To address this, it is advised to clear the OPAINTOEN bit for the time of calibration to make the CALOUT flag operate. When the calibration is completed, set OPAINTOEN to redirect the operational amplifier output back to a COMP input channel. As during the calibration the internal signal sent to the OPAMP_VOUT pin toggles, take care to prevent any conflict on the pin. For example, use the pin in the application as an input.
24.4.12 Timer-controlled operation
Certain timer channels (see Table 183) can toggle the control of the operational amplifier multiplexers between the primary configuration defined through the OPAMP_CSR register and the secondary configuration defined through the OPAMP_TCMR register.
Once configured, the mechanism operates even when the OPAMP clock is disabled.
As an example, this can be used for dual motor control. Figure 164 illustrates the use of a timer compare output toggling the OPAMP primary (default) and secondary configurations, to measure alternatively the currents of the three phases of a motor, then of the other motor.
Figure 164. Timer-controlled operation for a dual motor application

Timer-controlled input selection
This operation is activated by writing a value other than 0 to the TIMCM_SEL[2:0] bitfield of the OPAMP_TCMR register, thus selecting one of the opamp_tcX signals. As long as the selected signal is low, the input selectors are controlled with the VP_SEL[1:0] and VM_SEL[1:0] bitfields of the OPAMP_CSR register. As long as it is high, the input selectors are controlled with the VPS_SEL[1:0] and VMS_SEL bitfields of the OPAMP_TCMR register. Writing 0 to TIMCM_SEL[2:0] (default upon reset) makes the input selectors steadily controlled with VP_SEL[1:0] and VM_SEL[1:0].
Table 183 gives the correspondence between the opamp_tcX and the timer signals.
Table 183. Timer-controlled input selection
| TIMCM_SEL[2:0] | Signal name | Timer connection |
|---|---|---|
| 000 | - | None |
| 001 | opamp_tc1 | tim1_oc6 |
| 010 | opamp_tc2 | tim2_oc4 |
| 011 | opamp_tc3 | tim12_oc1 |
| 100 | opamp_tc4 | tim15_oc2 |
| 101 | opamp_tc5 | Reserved |
| 110 | opamp_tc6 | Reserved |
| 111 | opamp_tc7 | Reserved |
Timer-controlled programmable gain and PGA flavor
This operation is activated by writing a value other than 0 to the TIMPGA_SEL[2:0] bitfield of the OPAMP_TCMR register, thus selecting one of opamp_tpX signals. As long as the selected signal is low, the programmable gain and PGA flavor selectors are controlled with the PGA_GAIN[4:0] bitfield of the OPAMP_CSR register. As long as it is high, the input selectors are controlled with the PGAS_GAIN[4:0] bitfield of the OPAMP_TCMR register. Writing 0 to TIMPGA_SEL[2:0] (default upon reset) makes the programmable gain and PGA flavor selectors steadily controlled with PGA_GAIN[4:0].
The following table gives the correspondence of the opamp_tpX signals to timer signals.
Table 184. Timer-controlled programmable gain selection
| TIMPGA_SEL[2:0] | Signal name | Timer connection |
|---|---|---|
| 000 | - | None |
| 001 | opamp_tp1 | tim1_oc6 |
| 010 | opamp_tp2 | tim2_oc4 |
| 011 | opamp_tp3 | tim12_oc2 |
| 100 | opamp_tp4 | tim15_oc2 |
| 101 | opamp_tp5 | Reserved |
| 110 | opamp_tp6 | Reserved |
| 111 | opamp_tp7 | Reserved |
24.5 OPAMP in low-power modes
Table 185. Effect of low-power modes on OPAMP
| Mode | Description |
|---|---|
| Sleep | No effect. |
| Stop | No effect, OPAMP register contents are kept. |
| Standby | The OPAMP registers are powered down and must be re-initialized after exiting Standby mode. |
24.6 OPAMP registers
24.6.1 OPAMP control/status register (OPAMP_CSR)
Address offset: 0x00
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LOCK | CAL OUT | TSTREF | TRIMOFFSETN[4:0] | TRIMOFFSETP[4:0] | PGA_GAIN[4:2] | ||||||||||
| rw | r | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| PGA_GAIN[1:0] | CALSEL[1:0] | CALON | Res. | Res. | OPA INTOEN | OPA HSM | VM_SEL[1:0] | USER TRIM | VP_SEL[1:0] | FORCE_VP | OPAEN | ||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | ||
Bit 31 LOCK: OPAMP_CSR register lock
This bit is write-once. It is set by software. It can only be cleared by a system reset.
This bit is used to configure the OPAMP_CSR register as read-only.
0: OPAMP_CSR is read-write
1: OPAMP_CSR is read-only
Bit 30 CALOUT: Operational amplifier calibration output
This bit reflects the digital value of OPAMP output when OPAINTOEN bit is low. During the input offset calibration procedure, it provides the indication that the target trimming value is reached, by transiting from 1 to 0.
The bit cannot be used as long as the OPAINTOEN bit is high.
Bit 29 TSTREF: OPAMP calibration reference voltage output control
This bit is reserved for test. When set, OPAMP outputs the calibration reference voltage.
0: Does not output calibration reference voltage
1: Outputs calibration reference voltage
Bits 28:24 TRIMOFFSETN[4:0]: Trim for NMOS differential pairs
Upon reset, this bitfield is loaded with the factory trimming value. It can only be modified when the USERTRIM bit is set.
Bits 23:19 TRIMOFFSETP[4:0]: Trim for PMOS differential pairs
Upon reset, this bitfield is loaded with the factory trimming value. It can only be modified when the USERTRIM bit is set.
- Bits 18:14 PGA_GAIN[4:0]: Operational amplifier programmable gain and PGA flavor primary control
This bitfield selects the programmable gain (bits [2:1]) and the PGA flavor ([bits 4:3]). Positive numbers represent positive gain (noninverting PGA), negative numbers negative gain (inverting PGA).
00000: gain 2
00001: gain 4
00010: gain 8
00011: gain 16
01000: gain -1 / gain 2 with bias on OPAMP_VINM0
01001: gain -3 / gain 4 with bias on OPAMP_VINM0
01010: gain -7 / gain 8 with bias on OPAMP_VINM0
01011: gain -15 / gain 16 with bias on OPAMP_VINM0
10000: gain 2 with filtering on OPAMP_VINM0
10001: gain 4 with filtering on OPAMP_VINM0
10010: gain 8 with filtering on OPAMP_VINM0
10011: gain 16 with filtering on OPAMP_VINM0
11000: gain -1 / gain 2 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
11001: gain -3 / gain 4 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
11010: gain -7 / gain 8 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
11011: gain -15 / gain 16 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
Other: Not used - Bits 13:12 CALSEL[1:0]: Calibration selection
This bitfield selects the offset calibration reference voltage applied on the operational amplifier inputs when CALON and FORCE_VP bits are set.
00: \(0.033 \cdot V_{DDA}\)
01: \(0.1 \cdot V_{DDA}\) (for PMOS calibration)
10: \(0.5 \cdot V_{DDA}\)
11: \(0.9 \cdot V_{DDA}\) (for NMOS calibration) - Bit 11 CALON: Calibration mode enable
This bitfield disables or enables the calibration mode.
0: Calibration mode disabled
1: Calibration mode enabled - Bits 10:9 Reserved, must be kept at reset value.
- Bit 8 OPAINTOEN: Operational amplifier internal output enable
This bit determines where the operational amplifier output is connected, either to the OPAMP_VOUT pin or internally to a COMP channel.
0: OPAMP_VOUT pin
1: COMP channel - Bit 7 OPAHSM: Operational amplifier high-speed mode
This bit determines the speed (slew rate) of the operational amplifier.
0: Normal speed
1: High speed
Only change this configuration when OPAMP is disabled.
Bits 6:5 VM_SEL[1:0]: Inverting input primary selection
This bitfield determines where the operational amplifier inverting input is connected to.
00: OPAMP_VINM0 pin
01: OPAMP_VINM1 pin
10: Internal resistor divider middle point
11: Operational amplifier output
The setting 10 is for the PGA use cases. With this setting, the connection of the OPAMP_VINM0 and OPAMP_VINM1 pins is determined by the PGA_GAIN[4:0] bitfield.
The setting 11 sets OPAMP in follower mode. With the other two settings, OPAMP is configured as a stand-alone operational amplifier.
Bit 4 USERTRIM: User trimming enable
This bit enables the user trimming of the operational amplifier input offset. When set, the TRIMOFFSETN[4:0] and TRIMOFFSETP[4:0] bitfields, loaded with factory trimming values upon reset, become writable. This allows modifying the input offset trimming values by the user.
0: Disable (trimming by user not possible)
1: Enable (trimming by user possible)
Bits 3:2 VP_SEL[1:0]: Noninverting input primary selection
This bitfield determines where the operational amplifier noninverting input is connected to.
00: OPAMP_VINP0 pin
01: OPAMP_VINP1 pin
10: OPAMP_VINP2 pin
11: OPAMP_VINP3 pin or DAC output channel
Refer to Section 24.3: OPAMP implementation for OPAMP instance-dependent information.
Bit 1 FORCE_VP: Force internal reference on noninverting input
This bit is reserved for test. It allows forcing the calibration reference voltage selected through the CALSEL[1:0] bitfield on the operational amplifier noninverting input.
0: Do not force (normal operation)
1: Force
Bit 0 OPAEN: Operational amplifier enable
This bit enables and disables the operational amplifier.
0: Disable
1: Enable
24.6.2 OPAMP timer-controlled mode register (OPAMP_TCMR)
Address offset: 0x04
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LOCK | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| rw | |||||||||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| TIMPGA_SEL[2:0] | PGAS_GAIN[4:0] | Res. | Res. | TIMCM_SEL[2:0] | VPS_SEL[1:0] | VMS_SEL | |||||||||
| rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | rw | ||
Bit 31 LOCK: OPAMP_TCMR register lock
This bit is write-once. It is set by software. It can only be cleared by a system reset.
This bit determines whether the OPAMP_TCMR register is read-write or read-only.
0: Read-write
1: Read-only (OPAMP_TCMR locked)
Bits 30:16 Reserved, must be kept at reset value.
Bits 15:13 TIMPGA_SEL[2:0]: Timer toggle signal selection for programmable gain control
This bitfield is set and cleared by software. It selects the signal (coming from timer to OPAMP multiplexers) that toggles the programmable gain control bitfields between the primary (PGA_GAIN[4:0], signal at low level) and secondary (PGAS_GAIN[4:0], signal at high level).
000: None (gain permanently controlled through PGA_GAIN[4:0] and VM_SEL[1:0])
001: opamp_tp1
010: opamp_tp2
011: opamp_tp3
100: opamp_tp4
101: opamp_tp5
110: opamp_tp6
111: opamp_tp7
Bits 12:8 PGAS_GAIN[4:0]: Operational amplifier programmable gain and PGA flavor secondary control
This bitfield selects the programmable gain (bits [2:1]) and the PGA flavor ([bits 4:3]) when the timer signal selected through TIMPGA_SEL[2:0] is high. Positive numbers represent positive gain (noninverting PGA), negative numbers negative gain (inverting PGA).
00000: gain 2
00001: gain 4
00010: gain 8
00011: gain 16
01000: gain -1 / gain 2 with bias on OPAMP_VINM0
01001: gain -3 / gain 4 with bias on OPAMP_VINM0
01010: gain -7 / gain 8 with bias on OPAMP_VINM0
01011: gain -15 / gain 16 with bias on OPAMP_VINM0
10000: gain 2 with filtering on OPAMP_VINM0
10001: gain 4 with filtering on OPAMP_VINM0
10010: gain 8 with filtering on OPAMP_VINM0
10011: gain 16 with filtering on OPAMP_VINM0
11000: gain -1 / gain 2 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
11001: gain -3 / gain 4 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
11010: gain -7 / gain 8 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
11011: gain -15 / gain of 16 with bias on OPAMP_VINM0 and filtering on OPAMP_VINM1
Other: Not used
Bits 7:6 Reserved, must be kept at reset value.
Bits 5:3 TIMCM_SEL[2:0]: Timer toggle signal selection for operational amplifier input control
This bitfield is set and cleared by software. It selects the signal (coming from timer to OPAMP multiplexers) that toggles the operational amplifier input configuration control bitfields between the primary (VP_SEL[1:0] / VM_SEL, signal at low level) and secondary (VPS_SEL[1:0] / VMS_SEL, signal at high level).
000: None (input configuration permanently controlled through VP_SEL[1:0] and VM_SEL)
001: opamp_tc1
010: opamp_tc2
011: opamp_tc3
100: opamp_tc4
101: opamp_tc5
110: opamp_tc6
111: opamp_tc7
Bits 2:1 VPS_SEL[1:0]: OPAMP noninverting input secondary selection.
This bitfield is set and cleared by software. It selects the signal to connect to the operational amplifier noninverting input as long as the level of the timer signal selected through the TIMCM_SEL[2:0] bitfield is high.
00: OPAMP_VINP0
01: OPAMP_VINP1
10: OPAMP_VINP2
11: OPAMP_VINP3 pin or DAC output channel
Refer to Section 24.3: OPAMP implementation for OPAMP instance-dependent information.
Bit 0 VMS_SEL: OPAMP inverting input secondary selection
This bitfield is set and cleared by software. It selects the signal to connect to the operational amplifier inverting input as long as the level of the timer signal selected through the TIMCM_SEL[2:0] bitfield is high. The effect also depends on the VM_SEL[1:0] bitfield.
Condition: VM_SEL[1:0] = 00 or 01
0: OPAMP_VINM0 (operation as stand-alone operational amplifier)
1: OPAMP_VINM1 (operation as stand-alone operational amplifier)
Condition: VM_SEL[1:0] = 10 or 11
0: Internal resistor divider middle point (operation as PGA)
1: Operational amplifier output (operation as follower)
24.6.3 OPAMP register map
Table 186. OPAMP register map and reset values
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x000 | OPAMP_CSR | LOCK | CALOUT | Res | TRIMOFFSETN [4:0] | TRIMOFFSETP [4:0] | PGA_GAIN[4:0] | CALSEL | CALON | Res. | Res. | OPAINTOEN | OPAHSN | VM_SEL | USERTRIM | VP_SEL [1:0] | FORCE_VP | OPAEN | |||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |||
| 0x004 | OPAMP_TCMR | LOCK | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | TIMPGA_SEL [2:0] | PGAS_GAIN [4:0] | Res. | Res. | Res. | TIMCM_SEL [2:0] | VPS_SEL [1:0] | VMS_SE | ||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||||||||
| 0x008 - 0x3FC | Reserved | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | |