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

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:

Table 179. OPAMP pin and signal assignment per instance

Generic nameInstance-specific nameAssignment or possible connectionComment
OPAMP1OPAMP_VINM0OPAMP1_VINM0PA2Selected as additional I/O function
OPAMP_VINM1OPAMP1_VINM1PB1
OPAMP_VINP0OPAMP1_VINP0PA1
OPAMP_VINP1OPAMP1_VINP1PB0
OPAMP_VINP2OPAMP1_VINP2PB15
opamp_dac_inopamp1_dac_indac2_int-
OPAMP_VOUTOPAMP1_VOUTPA6Selected as additional I/O function
opamp_outopamp1_outcomp2_inn8Selected in the COMP
opamp_pclkopamp1_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

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.

Figure 156. OPAMP block diagram

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

NameTypeDescription
OPAMP_VINP0
OPAMP_VINP1
OPAMP_VINP2
OPAMP_VINP3
ISelectable as INP noninverting input of the operational amplifier.
OPAMP_VINM0
OPAMP_VINM1
ISelectable as INM inverting input of the operational amplifier.
Table 180. OPAMP pins (continued)
NameTypeDescription
OPAMP_VOUTOOperational 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
NameTypeDescription
opamp_tc1
opamp_tc2
opamp_tc3
opamp_tc4
opamp_tc5
opamp_tc6
opamp_tc7
ISignal 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
ISignal 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_inIOutput of a DAC channel, selectable as noninverting operational amplifier input. Exclusive with the OPAMP_VINP3 pin.
opamp_pclkIClock for OPAMP registers.
opamp_outOOperational 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):

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:

The principal operating modes are:

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.

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

Follower

To use OPAMP as a follower with an internal feedback, set the following bitfields as indicated:

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

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:

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

Noninverting PGA with filtering

To use OPAMP as a noninverting PGA with filtering, set the following bitfields as indicated:

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

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

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

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:

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

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

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

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:

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].
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].
Figure 163. Simplified view Figure 163: Simplified view of Noninverting PGA and Inverting PGA circuits with inputs, feedback resistors, capacitors, and bias voltage connections.
Figure 163: Simplified view of Noninverting PGA and Inverting PGA circuits with inputs, feedback resistors, capacitors, and bias voltage connections.

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 loopControl bitfield
CALSEL[1:0]TRIMOFFSETN[4:0]TRIMOFFSETP[4:0]
NMOS11IncrementKeep as is
PMOS01Keep as isIncrement

Different OPAMP instances can be calibrated at any time, even at the same time.

Calibration initialization

To initialize the offset trimming value calibration:

Calibration loop sequence

To execute a calibration loop, go through the following steps:

  1. 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. 2. Increment the appropriate trimming bitfield (TRIMOFFSETN[4:0] for NMOS, TRIMOFFSETP[4:0] for PMOS), keeping the other trimming bitfield as is.
  3. 3. Wait for at least the \(t_{OFFTRIMmax}\) period.
  4. 4. Check the CALOUT flag (OPAINTOEN = 0). If high, go to step 2 (loop back).
  5. 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

Figure 164: Timer-controlled operation for a dual motor application. The diagram shows a timing diagram with five horizontal axes. The top axis is 'CCR6' showing a sawtooth wave. Below it is 'T1 counter' showing a sawtooth wave. Below that is 'T8 counter' showing a sawtooth wave. Below that is 'T1 output (1 out of 3)' showing a square wave. Below that is 'T8 output (1 out of 3)' showing a square wave. Below that is 'T1 CC6 output arriving on OPAMP input mux' showing a square wave. At the bottom is 'OPAMP input selection' showing a sequence of 'Sec', 'Def', 'Sec', 'Def', 'Sec'. Arrows indicate the timing of ADC sampling points relative to the counter and output signals. A legend defines 'Def = default OPAMP input selection' and 'Sec = secondary OPAMP input selection'. The reference 'MS192230V3' is at the bottom right.
Figure 164: Timer-controlled operation for a dual motor application. The diagram shows a timing diagram with five horizontal axes. The top axis is 'CCR6' showing a sawtooth wave. Below it is 'T1 counter' showing a sawtooth wave. Below that is 'T8 counter' showing a sawtooth wave. Below that is 'T1 output (1 out of 3)' showing a square wave. Below that is 'T8 output (1 out of 3)' showing a square wave. Below that is 'T1 CC6 output arriving on OPAMP input mux' showing a square wave. At the bottom is 'OPAMP input selection' showing a sequence of 'Sec', 'Def', 'Sec', 'Def', 'Sec'. Arrows indicate the timing of ADC sampling points relative to the counter and output signals. A legend defines 'Def = default OPAMP input selection' and 'Sec = secondary OPAMP input selection'. The reference 'MS192230V3' is at the bottom right.

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 nameTimer connection
000-None
001opamp_tc1tim1_oc6
010opamp_tc2tim2_oc4
011opamp_tc3tim12_oc1
100opamp_tc4tim15_oc2
101opamp_tc5Reserved
110opamp_tc6Reserved
111opamp_tc7Reserved

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 nameTimer connection
000-None
001opamp_tp1tim1_oc6
010opamp_tp2tim2_oc4
011opamp_tp3tim12_oc2
100opamp_tp4tim15_oc2
101opamp_tp5Reserved
110opamp_tp6Reserved
111opamp_tp7Reserved

24.5 OPAMP in low-power modes

Table 185. Effect of low-power modes on OPAMP

ModeDescription
SleepNo effect.
StopNo effect, OPAMP register contents are kept.
StandbyThe 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

31302928272625242322212019181716
LOCKCAL OUTTSTREFTRIMOFFSETN[4:0]TRIMOFFSETP[4:0]PGA_GAIN[4:2]
rwrrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
PGA_GAIN[1:0]CALSEL[1:0]CALONRes.Res.OPA INTOENOPA HSMVM_SEL[1:0]USER TRIMVP_SEL[1:0]FORCE_VPOPAEN
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

31302928272625242322212019181716
LOCKRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rw
1514131211109876543210
TIMPGA_SEL[2:0]PGAS_GAIN[4:0]Res.Res.TIMCM_SEL[2:0]VPS_SEL[1:0]VMS_SEL
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000OPAMP_CSRLOCKCALOUTResTRIMOFFSETN [4:0]TRIMOFFSETP [4:0]PGA_GAIN[4:0]CALSELCALONRes.Res.OPAINTOENOPAHSNVM_SELUSERTRIMVP_SEL [1:0]FORCE_VPOPAEN
Reset value000000000000000000000000000000
0x004OPAMP_TCMRLOCKResResResResResResResResResResResResResResResTIMPGA_SEL [2:0]PGAS_GAIN [4:0]Res.Res.Res.TIMCM_SEL [2:0]VPS_SEL [1:0]VMS_SE
Reset value000000000000000
0x008 - 0x3FCReservedResResResResResResResResResResResResResResResResResResResResResResResResResResResResResResRes
Refer to Section 2.2 on page 90 for the register boundary addresses.