15. Operational amplifiers (OPAMP)

This section applies to Cat.3, Cat.4, Cat.5 and Cat.6 devices only. See device datasheet for OPAMP availability (OPAMP is not present in STM32L100xx product categories - see Table 2 ).

15.1 OPAMP introduction

The MCU has three operational amplifiers with external or internal follower routing capability (or even amplifier and filter capability with external components). When one operational amplifier is selected, one external ADC channel is used to enable output measurement.

15.2 OPAMP main features

15.3 OPAMP functional description

Three operational amplifiers (OPAMP1, OPAMP2 and OPAMP3) are available on Cat.4 devices and two operational amplifiers (OPAMP1 and OPAMP2) are available on Cat.3, Cat.5 and Cat.6 devices. OPAMP is not available in STM32L100xx product categories - see Table 2 . The connection with dedicated I/O are listed below:


a. Or dedicated OPAMPx_VINM pin available on some packages.

15.3.1 Signal routing

Figure 69. OPAMP1 signal routing

Figure 69. OPAMP1 signal routing diagram

The diagram illustrates the signal routing for OPAMP1. The non-inverting input (+) is connected to a switch S6, which is connected to DAC1, and a switch S5, which is connected to PA1 I/O. The inverting input (-) is connected to a switch SanB, which is connected to PA2 I/O(-) via switch S4, and a switch S3, which is connected to PA3 I/O. A direct channel FCH3 is also connected to the inverting input. The output of OPAMP1 is connected to an ADC Switch matrix. The diagram is labeled MS18924V2.

Figure 69. OPAMP1 signal routing diagram

The routing for the three operational amplifiers can be selected by OPAMP_CSR register.

Analog switches S3 to S6 and SanA can be opened and closed by programming the corresponding OPAMP_CSR register bits independently of whether the amplifiers are enabled or not by the OPA1_PD, OPA2_PD and/or OPA3_PD bits.

Analog switch SanB automatically follows the selection of the S3 or S4 switches. It is not controlled individually.

For OPAMP1, S6 is used to connect DAC_Channel1 to its positive input.

For OPAMP2, there is an additional S7 switch in parallel with S6 in order to select the positive input source as either I/O or DAC_Channel1 or DAC_Channel2.

For OPAMP3, S6 is used to connect DAC_Channel2 to its positive input.

All operational amplifiers can be powered down by setting the OPAx_PD bit. The corresponding inputs and outputs are then in high impedance.

Figure 70. OPAMP2 signal routing

Figure 70. OPAMP2 signal routing diagram

The diagram illustrates the signal routing for OPAMP2. The non-inverting input (+) is connected to a switch S7, which is connected to DAC_Channel2, a switch S6, which is connected to DAC_Channel1, and a switch S5, which is connected to PA6 I/O. The inverting input (-) is connected to a switch SanB, which is connected to PA7 I/O(-) via switch S4, and a switch S3, which is connected to PB0 I/O. A direct channel FCH8 is also connected to the inverting input. The output of OPAMP2 is connected to an ADC Switch matrix. The diagram is labeled MS18953V3.

Figure 70. OPAMP2 signal routing diagram

Figure 71. OPAMP3 signal routing (Cat.4 devices only)

Figure 71. OPAMP3 signal routing (Cat.4 devices only). The diagram shows the internal signal routing for OPAMP3. On the left, several input sources are connected via switches (S3, S4, S5, S6) to the non-inverting (+) and inverting (-) inputs of OPAMP3. The non-inverting input (+) can be connected to DAC2 (via S6), PC1 I/O (via S5), or SanA (via SanB). The inverting input (-) can be connected to PC2 I/O(-) (via S4) or PC3 I/O (via S3). A re-routed channel RCH13 is also connected to the inverting input. The output of OPAMP3 is connected to an ADC switch matrix via COMP1_SW1 and VCOMP. A comparator COMP1 is shown with its non-inverting input connected to VREFINT and its inverting input connected to the output of OPAMP3. The diagram is labeled MS18952V1.
Figure 71. OPAMP3 signal routing (Cat.4 devices only). The diagram shows the internal signal routing for OPAMP3. On the left, several input sources are connected via switches (S3, S4, S5, S6) to the non-inverting (+) and inverting (-) inputs of OPAMP3. The non-inverting input (+) can be connected to DAC2 (via S6), PC1 I/O (via S5), or SanA (via SanB). The inverting input (-) can be connected to PC2 I/O(-) (via S4) or PC3 I/O (via S3). A re-routed channel RCH13 is also connected to the inverting input. The output of OPAMP3 is connected to an ADC switch matrix via COMP1_SW1 and VCOMP. A comparator COMP1 is shown with its non-inverting input connected to VREFINT and its inverting input connected to the output of OPAMP3. The diagram is labeled MS18952V1.

15.3.2 Using the OPAMP outputs as ADC inputs

In order to use OPAMP outputs as ADC inputs, the operational amplifiers must be enabled and the ADC must use the OPAMP output channel number. (OPA1: CH3 ; OPA2: CH8 ; OPA3: CH13).

In addition for OPA3 or FCH13, the user must close COMP1_SW1 analog switch to do an acquisition (refer to Section 14.9.1: COMP comparator control and status register (COMP_CSR) on page 340 ).

15.3.3 Calibration

At startup, the trimming values are initialized with the preset 'factory' trimming value.

Furthermore each operational amplifier offset can be trimmed by the user. All switches related to the inputs of each operational amplifier must be open during the trimming operation (SanA, S3, S4, S5, S6).

There are two registers for trimming the offsets of the 3 operational amplifiers for normal mode and low-power mode. Two words of 30-bits, one for standard mode and the other for low-power mode are available in OPAMP_OTR and OPAMP_LPOTR registers. This is the 'user' value.

The user is able to switch from 'factory' values to 'user' trimmed values using the OT_USER bit in the OPAMP_OTR register. This bit is reset at startup to send 'factory' value to the OPAMPs. It is common to the 3 OPAMPs.

The offset of each operational amplifier can be trimmed by programming the OPAMP offset trimming register for normal mode (OPAMP_OTR) . The trimming values are stored in non-volatile memory.

The offset trimming register can be written, typically after a calibration operation initialized by the OPAx_CAL bits.

The 30 useful bits of OPA_OTR or OPA_LP_OTR are composed of three 10-bit words one for each operational amplifier. Each 10-bit is composed of 2 calibration values, the 5 lower bits are for trimming the offset of the PMOS differential pair. The 5 upper bits are for the NMOS ones.

After offset calibration is initialized by setting the control bit as shown in Table 72 , write the new trimming values in the OPAMP offset trimming register for normal mode (OPAMP_OTR) register value until the OPAxCALOUT flag toggles to indicate that the calibration has successfully completed.

Table 72. Operating modes and calibration

ModeControl bitsOutput
OPAxPDOPAxLPMOPAxCAL_HOPAxCAL_LV OUTCALout flag
Normal operating mode0000analog0
11
Low-power mode0100analog0
11
Power down1XXXZ0
Offset cal high0X10analogX
Offset cal low0X01analogX

Calibration procedure

Follow these steps to perform a full calibration of either one of the operational amplifiers:

  1. 1. Program the OPAMP_CSR register to open all the switches connected to the operational amplifier.
  2. 2. Set the OT_USER bit in the OPAMP_OTR register to 1.
  3. 3. Choose a calibration mode (refer to Table 72: Operating modes and calibration ). You can begin with:
    • • Normal mode, offset cal high
    To do this, set OPAxPD=0, OPAxLPM=0, OPAxCAL_H=1, OPAxCAL_L=0 in the OPAMP_CSR register.
  4. 4. The code in OPAMP_OTR[OPAxOPT_OFFSET_TRIM_High] is incremented from 00000b to the first value code that causes the OPAxCALOUT output level to change from 0 to 1.

Note: Between the write to the OPAMP_OTR register and the read of the OPAxCALOUT value, take care to wait for the \( t_{OFFTRIMmax} \) delay specified in the datasheet electrical characteristics section, to get the correct OPAxCALOUT value.

The commutation means that the offset is correctly compensated and the corresponding trim code must kept in the OPAMP_OTR register.

The value 11111b is forbidden for OPAMP_OTR[OPAxOPT_OFFSET_TRIM_High].

Repeat steps 3 to 4 for:

If a mode is not used its calibration serves no purpose.

Note: During the whole calibration phase the external connection of the operational amplifier output must not pull up or down currents higher than 500 \( \mu \) A.

15.4 OPAMP registers

15.4.1 OPAMP control/status register (OPAMP_CSR)

Address offset: 0x00

Reset value: 0x0001 0101

31302928272625242322212019181716
OPA3C
ALOUT
OPA2C
ALOUT
OPA1C
ALOUT
OPA_R
ANGE
S7SEL
2
ANAW
SEL3
ANAWS
EL2
ANAWS
EL1
OPA3L
PM
OPA3C
AL_H
OPA3C
AL_L
S6SEL
3
S5SEL
3
S4SEL
3
S3SEL
3
OPA3P
D
rrrrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
OPA2L
PM
OPA2C
AL_H
OPA2C
AL_L
S6SEL
2
S5SEL
2
S4SEL
2
S3SEL
2
OPA2P
D
OPA1L
PM
OPA1C
AL_H
OPA1C
AL_L
S6SEL
1
S5SEL
1
S4SEL
1
S3SEL
1
OPA1P
D
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
  1. Bit 31 OPA3CALOUT : OPAMP3 calibration output
    During calibration mode, the offset is trimmed when this signal toggles.
  2. Bit 30 OPA2CALOUT : OPAMP2 calibration output
    During calibration mode, the offset is trimmed when this signal toggles.
  3. Bit 29 OPA1CALOUT : OPAMP1 calibration output
    During calibration mode, the offset is trimmed when this signal toggles.
  4. Bit 28 OPA_RANGE : Power range selection
    This bit can be set and cleared by software when the operational amplifiers are in powered down. It select the operational amplifier power supply range for stability.
    0: Low range ( \( V_{DDA} < 2.4\text{ V} \) )
    1: High range ( \( V_{DDA} > 2.4\text{ V} \) )
  5. Bit 27 S7SEL2 : Switch 7 for OPAMP2 enable
    0: S7 opened
    1: S7 closed
  6. Bit 26 ANAWSEL3 : Switch SanA enable for OPAMP3
    0: SanA switch opened
    1: SanA switch closed
  7. Bit 25 ANAWSEL2 : Switch SanA enable for OPAMP2
    0: SanA switch opened
    1: SanA switch closed
  8. Bit 24 ANAWSEL1 : Switch SanA enable for OPAMP1
    0: SanA switch opened
    1: SanA switch closed
  9. Bit 23 OPA3LPM : OPAMP3 low-power mode
    0: OPAMP3 low-power mode off
    1: OPAMP3 low-power mode on
  10. Bit 22 OPA3CAL_H : OPAMP3 offset calibration for N differential pair
    0: OPAMP3 offset calibration for N diff OFF
    1: OPAMP3 offset calibration for N diff ON if OPA3CAL_L = 0
  11. Bit 21 OPA3CAL_L : OPAMP3 offset Calibration for P differential pair
    0: OPAMP3 offset calibration for P diff OFF
    1: OPAMP3 offset calibration for P diff ON if OPA3CAL_H = 0
  12. Bit 20 S6SEL3 : Switch 6 for OPAMP3 enable
    0: S6 switch opened
    1: S6 switch closed
  13. Bit 19 S5SEL3 : Switch 5 for OPAMP3 enable
    0: S5 switch opened
    1: S5 switch closed
  14. Bit 18 S4SEL3 : Switch 4 for OPAMP3 enable
    0: S4 switch opened
    1: S4 switch closed
  15. Bit 17 S3SEL3 : Switch 3 for OPAMP3 Enable
    0: S3 switch opened
    1: S3 switch closed
  1. Bit 16 OPA3PD : OPAMP3 power down
    0: OPAMP3 enabled
    1: OPAMP3 disabled
  2. Bit 15 OPA2LPM : OPAMP2 low-power mode
    0: OPAMP2 low-power mode off
    1: OPAMP2 low-power mode on
  3. Bit 14 OPA2CAL_H : OPAMP2 offset calibration for N differential pair
    0: OPAMP2 offset calibration for N diff OFF
    1: OPAMP2 offset calibration for N diff ON if OPA2CAL_L = 0
  4. Bit 13 OPA2CAL_L : OPAMP2 offset Calibration for P differential pair
    0: OPAMP2 offset calibration for P diff OFF
    1: OPAMP2 offset calibration for P diff ON if OPA2CAL_H = 0
  5. Bit 12 S6SEL2 : Switch 6 for OPAMP2 enable
    0: S6 switch opened
    1: S6 switch closed
  6. Bit 11 S5SEL2 : Switch 5 for OPAMP2 enable
    0: S5 switch opened
    1: S5 switch closed
  7. Bit 10 S4SEL2 : Switch 4 for OPAMP2 enable
    0: S4 switch opened
    1: S4 switch closed
  8. Bit 9 S3SEL2 : Switch 3 for OPAMP2 enable
    0: S3 switch opened
    1: S3 switch closed
  9. Bit 8 OPA2PD : OPAMP2 power down
    0: OPAMP2 enabled
    1: OPAMP2 disabled
  10. Bit 7 OPA1LPM : OPAMP1 low-power mode
    0: OPAMP1 low-power mode off
    1: OPAMP1 in low-power mode on
  11. Bit 6 OPA1CAL_H : OPAMP1 offset calibration for N differential pair
    0: OPAMP1 offset calibration for N diff OFF
    1: OPAMP1 offset calibration for N diff ON if OPA1CAL_L = 0
  12. Bit 5 OPA1CAL_L : OPAMP1 offset calibration for P differential pair
    0: OPAMP1 offset calibration for P diff OFF
    1: OPAMP1 offset calibration for P diff ON if OPA1CAL_H = 0
  13. Bit 4 S6SEL1 : Switch 6 for OPAMP1 enable
    0: S6 switch opened
    1: S6 switch closed
  14. Bit 3 S5SEL1 : Switch 5 for OPAMP1 enable
    0: S5 switch opened
    1: S5 switch closed

Bit 2 S4SEL1 : Switch 4 for OPAMP1 enable
0: S4 switch opened
1: S4 switch closed

Bit 1 S3SEL1 : Switch 3 for OPAMP1 enable
0: S3 switch opened
1: S3 switch closed

Bit 0 OPA1PD : OPAMP1 power down
0: OPAMP1 enabled
1: OPAMP1 disabled

15.4.2 OPAMP offset trimming register for normal mode (OPAMP_OTR)

Address offset: 0x04
Bit 31 reset value: 0
Bits 29:0 reset value: Factory trimmed value is restored.

31302928272625242322212019181716
OT_
USER
Res.OA3_OPT_OFFSET_TRIM_HIGHOA3_OPT_OFFSET_TRIM_LOWOA2_OPT_OFFSET_TRIM_HIGH[4:1]
wrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
OA2_OPT_OFFSET_TRIM_HIGH[0]OA2_OPT_OFFSET_TRIM_LOWOA1_OPT_OFFSET_TRIM_HIGHOA1_OPT_OFFSET_TRIM_LOW
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 OT_USER Select user or factory trimming value
This bit is set and cleared by software, it is always read as 0. It is used to select if the OPAMPx offset is trimmed by the preset factory-programmed trimming values or the user programmed trimming value.
0: Trim the OPAMP offset using default factory values
1: Trim the OPAMP offset using user programmed values

Bit 30 Reserved, must be kept at reset value

15.4.3 OPAMP offset trimming register for low-power mode (OPAMP_LPOTR)

Address offset: 0x08

Bits 29:0 reset value: Factory trimmed value is restored.

31302928272625242322212019181716
ReservedOA3_OPT_OFFSET_TRIM_LP_HIGHOA3_OPT_OFFSET_TRIM_LP_LOWOA2_OPT_OFFSET_TRIM_LP_HIGH[4:1]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
OA2_OPT_OFFSET_TRIM_LP_HIGHOA2_OPT_OFFSET_TRIM_LP_LOWOA1_OPT_OFFSET_TRIM_LP_HIGHOA1_OPT_OFFSET_TRIM_LP_LOW
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:30 Reserved, must be kept at reset value

Bit 29:25 OA3_OPT_OFFSET_TRIM_LP_HIGH[4:0] : OPAMP3, low-power mode 5-bit offset trim value for NMOS pairs

Bit 24:20 OA3_OPT_OFFSET_TRIM_LP_LOW[4:0] : OPAMP3, low-power mode 5-bit offset trim value for PMOS pairs

Bit 19:15 OA2_OPT_OFFSET_TRIM_LP_HIGH[4:0] : OPAMP2, low-power mode 5-bit offset trim value for NMOS pairs

Bit 14:10 OA2_OPT_OFFSET_TRIM_LP_LOW[4:0] : OPAMP2, low-power mode 5-bit offset trim value for PMOS pairs

Bit 9:5 OA1_OPT_OFFSET_TRIM_LP_HIGH[4:0] : OPAMP1, low-power mode 5-bit offset trim value for NMOS pairs

Bit 4:0 OA1_OPT_OFFSET_TRIM_LP_LOW[4:0] : OPAMP1, low-power mode 5-bit offset trim value for PMOS pairs

15.4.4 OPAMP register map

Table 73. OPAMP register map

OffsetRegister name313029282726252423222120191817161514131211109876543210
OPA3CALOUTOPA2CALOUTOPA1CALOUTOPA_RANGES7SEL2ANAWSEL3ANAWSEL2ANAWSEL1OPA3LPMOPA3CAL_HOPA3CAL_LS6SEL3S5SEL3S4SEL3S3SEL3OPA3PDOPA2LPMOPA2CAL_HOPA2CAL_LS6SEL2S5SEL2S4SEL2S3SEL2OPA2PDOPA1LPMOPA1CAL_HOPA1CAL_LS6SEL1S5SEL1S4SEL1S3SEL1OPA1PD
0x00OPAMP_CSR_
0x04OPAMP_OTR_OT_USERReservedOA3_OPT_OFFSET_TRIM_HIGHOA3_OPT_OFFSET_TRIM_LOWOA2_OPT_OFFSET_TRIM_HIGHOA2_OPT_OFFSET_TRIM_LOWOA1_OPT_OFFSET_TRIM_HIGHOA1_OPT_OFFSET_TRIM_LOW
0x08OPAMP_LPOTR_ReservedOA3_OPT_OFFSET_TRIM_LP_HIGHOA3_OPT_OFFSET_TRIM_LP_LOWOA2_OPT_OFFSET_TRIM_LP_HIGHOA2_OPT_OFFSET_TRIM_LP_LOWOA1_OPT_OFFSET_TRIM_LP_HIGHOA1_OPT_OFFSET_TRIM_LP_LOW

Refer to Table 5 on page 47 for the Register boundary addresses table.