33. Analog-to-digital converter (ADC12)

STM32U535/545/575/585 devices embed one analog-to-digital converter (ADC1) while STM32U59x/5Ax/5Fx/5Gx devices embed two analog-to-digital converters (ADC1 and ADC2), controlled by a single interface ADC12.

33.1 ADC introduction

This section describes the implementation of the 14-bit ADC successive approximation analog-to-digital converter.

ADC1 and ADC2 are tightly coupled and can operate in dual mode (ADC1 is a master).

The ADC features up to 20 multiplexed channels. Channel A/D conversion can be performed in single, continuous, scan, or discontinuous mode. The result of the ADC can be stored in a left-aligned or right-aligned 32-bit data register.

The ADC is mapped on the AHB bus to enable fast data handling.

In addition, the analog watchdog features enable the application to detect if the input voltage goes outside user-defined high or low thresholds.

The ADC features a built-in hardware oversampler that improves analog performances while off-loading the related computational burden from the CPU.

An efficient low-power mode is also implemented to achieve very low consumption at low frequency.

33.2 ADC main features

Figure 221 shows the block diagram of one ADC.

33.3 ADC implementation

The tables below describe the ADC implementation on STM32U5 series devices. It also includes ADC4 for comparison.

Table 301. ADC features (1)

ADC modes/featuresSTM32U535/545/
575/585
STM32U59x/5Ax/
5Fx/5Gx
STM32U535/545/575/585/
59x/5Ax/5Fx/5Gx
ADC1ADC1ADC2ADC4
Resolution14 bits12 bits
Maximum sampling speed for maximum resolution2.5 Msps2.75 Msps
Hardware offset calibrationXX
Hardware linearity calibrationX-
Extended calibration modeX (2)X-
Single-ended inputsXX
Differential inputsX-
Injected channel conversionX-
Oversamplingup to x1024up to x256
Data register32 bits16 bits
DMA supportXX
Parallel data output to MDFX-
Dual mode-X-
Autonomous mode-X
Offset compensationX-
Gain compensationX-
Number of analog watchdogs33
Wake-up from Stop mode-X (3)
  1. Note: 'X' = supported, '-' = not supported.
  2. For STM32U575/585, the extended calibration mode is not supported on device revision X.
  3. Wake-up supported from Stop 0, Stop 1 and Stop 2 modes.

Table 302. Memory location of the temperature sensor calibration values

NameDescriptionMemory address
TS_CAL1Temperature sensor 14-bit raw data acquired by ADC1 at 30 °C (± 5 °C), \( V_{DDA} = V_{REF+} = 3.0\text{ V} \) (±10 mV)0x0BFA 0710 - 0x0BFA 0711
TS_CAL2Temperature sensor 14-bit raw data acquired by ADC1 at 130 °C (± 5 °C), \( V_{DDA} = V_{REF+} = 3.0\text{ V} \) (±10 mV)0x0BFA 0742 - 0x0BFA 0743
Table 303. Memory location of the internal reference voltage sensor calibration value
NameDescriptionMemory address
VREFINT_CAL14-bit raw data acquired by ADC1 at 30 °C ( \( \pm 5 \) °C), \( V_{DDA} = V_{REF+} = 3.0 \) V ( \( \pm 10 \) mV)0x0BFA 07A5 - 0x0BFA 07A6

33.4 ADC functional description

33.4.1 ADC block diagram

Figure 221 shows the ADC block diagram and Table 304 gives the ADC pin description.

Figure 221. ADC block diagram

Detailed block diagram of the ADC12 functional description. The diagram shows the internal architecture of the ADC, including the SAR ADC core, input selection, triggers, calibration, and watchdog functions. Key components include: Input selection & scan control with BOOST, JAUTO, JL[1:0], JSQx, L[3:0], SQx, CONT, and DIFSEL[19:0] settings; a SAR ADC core with V_IN input, BOOST, and SMPx[2:0] sampling time settings; a Bias & Ref section with DEEPPWD, ADVREGEN, REG, and VREF+ input; an Oversampler with RDATA[31:0], JDATA1[31:0], JDATA2[31:0], JDATA3[31:0], and JDATA4[31:0] outputs; an AHB interface with ADRDY, EOSMP, EOC, EOS, OVR, JEOC, JEOS, and AWDx signals; and an Analog watchdog section with AWD1, AWD2, and AWD3 comparators. External connections include ADCx_INI, adc_ext_trg0, adc_ext_trg1, adc_jext_trg0, and adc_jext_trg1. Internal signals include adc_it, adc_dma, adcx_dat[15:0], adc_ker_ck, and adc_hclk. The diagram is labeled MSV62467V4 at the bottom right.
Detailed block diagram of the ADC12 functional description. The diagram shows the internal architecture of the ADC, including the SAR ADC core, input selection, triggers, calibration, and watchdog functions. Key components include: Input selection & scan control with BOOST, JAUTO, JL[1:0], JSQx, L[3:0], SQx, CONT, and DIFSEL[19:0] settings; a SAR ADC core with V_IN input, BOOST, and SMPx[2:0] sampling time settings; a Bias & Ref section with DEEPPWD, ADVREGEN, REG, and VREF+ input; an Oversampler with RDATA[31:0], JDATA1[31:0], JDATA2[31:0], JDATA3[31:0], and JDATA4[31:0] outputs; an AHB interface with ADRDY, EOSMP, EOC, EOS, OVR, JEOC, JEOS, and AWDx signals; and an Analog watchdog section with AWD1, AWD2, and AWD3 comparators. External connections include ADCx_INI, adc_ext_trg0, adc_ext_trg1, adc_jext_trg0, and adc_jext_trg1. Internal signals include adc_it, adc_dma, adcx_dat[15:0], adc_ker_ck, and adc_hclk. The diagram is labeled MSV62467V4 at the bottom right.

33.4.2 ADC pins and internal signals

Table 304. ADC input/output pins

NameSignal typeDescription
VREF+Input, analog reference positiveHigher/positive reference voltage for the ADC
VDDAInput, analog supplyAnalog power supply equal V DDA
VREF-Input, analog reference negativeLower/negative reference voltage for the ADC, V REF- = V SSA
VSSAInput, analog supply groundGround for analog power supply equal to V SS
ADCx_INyExternal analog input signalsUp to 17 external analog input channels

Table 305. ADC internal input/output signals

Internal signal nameSignal typeDescription
V INP [i]Analog inputsPositive input analog channels for each ADC
V INN [i]Analog inputsNegative input analog channels for each ADC
adc_ext_trgyInputsExternal trigger inputs for the regular conversions (can be connected to on-chip timers).
adc_jext_trgyInputsExternal trigger inputs for the injected conversions (can be connected to on-chip timers).
adc_awd1
adc_awd2
adc_awd3
OutputsInternal analog watchdog output signal connected to on-chip timers.
adc_itOutputADC interrupt
adc_hclkInputAHB clock
adc_ker_ckInputADC kernel clock
adc_dmaOutputADC DMA requests
adcx_dat[15:0]OutputADC data outputs (regular data register)

Table 306. ADC1/ADC12 interconnection

Signal nameSource/destination
ADCx V INP [0] (x = 1, 2)V REFINT buffered voltage
ADCx V INP [18] (x = 1, 2)V BAT /4
ADCx V INP [19] (x = 1, 2)V SENSE
adcx_dat[15:0] (x = 1, 2)mdf1_adcx_dat[15:0]

Table 307. ADC1/ADC12 external triggers for regular channels

NameSource
adc_ext_trg0tim1_oc1
adc_ext_trg1tim1_oc2
adc_ext_trg2tim1_oc3
adc_ext_trg3tim2_oc2
adc_ext_trg4tim3_trgo
adc_ext_trg5tim4_oc4
adc_ext_trg6exti11
adc_ext_trg7tim8_trgo
adc_ext_trg8tim8_trgo2
adc_ext_trg9tim1_trgo
adc_ext_trg10tim1_trgo2
adc_ext_trg11tim2_trgo
adc_ext_trg12tim4_trgo
adc_ext_trg13tim6_trgo
adc_ext_trg14tim15_trgo
adc_ext_trg15tim3_oc4
adc_ext_trg16exti15
adc_ext_trg18lptim1_ch1
adc_ext_trg19lptim2_ch1
adc_ext_trg20lptim3_ch1
adc_ext_trg21lptim4_out

Table 308. ADC1/ADC12 external triggers for injected channels

NameSource
adc_jext_trg0tim1_trgo
adc_jext_trg1tim1_oc4
adc_jext_trg2tim2_trgo
adc_jext_trg3tim2_oc1
adc_jext_trg4tim3_oc4
adc_jext_trg5tim4_trgo
adc_jext_trg6exti15
adc_jext_trg7tim8_oc4
adc_jext_trg8tim1_trgo2
adc_jext_trg9tim8_trgo
adc_jext_trg10tim8_trgo2
Table 308. ADC1/ADC12 external triggers for injected channels (continued)
NameSource
adc_jext_trg11tim3_oc3
adc_jext_trg12tim3_trgo
adc_jext_trg13tim3_oc1
adc_jext_trg14tim6_trgo
adc_jext_trg15tim15_trgo
adc_jext_trg18lptim1_ch2
adc_jext_trg19lptim2_ch2
adc_jext_trg20lptim3_ch1
adc_jext_trg21lptim4_out1

33.4.3 ADC clocks

Dual clock domain architecture

Dual clock-domain architecture means that the ADC kernel clock is independent from the AHB bus clock that is used to access ADC registers.

The adc_ker_ck input clock can be selected between different clock sources (see Figure 222: ADC clock scheme ). This selection is done in the RCC (refer to the RCC section for more information):

  1. 1. The ADC clock can be provided by an internal or external clock source, which is independent and asynchronous with the AHB clock.
  2. 2. The ADC clock can be derived from the AHB clock.

Option 1 has the advantage of achieving the maximum ADC clock frequency whatever the AHB clock scheme selected. The ADC clock can eventually be divided by a ratio of 1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128 or 256, using the prescaler configured through the PRESC[3:0] bits in the ADC12_CCR register.

Option 2 enables to bypass the clock domain resynchronizations. This can be useful when the ADC is triggered by a timer and the application requires that the ADC is accurately triggered without any uncertainty (otherwise, an uncertainty of the trigger instant is added by the resynchronizations between the two clock domains).

The clock is configured through the RCC. It must be compliant with the operating frequency specified in the device datasheet.

Figure 222. ADC clock scheme

Block diagram of the ADC clock scheme showing connections between RCC, ADC1 and ADC2 (AHB interface), a prescaler, and Analog ADC1, 2.

The diagram illustrates the clock architecture for the ADC. On the left, the RCC (Reset and clock controller) provides two clock signals: adc_hclk and adc_ker_ck . The adc_hclk signal is connected to the AHB interface within the ADC1 and ADC2 block. The adc_ker_ck signal is connected to a prescaler block labeled with values: /1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256 . This prescaler is controlled by the Bits PREC[3:0] of ADCCx_CCR . The output of the prescaler, labeled F_adc_ker_ck , is connected to the Analog ADC1, 2 block. The entire ADC section, including the AHB interface, prescaler, and analog ADCs, is contained within a larger block labeled ADC1 and ADC2 . A reference code MSV65324V2 is located in the bottom right corner of the diagram.

Block diagram of the ADC clock scheme showing connections between RCC, ADC1 and ADC2 (AHB interface), a prescaler, and Analog ADC1, 2.

1. Refer to the RCC section for information on adc_hclk and adc_ker_ck generation.

Clock ratio constraint between ADC clock and AHB clock

There are generally no constraints to be respected for the ratio between the ADC clock and the AHB clock. However, the ratio must be carefully chosen to avoid any overrun especially if the clock AHB is much slower than the ADC clock.

33.4.4 ADC connectivity

Figure 223. ADC1 connectivity

Schematic diagram of ADC1 connectivity showing 20 channels (IN0 to IN19) connected to a SAR ADC1 block. The diagram includes external input pins (ADC1_IN1 to IN17), internal signal sources (VREFINT, VSSA, VBAT/4, VSENSE), and a 'Channel selection' matrix. The SAR ADC1 block is shown with its reference voltage inputs (VREF+, VREF-, VINP, VINN).

The diagram illustrates the internal connectivity of the ADC12. On the left, external pins are labeled ADC1_IN1 through ADC1_IN17. These are connected to a central column of internal signal nodes. The nodes are organized into pairs for each channel index i: V INP [i] and V INN [i].

Additional internal signal sources are connected to the central column:

On the right, a 'Channel selection' matrix (indicated by a dashed vertical line) allows for the routing of these internal signals to the SAR ADC1 block. The SAR ADC1 block has inputs for V REF+ , V REF- , V INP , and V INN .

Schematic diagram of ADC1 connectivity showing 20 channels (IN0 to IN19) connected to a SAR ADC1 block. The diagram includes external input pins (ADC1_IN1 to IN17), internal signal sources (VREFINT, VSSA, VBAT/4, VSENSE), and a 'Channel selection' matrix. The SAR ADC1 block is shown with its reference voltage inputs (VREF+, VREF-, VINP, VINN).

MSv62469V6

  1. 1. V INN [i] signal can only be used when the corresponding ADC input channel is configured as differential mode.

Figure 224. ADC2 connectivity (STM32U59x/5Ax/5Fx/5Gx)

ADC2 connectivity diagram showing 20 channels (IN0 to IN19) connected to a SAR ADC2 block. The diagram includes external pins like ADC2_IN1 to ADC2_IN17, and internal connections to V_INP and V_INN pins of the ADC. Reference voltages V_REFINT (buffered), V_SSA, V_BAT/4, and V_SENSE are also shown.

The diagram illustrates the connectivity of the ADC2 module. On the left, external pins are labeled from ADC2_IN1 to ADC2_IN17. These are connected to a central column of ADC pins labeled V_INP[0] through V_INP[19] and V_INN[0] through V_INN[19]. The connections are as follows:

Additional pins V_SSA and V_REFINT (buffered) are also shown at the top and bottom of the central column. On the right, a block labeled 'SAR ADC2' receives V_INP and V_INN signals. It is connected to V_REF+ and V_REF- reference voltages. A 'Channel selection' block is shown above the SAR ADC2 block, with lines connecting it to the V_INP and V_INN pins.

ADC2 connectivity diagram showing 20 channels (IN0 to IN19) connected to a SAR ADC2 block. The diagram includes external pins like ADC2_IN1 to ADC2_IN17, and internal connections to V_INP and V_INN pins of the ADC. Reference voltages V_REFINT (buffered), V_SSA, V_BAT/4, and V_SENSE are also shown.

MSv65309V4

33.4.5 Slave AHB interface

The ADC implements an AHB slave port for control/status register and data access. The features of the AHB interface are listed below:

The AHB slave interface does not support split/retry requests and never generates AHB errors.

33.4.6 ADC Deep-power-down mode (DEEPPWD) and ADC voltage regulator (ADVREGEN)

By default, the ADC is in Deep-power-down mode where its supply voltage is internally switched off to reduce the leakage currents (the reset state of bit DEEPPWD is 1 in the ADC_CR register).

To start ADC operations, follow the sequence below:

  1. 1. First exit Deep-power-down mode by clearing the DEEPPWD bit.
  2. 2. Then, enable the ADC internal voltage regulator by setting the ADVREGEN bit in the ADC_CR register. The software must wait for the startup time of the ADC voltage regulator ( \( T_{ADCVREG\_STUP} \) ) before launching a calibration or enabling the ADC. This can be done by software by polling the LDORDY bit of the ADC_ISR register.

After ADC operations are complete, the ADC can be disabled (ADEN = 0). It is possible to save power by also disabling the ADC voltage regulator. This is done by clearing the ADVREGEN bit. Power consumption can be further reduced by reducing the leakage currents. In addition, it is possible to enter again in ADC Deep-power-down mode by setting DEEPPWD bit in ADC_CR register. This is particularly interesting before entering Stop mode.

Note: Setting DEEPPWD automatically disables the ADC voltage regulator and the ADVREGEN bit is automatically cleared.

When the internal voltage regulator is disabled (ADVREGEN = 0), the internal analog calibration factor is kept.

In ADC Deep-power-down mode (DEEPPWD = 1), the internal analog calibration is lost and it is necessary either to relaunch a calibration or apply again the calibration factor, which was previously saved (refer to Section 33.4.8: Calibration (ADCAL, ADCALLIN, ADC_CALFACT) ).

33.4.7 Single-ended and differential input channels

ADC channels can be configured either as single-ended input or as differential input. This is done by writing DIFSEL[19:0] bits in the ADC_DIFSEL register. This configuration must be performed while the ADC is disabled (ADEN = 0).

In single-ended input mode, the analog voltage to be converted for channel “i” is the difference between the external voltage \( V_{INP}[i] \) (positive input) and \( V_{REF-} \) (negative input).

In differential input mode, the analog voltage to be converted for channel “i” is the difference between the external voltage \( V_{INP}[i] \) (positive input) and \( V_{INN}[i] \) (negative input).

The output data in differential mode is an unsigned data:

\[ \text{Converted value} = \frac{\text{ADC\_Full\_Scale}}{2} \times \left[ 1 + \frac{V_{INP} - V_{INN}}{V_{REF+}} \right] \]

When ADC is configured as differential mode, both inputs must be biased at \( V_{REF+} / 2 \) voltage.

For a complete description of how the input channels are connected, refer to Section 33.4.4: ADC connectivity

Caution: When channel “i” is configured in differential input mode, its negative input voltage is connected to \( V_{INN}[i-1] \) .

33.4.8 Calibration (ADCAL, ADCALLIN, ADC_CALFACT)

The ADC provides an automatic calibration procedure that controls the whole calibration sequence including the ADC power-on/off. During the procedure, the ADC calculates an offset calibration factor for single-ended and differential mode. This factor includes the internal offset and the linearity that are applied internally to the ADC until the next ADC power-off. During the calibration procedure, the application must not use the ADC and must wait until the calibration is complete.

The calibration is a prerequisite to any ADC operation. It removes the systematic errors that may vary from chip to chip and enables to compensate offset and linearity deviation.

The offset calibration is the same for single-ended or differential channels.

The linearity correction must be done only once, regardless of single / differential configuration:

The calibration is then initiated by software by setting the ADCAL bit. The calibration can only be initiated when the ADC is disabled (ADEN = 0). ADCAL bit remains at 1 during all the calibration sequence. It is cleared by hardware as soon the calibration completes. At this time, the associated calibration factor is stored internally in the analog ADC.

The internal analog calibration is kept if the ADC is disabled (ADEN = 0). However, if the ADC is disabled for extended periods of time, the temperature changes, or the reference voltage is modified of more than 10%, it is recommended that a new offset calibration cycle is run before enabling the ADC again.

The internal analog calibration is lost each time the ADC power is switched off (for example, when the device enters Standby or \( V_{BAT} \) mode). In this case, to avoid spending time recalibrating the ADC, the calibration factor can be written again to the ADC analog block without recalibrating, assuming that the software has previously saved the calibration factor generated during the previous calibration.

The calibration factor can be written if the ADC is enabled and no calibration is ongoing (ADEN = 1 and ADSTART = 0 and JADSTART = 0). Then, at the next start of conversion, the calibration factor is injected into the analog ADC.

Refer to the device datasheet for the offset and linearity calibration time requirements.

Software procedure to calibrate the ADC

  1. 1. Make sure DEEPPWD = 0, ADVREGEN = 1 and check that the ADC voltage regulator startup time has elapsed (LDORDY = 1).
  2. 2. Make sure ADEN = 0.
  3. 3. Either enable the linearity calibration (ADCALLIN = 1) or disable it (ADCALLIN = 0).
  4. 4. Make sure CAPTURE_COEF and LATCH_COEF in ADC_CALFACT are cleared.
  5. 5. Set ADCAL in the ADC_CR register and wait until ADCAL = 0.

Figure 225 shows the ADC calibration timing diagram.

Note: The software can launch the calibration only when ADEN = 0, LDORDY = 1 (ADC disabled and LDO ready), and DUAL[4:0] = 0b00000.

Single-ended and differential channels cannot be calibrated separately. The offset calibration is performed within the same sequence.

Figure 225. ADC calibration

Timing diagram for ADC calibration showing the relationship between ADCALLIN, ADCAL, ADC State, and Internal calibration factor.

The diagram illustrates the timing sequence for ADC calibration across four horizontal timelines:

A horizontal double-headed arrow labeled \( t_{CAB} \) indicates the time interval between the rising edge of ADCALLIN and the falling edge of ADCAL. A legend at the bottom indicates that transitions marked with an upward arrow are "by S/W" and those with a rightward arrow are "by H/W". The text "Indicative timings" is also present. The diagram is identified by the code MSV62470V3.

Timing diagram for ADC calibration showing the relationship between ADCALLIN, ADCAL, ADC State, and Internal calibration factor.

Reading calibration factor procedure

Once the calibration is complete (ADCAL bit cleared by hardware), the calibration factor can be read from the ADC_CALFACT2 register. The CALINDEX[0:3] bitfield of the ADC_CR register can be incremented to access other calibration factors:

  1. 1. Make sure DEEPPWD = 0, ADVREGEN = 1, and check that the ADC voltage regulator startup time has elapsed (LDORDY = 1).
  2. 2. Make sure that ADEN = 1.
  3. 3. Set CAPTURE_COEF and clear LATCH_COEF in the ADC_CALFACT register.
  4. 4. Select the calibration factor by setting CALINDEX[0:3] in ADC control register (ADC_CR) .
  5. 5. Read the calibration factor from the ADC_CALFACT2 register.
  6. 6. Repeat steps 4 and 5 for each required calibration factor.
  7. 7. Clear the CAPTURE_COEF bit in the ADC_CALFACT register.

Note: The software can access the calibration factor only when ADEN = 1, ADSTART = 0 and JADSTART = 0 (ADC enabled and no conversion is ongoing).

Software procedure to reinject the calibration factor into the ADC

  1. 1. Make sure ADEN = 1, ADSTART = 0 and JADSTART = 0 (ADC enabled and no conversion is ongoing).
  2. 2. Clear the CAPTURE_COEF and LATCH_COEF bits in the ADC_CALFACT register
  3. 3. Set CALINDEX[3:0] to the targeted calibration index to be updated, then write the calibration factor to CALFACT[31:0] in the ADC_CALFACT2 register.
  4. 4. Repeat step 3 for all the calibration index bytes.
  5. 5. Set the LATCH_COEF bit in the ADC_CALFACT register.
  6. 6. Clear the LATCH_COEF bit in the ADC_CALFACT register.

Note: The software is allowed to update the calibration factor only when ADEN = 1 and ADSTART = 0 and JADSTART = 0 (ADC enabled and no conversion is ongoing).

If some of the calibration factor bytes are not written when the LATCH_COEF bit is set, the calibration factor becomes the default value.

Calibration factor index

The calibration factors are stored in the analog block in an indexed way. Index 0b0000 and 0b1000 contain the offset calibration factor while index 0b0001 to 0b0110 contain the linearity factor. The lower two bytes of index 0b0111 contain the linearity calibration factor. The internal offset calibration factor must be programmed into byte 2 of index (0b0111). However, it is read at byte 3 of index 0b1000. When programming or reinjecting the calibration factor, make sure to use the correct indexes for read and write operations.

Refer to Table 309 for a summary.

Table 309. Calibration factor index

CALINDEX[3:0]
values
Calibration factorReset value
Byte location
Byte 3Byte 2Byte 1Byte 0
0b0000Differential offsetSingle-end offset0x036D 0648
0b0001Linearity factor 10x0004 0000
0b0010Linearity factor 20x0000 0200
0b0011Linearity factor 30x0080 0001
0b0100Linearity factor 40x2000 4000
0b0101Linearity factor 50x09EB 13D6
0b0110Linearity factor 60x027A 04F5
0b0111 (read)ReservedReservedLinearity factor 70x8000 016A
0b0111 (write)ReservedInternal offset
0b1000 (read)Internal offsetReservedReservedReserved0x8C02 7A00
0b1001ReservedCalibration modeReservedReserved0x3000 1100
0b1000 (write)ReservedReservedReservedReserved-
Other valuesReserved-

When the calibration factor is latched, all the index bytes must be uploaded, otherwise the non-uploaded index bytes are reset to their default value.

Extended calibration mode

To enhance the ADC performance, the extended calibration mode is implemented on some product versions (see Section 33.3: ADC implementation ).

Below the procedure to enable the extended calibration mode:

  1. 1. Make sure that DEEPPWD = 0 and ADVREGEN = 1, and check that the ADC voltage regulator startup time has elapsed (LDORDY = 1).
  2. 2. Set ADCALLIN in the ADC_CR register.
  3. 3. Make sure CAPTURE_COEF and LATCH_COEF of ADC_CALFACT are cleared.
  4. 4. Set ADEN and wait until ADRDY is set.
  5. 5. Set CALINDEX[3:0] = 0b1001, then write CALFACT[31:0] = 0x0302 1100 in the ADC_CALFACT2 register.
  6. 6. Set the LATCH_COEF bit in the ADC_CALFACT register.
  7. 7. Set the ADDIS and wait until the ADEN bit is cleared.
  8. 8. Set the ADCAL in the ADC_CR register and wait until ADCAL bit is cleared.

Note: Once the calibration is complete, the value of CALFACT[31:0] at CALINDEX[3:0] = 0b1001 is reset.

The values written to the ADC_CR (CALINDEX[3:0] and ADCALLIN), ADC_CALFACT, and ADC_CALFACT2 registers are internally applied asynchronously from \( F_{adc\_ker\_ck} \) . As a result, consecutive fast accesses to these registers might generate errors. To prevent errors

from occurring, the software can insert the __DMB(); command after each access to these registers.

To run the calibration, set DUAL[4:0] = 0b00000.

33.4.9 ADC on-off control (ADEN, ADDIS, ADRDY)

First of all, follow the procedure described in Section 33.4.6: ADC Deep-power-down mode (DEEPPWD) and ADC voltage regulator (ADVREGEN) .

Once the DEEPPWD bit is cleared and the ADVREGEN bit is set, the ADC can be enabled. It requires a stabilization time of \( t_{STAB} \) before staring converting accurately (see Figure 226 ). Two control bits enable or disable the ADC:

ADEN and ADDIS bits are automatically cleared by hardware as soon as the analog ADC is effectively disabled.

Regular conversions can then start either by setting ADSTART (refer to Section 33.4.19: Conversion on external trigger and trigger polarity (EXTSEL, EXTEN[1:0], JEXTSEL, JEXTEN[1:0]) ) or when an external trigger event occurs if triggers are enabled.

Injected conversions start by setting JADSTART or when an external injected trigger event occurs if injected triggers are enabled.

Software procedure to enable the ADC

  1. 1. Clear the ADRDY bit in the ADC_ISR register by writing 1.
  2. 2. Set ADEN = 1.
  3. 3. Wait until ADRDY = 1 (ADRDY is set after the ADC startup time). This can be done by using the associated interrupt (ADRDYIE = 1).
  4. 4. Clear the ADRDY bit in the ADC_ISR register by writing 1 (optional).

Software procedure to disable the ADC

  1. 1. Check that both ADSTART = 0 and JADSTART = 0 to make sure that no conversion is ongoing. If required, stop any ongoing regular and injected conversion by setting ADSTP = 1 and JADSTP = 1 and then wait until ADSTP = 0 and JADSTP = 0.
  2. 2. Set ADDIS.
  3. 3. If required by the application, wait until ADEN = 0, until the analog ADC is effectively disabled (ADDIS is automatically reset once ADEN = 0).

Figure 226. Enabling/disabling the ADC

Timing diagram showing the sequence of events for enabling and disabling the ADC. The diagram plots four signals over time: ADEN, ADRDY, ADDIS, and ADC state. 1. Initial state: ADEN is high, ADRDY is high, ADDIS is low, and ADC state is OFF. 2. Disabling: ADEN is cleared (low) by software (S/W). ADRDY goes low after a stabilization time t_STAB. ADDIS goes high. ADC state transitions from OFF to Startup, then RDY, then Converting CH, then RDY, then REQ-OF, and finally OFF. 3. Enabling: ADEN is set (high) by hardware (H/W). ADRDY goes high. ADDIS goes low. ADC state transitions from OFF to Startup, then RDY. Legend: 'by S/W' with an upward arrow for setting, 'by H/W' with a downward arrow for clearing.
Timing diagram showing the sequence of events for enabling and disabling the ADC. The diagram plots four signals over time: ADEN, ADRDY, ADDIS, and ADC state. 1. Initial state: ADEN is high, ADRDY is high, ADDIS is low, and ADC state is OFF. 2. Disabling: ADEN is cleared (low) by software (S/W). ADRDY goes low after a stabilization time t_STAB. ADDIS goes high. ADC state transitions from OFF to Startup, then RDY, then Converting CH, then RDY, then REQ-OF, and finally OFF. 3. Enabling: ADEN is set (high) by hardware (H/W). ADRDY goes high. ADDIS goes low. ADC state transitions from OFF to Startup, then RDY. Legend: 'by S/W' with an upward arrow for setting, 'by H/W' with a downward arrow for clearing.

MSv62472V1

33.4.10 Constraints when writing the ADC control bits

The software can program the RCC control bits to configure and enable the ADC clock (refer to the Reset and clock control section), the control DIFSEL bits in the ADC_DIFSEL register, the ADC12_CCR register and the ADCAL and ADEN control bits in the ADC_CR register, only if the ADC is disabled.

The software can program the ADCAL bit to launch the calibration when ADEN is cleared. It can read or update the calibration factor if ADEN is set and no conversion is ongoing (ADSTART and JADSTART both cleared).

The software is then allowed to write the ADSTART, JADSTART, and ADDIS control bits in the ADC_CR register only if the ADC is enabled and there is no pending request to disable it (ADEN must be equal to 1 and ADDIS to 0).

The following constraints apply to all the other control bits of the ADC_CFGRx, ADC_SMPRy, ADC_LTRy, ADC_HTRy, ADC_SQRY, ADC_OFRy and ADC_IER registers:

The software can write ADSTP or JADSTP control bits in the ADC_CR register only if the ADC is enabled, a conversion is ongoing and there is no pending request to disable it (ADSTART or JADSTART must be equal to 1 and ADDIS to 0).

Note: There is no hardware protection to prevent these forbidden write accesses that may cause the ADC to enter an unknown state. To recover from this situation, the ADC must be disabled (clear ADEN as well as all the bits of the ADC_CR register).

33.4.11 Channel selection (SQRx, JSQRx)

The ADC features up to 20 multiplexed channels per ADC:

Refer to Table ADC interconnection in Section 33.4.2: ADC pins and internal signals for the connection of the above internal analog inputs to external ADC pins or internal signals.

The conversions can be organized in two groups: regular and injected. A group consists of a sequence of conversions that can be done on any channel and in any order. For instance, it is possible to implement the conversion sequence in the following order: ADC_IN3, ADC_IN8, ADC_IN2, ADC_IN2, ADC_IN0, ADC_IN2, ADC_IN2, ADC_IN15.

ADC_SQRy registers must not be modified while regular conversions are ongoing. To modify ADC_SQRy registers, the ADC regular conversions must first be stopped by setting ADSTP (refer to Section 33.4.18: Stopping an ongoing conversion (ADSTP, JADSTP) ).

Note: To convert one of the internal analog channels, the corresponding analog sources must first be enabled by programming VBATEN, VSENSESEL, or VREFEN bits in the ADC12_CCR registers.

33.4.12 Channel preselection register (ADC_PCSEL)

For each channel selected through SQRx or JSQRx bits, the corresponding ADC_PCSEL bit must be configured in advance.

This ADC_PCSEL bit controls the analog switch integrated in the I/O level. The ADC input multiplexer selects the ADC input according to SQRx and JSQRx configuration with very high speed and the analog switch integrated in the I/O cannot react as fast as the ADC multiplexer does. To avoid the delay due to on analog switch control on the I/O, it is necessary to preselect the input channels that are selected through the SQRx and JSQRx. The selection is based on the \( V_{\text{INP}}[i] \) of each ADC input. For example, if the ADC converts ADC_IN1, the PCSEL1 bit must also be set in ADC_PCSEL.

33.4.13 Channel-wise programmable sampling time (SMPR1, SMPR2)

Before starting a conversion, the ADC must establish a direct connection between the voltage source under measurement and the embedded sampling capacitor of the ADC. This sampling time must be enough for the input voltage source to charge the embedded capacitor to the input voltage level.

Each channel can be sampled with a different sampling time that is programmable using the SMP[2:0] bits in the ADC_SMPR1 and ADC_SMPR2 registers. It is therefore possible to select among the following sampling time values:

The total conversion time is calculated as follows:

\[ T_{\text{CONV}} = \text{Sampling time} + \text{Conversion time} \]

Example

When converting a single data, the sampling time is five cycles and the conversion time is 17 cycles for 14-bit mode. With an \( F_{\text{adc\_ker\_ck}} \) of 55 MHz:

\[ T_{\text{CONV}} = (5 + 17) \text{ ADC clock cycles} = 22 \text{ ADC clock cycles} = 0.40 \mu\text{s} \]

The above result assumes that \( R_{\text{AIN}} \ll 1 \text{ K}\Omega \) (refer to the datasheet for additional sampling time to be added depending on the external resistance).

The ADC notifies the end of the sampling phase by setting the status bit EOSMP (only for regular conversion).

I/O analog switch voltage booster

The resistance of the I/O analog switches increases when the \( V_{\text{DDA}} \) voltage is too low. The sampling time must consequently be adapted accordingly (refer to the device datasheet for the corresponding electrical characteristics). This resistance can be minimized at low \( V_{\text{DDA}} \) voltage by enabling an internal voltage booster (refer to the SYSCFG section for more details).

Bulb sampling mode

When the BULB bit is set in the ADC_CFGR2 register, the sampling period starts immediately after the last ADC conversion. A hardware or software trigger starts the conversion after the sampling time has been programmed in the ADC_SMPR1 register. The very first ADC conversion, after the ADC is enabled, is performed with the sampling time programmed in SMP bits. The bulb mode is effective starting from the second conversion.

The maximum sampling time is limited (refer to the ADC characteristics section of the datasheet).

The bulb mode may not be used in continuous conversion mode or with injected channel conversion.

When the BULB bit is set, it is not allowed to set the SMPTRIG bit in ADC_CFGR2.

When conversions in bulb mode are stopped by setting ADSTP bit or when the DMA transfers are complete, the ADC must be disabled by setting ADDIS bit.

Figure 227. Bulb mode timing diagram

Timing diagram for ADC12 Bulb mode. It shows two sections: 'Normal mode (discontinuous sampling)' and 'BULB mode (continuous sampling)'. In normal mode, the ADC state cycles through idle, sample, and conversion. In bulb mode, after the first conversion, it goes back to sample. The sampling time is controlled by the trigger signal and programmed in SMP bits.

The figure is a timing diagram for the ADC12 Bulb mode. It is divided into two horizontal sections. The top section, 'Normal mode (discontinuous sampling)', shows the 'ADC state' as a sequence of 'idle', 'sample', and 'conversion' periods. The 'Trigger' signal is shown as a series of pulses. The bottom section, 'BULB mode (continuous sampling)', shows the 'ADC state' as 'idle', 'sample', 'conversion', 'sample', 'conversion', and 'sample'. The 'Trigger' signal is shown as a pulse that starts the sampling period and a falling edge that ends it. A double-headed arrow indicates the 'Sampling time programmed in SMP bits' between the rising and falling edges of the trigger signal. The diagram is labeled 'MSV62473V1' in the bottom right corner.

Timing diagram for ADC12 Bulb mode. It shows two sections: 'Normal mode (discontinuous sampling)' and 'BULB mode (continuous sampling)'. In normal mode, the ADC state cycles through idle, sample, and conversion. In bulb mode, after the first conversion, it goes back to sample. The sampling time is controlled by the trigger signal and programmed in SMP bits.

Sampling time control trigger mode

When the SMPTRIG bit is set, the sampling time programmed through SMPx bits is not applicable. The sampling time is controlled by the trigger signal edge.

When a hardware trigger is selected, each rising edge of the trigger signal starts the sampling period. A falling edge ends the sampling period and starts the conversion.

When a software trigger is selected, the software trigger is not the ADSTART bit in ADC_CR but the SWTRIG bit. SWTRIG bit has to be set to start the sampling period, and the SWTRIG bit has to be cleared to end the sampling period and start the conversion.

The maximum sampling time is limited (refer to the ADC characteristics section of the datasheet).

This mode is not compatible with the continuous conversion mode and injected channel conversion.

When the SMPTRIG bit is set, it is not allowed to set the BULB bit.

33.4.14 Single conversion mode (CONT = 0)

In single conversion mode, the ADC performs once the conversions of all channels. This mode is started with the CONT bit at 0 by either:

Inside the regular sequence, after each conversion is complete:

Inside the injected sequence, after each conversion is complete:

After the regular sequence is complete:

After the injected sequence is complete:

Then the ADC stops until a new external regular or injected trigger occurs or until bit ADSTART or JADSTART is set again.

Note: To convert a single channel, program a sequence with a length of 1.

33.4.15 Continuous conversion mode (CONT = 1)

This mode applies to regular channels only.

In continuous conversion mode, when a software or hardware regular trigger event occurs, the ADC performs once all the regular conversions of the channels and then automatically restarts and continuously converts each conversion of the sequence. This mode is started with the CONT bit at 1 either by an external trigger or by setting the ADSTART bit in the ADC_CR register.

Inside the regular sequence, after each conversion is complete:

After the sequence of conversions is complete:

Then, a new sequence restarts immediately and the ADC continuously repeats the conversion sequence.

Note: To convert a single channel, program a sequence with a length of 1.

It is not possible to have both discontinuous mode and continuous mode enabled: it is forbidden to set both DISCEN = 1 and CONT = 1.

Injected channels cannot be converted continuously. The only exception is when an injected channel is configured to be converted automatically after regular channels in continuous mode (using the JAUTO bit), refer to Section : Auto-injection mode ).

33.4.16 Starting conversions (ADSTART, JADSTART)

The software starts ADC regular conversions by setting ADSTART. When ADSTART is set, the conversion starts:

The software starts ADC injected conversions by setting JADSTART. When JADSTART is set, the conversion starts:

Note: In auto-injection mode (JAUTO = 1), use the ADSTART bit to start regular conversions followed by auto-injected conversions (JADSTART must be kept cleared).

ADSTART and JADSTART also provide information on whether any ADC operation is ongoing. The ADC can be reconfigured while ADSTART and JADSTART are both cleared (the ADC is idle).

ADSTART is cleared by hardware:

Note: In continuous mode (CONT = 1), ADSTART is not cleared by hardware with the assertion of EOS because the sequence is automatically relaunched.

When a hardware trigger is selected in single mode (CONT = 0 and EXTEN[1:0] ≠ 0x0), ADSTART is not cleared by hardware with the assertion of EOS to help the software that does not need to reset ADSTART again for the next hardware trigger event. This ensures that no further hardware triggers are missed.

JADSTART is cleared by hardware:

Note: When the software trigger is selected, the ADSTART bit must not be set if the EOC flag is still high.

33.4.17 Timing

The elapsed time between the start of a conversion and the end of conversion is the sum of the configured sampling time plus the successive approximation time depending on data resolution for single conversion and minus the overlap time between the sampling and the previous SAR for continuous conversion.

In single conversion mode:

\[ T_{\text{CONV}} = T_{\text{SMPL}} + T_{\text{SAR}} = [5_{\min} + 17_{\text{14bits}}] \times T_{\text{adc\_ker\_ck}} \]

\[ T_{\text{CONV}} = T_{\text{SMPL}} + T_{\text{SAR}} = 22 \times T_{\text{adc\_ker\_ck min for 14bits}} = 400.0 \text{ ns (for } F_{\text{adc\_ker\_ck}} = 55 \text{ MHz)} \]

Figure 228. Analog-to-digital conversion time in single conversion

Timing diagram for single conversion mode showing ADC state, Analog channel, Internal S/H, ADSTART, EOSMP, EOC, and ADC_DR signals over time. The diagram illustrates the sequence of events: RDY state, Sampling Ch(N) with t_SMPL(1), Converting Ch(N) with t_SAR(2), and Sampling Ch(N+1). The ADC_DR register updates from Data N-1 to Data N at the end of the conversion.

The diagram shows the timing of signals during a single conversion. The ADC state starts at RDY, then goes to Sampling Ch(N) for a duration of \( t_{\text{SMPL}}^{(1)} \) , then to Converting Ch(N) for a duration of \( t_{\text{SAR}}^{(2)} \) , and finally to Sampling Ch(N+1). The Analog channel is Ch(N) during sampling and conversion, and Ch(N+1) during the next sampling. The Internal S/H is Sample AIN(N) during sampling and Hold AIN(N) during conversion, then Sample AIN(N+1) during the next sampling. ADSTART is set by SW at the beginning of sampling. EOSMP is set by HW at the end of sampling and cleared by SW at the end of conversion. EOC is set by HW at the end of conversion and cleared by HW/SW. ADC_DR contains Data N-1 during conversion and Data N after conversion. Indicative timings are shown for \( t_{\text{SMPL}}^{(1)} \) and \( t_{\text{SAR}}^{(2)} \) . MSV30532V2

Timing diagram for single conversion mode showing ADC state, Analog channel, Internal S/H, ADSTART, EOSMP, EOC, and ADC_DR signals over time. The diagram illustrates the sequence of events: RDY state, Sampling Ch(N) with t_SMPL(1), Converting Ch(N) with t_SAR(2), and Sampling Ch(N+1). The ADC_DR register updates from Data N-1 to Data N at the end of the conversion.

1. \( t_{\text{SMPL}} \) depends on SMP[2:0].

2. \( t_{\text{SAR}} \) depends on RES[1:0].

33.4.18 Stopping an ongoing conversion (ADSTP, JADSTP)

The software can decide to stop regular conversions ongoing by setting ADSTP, and injected conversions ongoing by setting JADSTP.

Stopping conversions resets the ongoing ADC operation. The ADC can then be reconfigured (for example by changing the channel selection or the trigger). It is then ready for a new operation.

Injected conversions can be stopped while regular conversions are still ongoing and vice versa. This enables, for instance, to reconfigure the injected conversion sequence and triggers while regular conversions are still ongoing (and vice versa).

When the ADSTP bit is set by software, any ongoing regular conversion is aborted with partial result discarded (ADC_DR register is not updated with the current conversion).

When the JADSTP bit is set by software, any ongoing injected conversion is aborted with partial result discarded (ADC_JDRy register is not updated with the current conversion). The scan sequence is also aborted and reset (meaning that relaunching the ADC would restart a new sequence).

Once this procedure is complete, ADSTP/ADSTART bits (in case of regular conversion), or JADSTP/JADSTART bits (in case of injected conversion) are cleared by hardware. The software must poll ADSTART (or JADSTART) until the bit is reset before assuming the ADC is completely stopped.

Note: In auto-injection mode (JAUTO = 1), setting the ADSTP bit aborts both regular and injected conversions (JADSTP must not be used).

Figure 229. Stopping ongoing regular conversions

Timing diagram for stopping ongoing regular conversions. It shows the ADC state (RDY, Sample Ch(N-1), Convert Ch(N-1), RDY, Sample Ch(N), C, RDY) triggered by external signals. The ADSTART bit is set by software to start regular conversions and is cleared by hardware when the ADC returns to RDY. The ADSTP bit is set by software to stop conversions and is also cleared by hardware. Data from previous conversions (Data N-2, Data N-1) are shown in the ADC_DR register.

This timing diagram illustrates the sequence of events for stopping ongoing regular conversions. The top line shows the ADC state transitioning from RDY to Sample Ch(N-1) upon a Trigger, then to Convert Ch(N-1), back to RDY, then to Sample Ch(N) upon another Trigger, then to C, and finally back to RDY. The ADSTART bit is set by software (SW) to initiate regular conversions and is cleared by hardware (HW) when the ADC returns to the RDY state. A note indicates that software cannot configure regular conversion selection and triggers. The ADSTP bit is set by software to stop conversions and is cleared by hardware. The ADC_DR register contains Data N-2 and Data N-1.

Timing diagram for stopping ongoing regular conversions. It shows the ADC state (RDY, Sample Ch(N-1), Convert Ch(N-1), RDY, Sample Ch(N), C, RDY) triggered by external signals. The ADSTART bit is set by software to start regular conversions and is cleared by hardware when the ADC returns to RDY. The ADSTP bit is set by software to stop conversions and is also cleared by hardware. Data from previous conversions (Data N-2, Data N-1) are shown in the ADC_DR register.

MSV62490V1

Figure 230. Stopping ongoing regular and injected conversions

Timing diagram for stopping ongoing regular and injected conversions. It shows the ADC state (RDY, Sample Ch(N-1), Convert Ch(N-1), RDY, Sample Ch(M), C, RDY, Sample, RDY) triggered by Regular, Injected, and Regular triggers. The JADSTART bit is set by software to start injected conversions and is cleared by hardware. The JADSTP bit is set by software to stop injected conversions and is cleared by hardware. The ADSTART bit is set by software to start regular conversions and is cleared by hardware. The ADSTP bit is set by software to stop regular conversions and is cleared by hardware. Data from previous conversions (DATA M-1, DATA N-2, DATA N-1) are shown in the ADC_JDR and ADC_DR registers.

This timing diagram shows the sequence of events for stopping ongoing regular and injected conversions. The ADC state transitions are triggered by Regular, Injected, and Regular triggers. The JADSTART bit is set by software to start injected conversions and is cleared by hardware. A note indicates that software cannot configure injected conversion selection and triggers. The JADSTP bit is set by software to stop injected conversions and is cleared by hardware. The ADSTART bit is set by software to start regular conversions and is cleared by hardware. A note indicates that software cannot configure regular conversion selection and triggers. The ADSTP bit is set by software to stop regular conversions and is cleared by hardware. The ADC_JDR register contains DATA M-1, and the ADC_DR register contains DATA N-2 and DATA N-1.

Timing diagram for stopping ongoing regular and injected conversions. It shows the ADC state (RDY, Sample Ch(N-1), Convert Ch(N-1), RDY, Sample Ch(M), C, RDY, Sample, RDY) triggered by Regular, Injected, and Regular triggers. The JADSTART bit is set by software to start injected conversions and is cleared by hardware. The JADSTP bit is set by software to stop injected conversions and is cleared by hardware. The ADSTART bit is set by software to start regular conversions and is cleared by hardware. The ADSTP bit is set by software to stop regular conversions and is cleared by hardware. Data from previous conversions (DATA M-1, DATA N-2, DATA N-1) are shown in the ADC_JDR and ADC_DR registers.

MS30534V1

33.4.19 Conversion on external trigger and trigger polarity (EXTSEL, EXTEN[1:0], JEXTSEL, JEXTEN[1:0])

A conversion or a sequence of conversions can be triggered either by software or by an external event (for example, timer capture, input pins). If the EXTEN[1:0] control bits (for a regular conversion) or JEXTEN[1:0] bits (for an injected conversion) are different from 00, then external events are able to trigger a conversion with the selected polarity.

The regular trigger selection is effective once software has set bit ADSTART = 1 and the injected trigger selection is effective once software has set bit JADSTART = 1.

Any hardware trigger which occurs while a conversion is ongoing are ignored.

Table 310 provides the correspondence between the EXTEN[1:0] and JEXTEN[1:0] values and the trigger polarity.

Table 310. Configuring the trigger polarity for regular external triggers

EXTEN[1:0]Source
00Hardware Trigger detection disabled, software trigger detection enabled
01Hardware Trigger with detection on the rising edge
10Hardware Trigger with detection on the falling edge
11Hardware Trigger with detection on both the rising and falling edges

Note: The polarity of the regular trigger cannot be changed on-the-fly.

Table 311. Configuring the trigger polarity for injected external triggers

JEXTEN[1:0]Source
00Hardware trigger detection disabled, software trigger detection enabled
01Hardware trigger with detection on the rising edge
10Hardware trigger with detection on the falling edge
11Hardware trigger with detection on both the rising and falling edges

The EXTSEL[4:0] and JEXTSEL[4:0] control bits select which events can trigger regular and injected groups conversion, out of 21 possibilities.

A regular group conversion can be interrupted by an injected trigger.

Note: The trigger selection cannot be changed on-the-fly.

Figure 231. Triggers are shared between ADC master and ADC slave

Schematic diagram showing trigger connections between ADC MASTER and ADC SLAVE. The diagram illustrates how external triggers (adc_ext0_trg, adc_ext1_trg, adc_ext31_trg) and JEXTI triggers (adc_jext0_trg, adc_jext1_trg, adc_jext31_trg) are shared between the master and slave ADC units. Each ADC unit has its own multiplexers for regular and injected triggers, controlled by EXTSEL[4:0] and JEXTSEL[4:0] registers. The diagram is labeled MSV41035V2.
Schematic diagram showing trigger connections between ADC MASTER and ADC SLAVE. The diagram illustrates how external triggers (adc_ext0_trg, adc_ext1_trg, adc_ext31_trg) and JEXTI triggers (adc_jext0_trg, adc_jext1_trg, adc_jext31_trg) are shared between the master and slave ADC units. Each ADC unit has its own multiplexers for regular and injected triggers, controlled by EXTSEL[4:0] and JEXTSEL[4:0] registers. The diagram is labeled MSV41035V2.

Refer to Table ADC external triggers for regular channels and Table ADC external triggers for injected channels in Section 33.4.2: ADC pins and internal signals for the connection of the above internal analog inputs to external ADC pins or internal signals.

33.4.20 Injected channel management

Triggered injection mode

To use triggered injection, the JAUTO bit must be cleared in the ADC_CFGR1 register:

  1. 1. Start the conversion of a group of regular channels either by an external trigger or by setting the ADSTART bit in the ADC_CR register.
  2. 2. If an external injected trigger occurs or if the JADSTART bit in the ADC_CR register is set during the conversion of a regular group of channels, the current conversion is reset and the injected channel sequence switches are launched (all the injected channels are converted once).
  3. 3. Then, the regular conversion of the regular group of channels is resumed from the last interrupted regular conversion.
  4. 4. If a regular event occurs during an injected conversion, the injected conversion is not interrupted but the regular sequence is executed at the end of the injected sequence. Figure 232 shows the corresponding timing diagram.

Note: When using triggered injection, one must ensure that the interval between trigger events is longer than the injection sequence. For instance, if the sequence length is 44 ADC clock cycles (that is two conversions with a minimum sampling time), the minimum interval between triggers must be 45 ADC clock cycles.

Auto-injection mode

If the JAUTO bit is set in the ADC_CFGR1 register, the channels in the injected group are automatically converted after the regular group of channels. This can be used to convert a sequence of up to 20 conversions programmed in the ADC_SQRy and ADC_JSQR registers.

In this mode, the ADSTART bit in the ADC_CR register must be set to start regular conversions, followed by injected conversions (JADSTART must be kept cleared). Setting the ADSTP bit aborts both regular and injected conversions (JADSTP bit must not be used).

In this mode, the external trigger on injected channels must be disabled.

If the CONT bit is also set in addition to the JAUTO bit, regular channels followed by injected channels are continuously converted.

Note: It is not possible to use both the auto-injected and discontinuous modes simultaneously.

When the DMA is used for exporting the regular sequencer's data in JAUTO mode, it is necessary to program it in circular mode (CIRC bit set in the DMA_CCRx register). If the CIRC bit is reset (single-shot mode), the JAUTO sequence is stopped upon a DMA Transfer Complete event.

Figure 232. Injected conversion latency

Timing diagram showing injected conversion latency. The diagram plots four signals over time: adc_ker_ck (ADC kernel clock), Injection event, Reset ADC, and SOC (Start of Conversion). The adc_ker_ck signal is a periodic square wave. The Injection event is a short pulse. The Reset ADC signal is a pulse that goes high after the injection event and then low. The SOC signal is a pulse that goes high when the Reset ADC signal goes low and then goes low when the adc_ker_ck signal goes high. A horizontal double-headed arrow labeled 'max. latency (1)' indicates the time interval between the rising edge of the adc_ker_ck signal and the rising edge of the SOC signal. The diagram is labeled MSv43771V1 in the bottom right corner.

The figure is a timing diagram illustrating the injected conversion latency. It shows four signal traces over time:

A horizontal double-headed arrow labeled "max. latency (1) " indicates the time interval between the rising edge of the adc_ker_ck signal and the rising edge of the SOC signal. The diagram is labeled MSv43771V1 in the bottom right corner.

Timing diagram showing injected conversion latency. The diagram plots four signals over time: adc_ker_ck (ADC kernel clock), Injection event, Reset ADC, and SOC (Start of Conversion). The adc_ker_ck signal is a periodic square wave. The Injection event is a short pulse. The Reset ADC signal is a pulse that goes high after the injection event and then low. The SOC signal is a pulse that goes high when the Reset ADC signal goes low and then goes low when the adc_ker_ck signal goes high. A horizontal double-headed arrow labeled 'max. latency (1)' indicates the time interval between the rising edge of the adc_ker_ck signal and the rising edge of the SOC signal. The diagram is labeled MSv43771V1 in the bottom right corner.
  1. 1. The maximum latency value can be found in the electrical characteristics of the device datasheet.

33.4.21 Discontinuous mode (DISCEN, DISCNUM, JDISCEN)

Regular group mode

This mode is enabled by setting the DISCEN bit in the ADC_CFGR1 register.

It is used to convert a short sequence (subgroup) of n conversions ( \( n \leq 8 \) ) that is part of the sequence of conversions selected in the ADC_SQRy registers. The value of n is specified by writing to the DISCNUM[2:0] bits in the ADC_CFGR1 register.

When an external trigger occurs, it starts the next n conversions selected in the ADC_SQRx registers until all the conversions in the sequence are done. The total sequence length is defined by the L[3:0] bits in the ADC_SQR1 register.

Example

Note: When a regular group is converted in discontinuous mode, no rollover occurs (the last subgroup of the sequence can have less than n conversions).

When all subgroups are converted, the next trigger starts the conversion of the first subgroup. In the example above, the 4th trigger reconverts the channels 1, 2 and 3 in the 1st subgroup.

It is not possible to have both discontinuous mode and continuous mode enabled. In this case (if DISCEN = 1, CONT = 1), the ADC behaves as if continuous mode was disabled.

Injected group mode

This mode is enabled by setting the JDISCEN bit in the ADC_CFGR1 register. It converts the sequence selected in the ADC_JSQR register, channel by channel, after an external injected trigger event. This is equivalent to discontinuous mode for regular channels where 'n' is fixed at 1.

When an external trigger occurs, it starts the next channel conversions selected in the ADC_JSQR registers until all the conversions in the sequence are done. The total sequence length is defined by the JL[1:0] bits in the ADC_JSQR register.

Example

Note: When all injected channels have been converted, the next trigger starts the conversion of the first injected channel. In the example above, the 4th trigger reconverts the 1st injected channel 1.

It is not possible to use both auto-injected mode and discontinuous mode simultaneously: the bits DISCEN and JDISCEN must be kept cleared by software when JAUTO is set.

33.4.22 Programmable resolution (RES) - fast conversion mode

It is possible to perform faster conversion by reducing the ADC resolution.

The resolution can be configured to be either 14, 12, 10, 8 bits by programming the control bits RES[1:0]. Figure 237 , Figure 238 , Figure 239 and Figure 240 show the conversion result format with respect to the resolution as well as to the data alignment (in continuous mode assuming no added extra sampling cycle for high input resistance).

Lower resolution enables faster conversion time for applications where high-data precision is not required. It reduces the conversion time spent by the successive approximation steps according to Table 312 .

Table 312. T SAR timings depending on resolution

REST SAR
(ADC clock cycles)
T SAR (ns) at
F adc_ker_ck =
55 MHz
T adc_ker_ck
(ADC clock cycles) with
Sampling time=5 ADC
clock cycles
T adc_ker_ck (ns)
at F adc_ker_ck =
55 MHz
1417 ADC clock cycles309.122 ADC clock cycles400.0
1215 ADC clock cycles272.720 ADC clock cycles363.6
1013 ADC clock cycles236.418 ADC clock cycles327.3
811 ADC clock cycles200.016 ADC clock cycles290.9

33.4.23 End of conversion and end of sampling phase (EOC, JEOC, EOSMP)

The ADC notifies the application for each end of regular conversion (EOC) event and each injected conversion (JEOC) event.

The ADC sets the EOC flag as soon as a new regular conversion data is available in the ADC_DR register. An interrupt can be generated if bit EOCIE is set. EOC flag is cleared by the software either by writing 1 to it or by reading ADC_DR.

The ADC sets the JEOC flag as soon as a new injected conversion data is available in one of the ADC_JDRy registers. An interrupt can be generated if bit JEOCIE is set. JEOC flag is cleared by the software either by writing 1 to it or by reading the corresponding ADC_JDRy register.

The ADC also notifies the end of Sampling phase by setting the status bit EOSMP (for regular conversions only). EOSMP flag is cleared by software by writing 1 to it. An interrupt can be generated if bit EOSMPIE is set.

33.4.24 End of conversion sequence (EOS, JEOS)

The ADC notifies the application for each end of regular sequence (EOS) and for each end of injected sequence (JEOS) event.

The ADC sets the EOS flag as soon as the last data of the regular conversion sequence is available in the ADC_DR register. An interrupt can be generated if bit EOSIE is set. EOS flag is cleared by the software either by writing 1 to it.

The ADC sets the JEOS flag as soon as the last data of the injected conversion sequence is complete. An interrupt can be generated if bit JEOSIE is set. JEOS flag is cleared by the software either by writing 1 to it.

33.4.25 Timing diagrams example (single/continuous modes, hardware/software triggers)

Figure 233. Single conversions of a sequence, software trigger

Timing diagram showing ADSTART, EOC, EOS, ADC state, and ADC_DR signals over time for single conversions of a sequence with a software trigger. The diagram shows two sequences of conversions for channels CH1, CH9, CH10, and CH17. The first sequence is triggered by a software (SW) rising edge, and the second by a hardware (HW) rising edge. The ADC state transitions from RDY to CH1, CH9, CH10, CH17, and back to RDY. The ADC_DR register shows the corresponding digital values D1, D9, D10, and D17. The EOC (End of Conversion) signal pulses for each conversion, and the EOS (End of Sequence) signal pulses after the last conversion of each sequence. A legend indicates 'by SW' with a green rising edge and 'by HW' with a black rising edge. A box labeled 'Indicative timings' is present. The code MS30549V1 is in the bottom right corner.
Timing diagram showing ADSTART, EOC, EOS, ADC state, and ADC_DR signals over time for single conversions of a sequence with a software trigger. The diagram shows two sequences of conversions for channels CH1, CH9, CH10, and CH17. The first sequence is triggered by a software (SW) rising edge, and the second by a hardware (HW) rising edge. The ADC state transitions from RDY to CH1, CH9, CH10, CH17, and back to RDY. The ADC_DR register shows the corresponding digital values D1, D9, D10, and D17. The EOC (End of Conversion) signal pulses for each conversion, and the EOS (End of Sequence) signal pulses after the last conversion of each sequence. A legend indicates 'by SW' with a green rising edge and 'by HW' with a black rising edge. A box labeled 'Indicative timings' is present. The code MS30549V1 is in the bottom right corner.
  1. 1. EXTEN[1:0] = 0x0, CONT = 0
  2. 2. Channels selected = 1,9, 10, 17; AUTDLY = 0.

Figure 234. Continuous conversion of a sequence, software trigger

Timing diagram for Figure 234: Continuous conversion of a sequence, software trigger. The diagram shows several signal lines: ADCSTART(1), EOC, EOS, ADSTP, ADC state(2), and ADC_DR. ADCSTART(1) shows a software trigger pulse. EOC (End of Conversion) pulses high at the end of each channel conversion. EOS (End of Sequence) pulses high after the last channel in the sequence (CH17) is converted. ADSTP (ADC Stop) is used to stop the continuous conversion. ADC state(2) transitions through READY, CH1, CH9, CH10, CH17, and then repeats the sequence until stopped. ADC_DR (ADC Data Register) shows the digital output values D1, D9, D10, D17 corresponding to the channels. A legend at the bottom indicates 'by SW' with a green upward arrow, 'by HW' with a black upward arrow, and 'Indicative timings'.

by SW ↑ by HW ↑ Indicative timings

MS30550V1

Timing diagram for Figure 234: Continuous conversion of a sequence, software trigger. The diagram shows several signal lines: ADCSTART(1), EOC, EOS, ADSTP, ADC state(2), and ADC_DR. ADCSTART(1) shows a software trigger pulse. EOC (End of Conversion) pulses high at the end of each channel conversion. EOS (End of Sequence) pulses high after the last channel in the sequence (CH17) is converted. ADSTP (ADC Stop) is used to stop the continuous conversion. ADC state(2) transitions through READY, CH1, CH9, CH10, CH17, and then repeats the sequence until stopped. ADC_DR (ADC Data Register) shows the digital output values D1, D9, D10, D17 corresponding to the channels. A legend at the bottom indicates 'by SW' with a green upward arrow, 'by HW' with a black upward arrow, and 'Indicative timings'.
  1. 1. EXTEN[1:0] = 0x0, CONT = 1
  2. 2. Channels selected = 1, 9, 10, 17; AUTDLY = 0.

Figure 235. Single conversions of a sequence, hardware trigger

Timing diagram for Figure 235: Single conversions of a sequence, hardware trigger. The diagram shows signal lines: ADSTART, EOC, EOS, TRGX(1), ADC state(2), and ADC_DR. ADSTART is a software start signal. TRGX(1) represents hardware trigger events. EOC pulses high after each channel conversion. EOS pulses high after the full sequence (CH1 to CH4) is complete. ADC state(2) shows the ADC moving from RDY to CH1, CH2, CH3, CH4, then back to READY. ADC_DR shows data values D1, D2, D3, D4. The diagram illustrates that hardware triggers occurring while the ADC is busy (converting CH1-CH4) are ignored (marked with an 'X'), while a trigger occurring when the ADC is in READY state starts a new sequence. A legend at the bottom indicates 'by s/w' with a green arrow, 'by h/w' with a black arrow, 'triggered' with a green arrow, 'ignored' with an 'X' mark, and 'Indicative timings'.

by s/w ↑ by h/w ↑ triggered ↑ ignored ✕ Indicative timings

MS31013V2

Timing diagram for Figure 235: Single conversions of a sequence, hardware trigger. The diagram shows signal lines: ADSTART, EOC, EOS, TRGX(1), ADC state(2), and ADC_DR. ADSTART is a software start signal. TRGX(1) represents hardware trigger events. EOC pulses high after each channel conversion. EOS pulses high after the full sequence (CH1 to CH4) is complete. ADC state(2) shows the ADC moving from RDY to CH1, CH2, CH3, CH4, then back to READY. ADC_DR shows data values D1, D2, D3, D4. The diagram illustrates that hardware triggers occurring while the ADC is busy (converting CH1-CH4) are ignored (marked with an 'X'), while a trigger occurring when the ADC is in READY state starts a new sequence. A legend at the bottom indicates 'by s/w' with a green arrow, 'by h/w' with a black arrow, 'triggered' with a green arrow, 'ignored' with an 'X' mark, and 'Indicative timings'.
  1. 1. TRGx (over-frequency) is selected as trigger source, EXTEN[1:0] = 01, CONT = 0
  2. 2. Channels selected = 1, 2, 3, 4; AUTDLY = 0.

Figure 236. Continuous conversions of a sequence, hardware trigger

Timing diagram for continuous conversions of a sequence with a hardware trigger. The diagram shows the relationship between ADSTART, EOC, EOS, ADSTP, TRGx, ADC, and ADC_DR signals. ADSTART is a software trigger. EOC (End of Conversion) pulses occur after each channel conversion. EOS (End of Sequence) pulses occur after the last channel in the sequence (CH4). ADSTP (Stop) is a software stop. TRGx is a hardware trigger that starts the sequence. ADC shows the sequence of conversions: RDY, CH1, CH2, CH3, CH4, CH1, CH2, CH3, CH4, CH1, STOP, RDY. ADC_DR shows the data output: D1, D2, D3, D4, D1, D2, D3, D4. A legend indicates: 'by s/w' (software), 'by h/w' (hardware), 'triggered' (triggered), 'ignored' (ignored), and 'Not in scale timings'.
Timing diagram for continuous conversions of a sequence with a hardware trigger. The diagram shows the relationship between ADSTART, EOC, EOS, ADSTP, TRGx, ADC, and ADC_DR signals. ADSTART is a software trigger. EOC (End of Conversion) pulses occur after each channel conversion. EOS (End of Sequence) pulses occur after the last channel in the sequence (CH4). ADSTP (Stop) is a software stop. TRGx is a hardware trigger that starts the sequence. ADC shows the sequence of conversions: RDY, CH1, CH2, CH3, CH4, CH1, CH2, CH3, CH4, CH1, STOP, RDY. ADC_DR shows the data output: D1, D2, D3, D4, D1, D2, D3, D4. A legend indicates: 'by s/w' (software), 'by h/w' (hardware), 'triggered' (triggered), 'ignored' (ignored), and 'Not in scale timings'.
  1. 1. TRGx is selected as trigger source, EXTEN[1:0] = 10, CONT = 1
  2. 2. Channels selected = 1, 2, 3, 4; AUTDLY = 0.

33.4.26 Data management

Data register, data alignment and offset (ADC_DR, ADC_JDRy, OFFSETy, OFFSETy_CH, OVSS, LSHIFT, USAT, SSAT)

Data and alignment

At the end of each regular conversion channel (when the EOC event occurs), the result of the converted data is stored into the ADC_DR data register which is 32 bits wide.

At the end of each injected conversion channel (when the JEOC event occurs), the result of the converted data is stored into the corresponding ADC_JDRy data register which is 32 bits wide.

The OVSS[3:0] and LSHIFT[3:0] bitfields in the ADC_CFGR2 register selects the alignment of the data stored after conversion. By default, data are right-aligned. Refer to Figure 237 , Figure 238 , Figure 239 and Figure 240 for examples of data alignment.

Note: The data can be realigned in normal and in oversampling mode.

Offset

An offset y (y = 1,2,3,4) can be applied to a channel by programming a value different from 0 in the OFFSETy[23:0] bitfield of the ADC_OFRy register. The channel to which the offset is applied is programmed into the bits OFFSETy_CH[4:0] of ADC_OFRy register. The offset can be positive or negative depending on the value of the POSOFF bit. When POSOFF is cleared, the converted value is subtracted by the user-defined offset written in OFFSETy[23:0] bits. The result can be a negative value. The read data is consequently signed and the SEXT bit represents the extended sign value.

The offset value must be lower than the maximum conversion value (for example, in 14-bit mode, the maximum offset value is 0x3FFF).

The offset can be used to convert unsigned data to signed data (for example, in 14-bit mode, the offset value is equal to 0x2000).

The offset correction is also supported in oversampling mode. For the oversampling mode, offset is subtracted before OVSS right shift applied.

Table 313 describes how the comparison is performed for all the possible resolutions for analog watchdog 1, 2, 3.

Table 313. Offset computation versus data resolution

Resolution
(bits
RES[1:0])
Subtraction/addition between
raw converted data and offset
ResultComments
Raw -
converted left
-aligned data
Offset
00: 14-bitDATA[13:0]OFFSET[13:0]Signed or unsigned
24-bit data, right
aligned to [13:0]
-
01: 12-bitDATA[13:2],00OFFSET[13:2]Signed or unsigned
24-bit data, right
aligned to [11:0]
The user must configure
OFFSET[11:0] to
0b0000 0000 0000.
10: 10-bitDATA[13:4],00
00
OFFSET[13:4]Signed or unsigned
24-bit data, right
aligned to [9:0]
The user must configure
OFFSET[3:0] to 0b0000.
11: 8-bitDATA[13:6],00
0000
OFFSET[13:6]Signed or unsigned
24-bit data, right
aligned to [7:0]
The user must configure
OFFSET[5:0] to 0b000000.

Figure 237, Figure 238, Figure 239 and Figure 240 show alignments for signed and unsigned data together with corresponding OVSS and LSHIFT values.

Figure 237. Right alignment (offset disabled, unsigned value)

Diagram showing right alignment of unsigned data for various resolutions (14-bit, 12-bit, 8-bit) and oversampling settings (OSR=1024).

The diagram illustrates the right alignment of unsigned data for different resolutions and oversampling settings. It shows the mapping of data bits (Dn..D0) into a 32-bit register, with bit positions 31, 15, 13, 7, and 0 marked at the top.

MSv62491V1

Diagram showing right alignment of unsigned data for various resolutions (14-bit, 12-bit, 8-bit) and oversampling settings (OSR=1024).

Figure 238. Right alignment (offset enabled, signed value)

Diagram showing right alignment of ADC data for various bit widths (14-bit, 12-bit, 8-bit) with sign extension (SEXT) and specific bit positions (31, 15, 13, 11, 7, 0).

The diagram illustrates the right alignment of ADC data for different bit widths. Each row shows a 32-bit register structure with bit positions 31, 15, 13, 11, 7, and 0 marked. The data is right-aligned, meaning the least significant bit (D0) is always at position 0.

MSv62492V1

Diagram showing right alignment of ADC data for various bit widths (14-bit, 12-bit, 8-bit) with sign extension (SEXT) and specific bit positions (31, 15, 13, 11, 7, 0).

Figure 239. Left alignment (offset disabled, unsigned value)

Diagram showing left alignment of ADC data for various bit widths (14-bit, 12-bit, 8-bit) with specific bit positions (31, 23, 15, 7, 1, 0) and LSHIFT values.

The diagram illustrates the left alignment of ADC data for different bit widths. Each row shows a 32-bit register structure with bit positions 31, 23, 15, 7, 1, and 0 marked. The data is left-aligned, meaning the most significant bit is at position 31.

MSv62493V1

Diagram showing left alignment of ADC data for various bit widths (14-bit, 12-bit, 8-bit) with specific bit positions (31, 23, 15, 7, 1, 0) and LSHIFT values.

Figure 240. Left alignment (offset enabled, signed value)

Figure 240. Left alignment (offset enabled, signed value). Diagram showing various data formats for 14-bit, 12-bit, and 8-bit data with left alignment and signed values. It includes bit positions (31, 15, 0, 3, 7, 23) and shift/offset settings (LSHIFT, SSAT).

The diagram illustrates the internal 32-bit register format for different ADC resolutions with left alignment and signed values. Bit positions 31, 15, 0, 3, 7, and 23 are marked at the top. The formats are as follows:

MSv62492V1

Figure 240. Left alignment (offset enabled, signed value). Diagram showing various data formats for 14-bit, 12-bit, and 8-bit data with left alignment and signed values. It includes bit positions (31, 15, 0, 3, 7, 23) and shift/offset settings (LSHIFT, SSAT).

Management of signed and unsigned saturation format (SSAT, USAT)

The offset correction might result in the data width to be wider than the original data.

To limit the original width, the data saturation can be enabled through the SSAT and USAT bits of the ADC_OFRy register.

Unsigned 14-bit data can be extended to 15-bit signed data by using an offset value different from 0x2000.

The original data width can be preserved by setting the SSAT bit to limit the data width to 14 bits.

Unsigned data can be saturated to the original data width by setting the USAT bit.

Table 314 shows the sign-extended data format corresponding to different resolutions.

Table 314. 14-bit data formats

SSATUSATFormatData range (offset = 0x2000)
00Sign-extended 15-bit significant data:
SEXT[31:14]
DATA[13:0]
0x0000 1FFF - 0xFFFF E000
10Sign-extended 14-bit significant data:
SEXT[31:13]
DATA[12:0]
0x1FFF - 0xE000

Table 314. 14-bit data formats (continued)

SSATUSATFormatData range (offset = 0x2000)
01Unsigned saturation14-bit significant data: DATA[13:0]0x3FFF - 0x0000
11Reserved-

Table 315 provides numerical examples for three different offset values.

Table 315. Numerical examples for 16-bit format

Raw conversion resultOffset valueResultResultResult
SSAT = 0
USAT = 0
SSAT = 0
USAT = 1
SSAT = 1
USAT = 0
0x3FFF0x20000x0000 1FFF1FFF1FFF
0x20000x0000 000000000000
0x00000xFFFF E000E000E000
0x3FFF0x20200x0000 1FDF1FDF1FDF
0x20000xFFFF FFE00000FFE0
0x00000xFFFF DFE00000DFE0
0x3FFF0x1FE00x0000 201F201F1FFF
0x20000x0000 002000200020
0x00000xFFFF E0200000E020
0x3FFF0x200x0000 3FDF3FDF3FDF
0x20000x0000 1FE01FE01FE0
0x00000xFFFF FFE00000FFE0

Caution: SSAT must not be used in conjunction with USAT. No hardware check is performed to ensure that this recommendation is respected.

Gain compensation

When the GCOMP bit is set in the ADC_CFGR2 register, the gain compensation is activated on all converted data. After each conversion, data is calculated using the following formula.

\[ DATA = DATA(adc\ result) \times (GCOMPCOEFF) / 4096 \]

As GCOMPCOEFF can be programmed from 0 to 16383, the actual gain compensation factor can range from 0 to 3.999756.

Before storing the resulting data in the RDATA or JDATAx registers, the LSB+1 value is evaluated to round up the data and minimize the error.

The gain compensation is also effective for the oversampling. When the gain compensation is used for the oversampling mode, the gain calculation is performed after the accumulation and right-shift operations to minimize the power consumption (the gain calculation is done

only once instead of at each conversion). The internal multiplier width is 32 bits and the input data width for the gain compensation must be less than 18 bits. When using oversampling with injected and regular conversion mode the bit ADC_CFGR2.ROVSM bit must be set to resume the pending conversion with the correct value.

ADC overrun (OVRMOD)

The overrun flag (OVR) notifies of that a buffer overrun event occurred when the regular converted data has not been read (by the CPU or the DMA) before ADC_DR FIFO (eight stages) is overflowed.

The OVR flag is set when a new conversion completes while the ADC_CR register FIFO was full. An interrupt is generated if the OVRIE bit is set.

When an overrun event occurs, the ADC is still operating and can continue converting unless the software decides to stop and reset the sequence by setting the ADSTP bit.

OVR flag is cleared by software by writing 1 to it.

Data can be configured to be preserved or overwritten when an overrun event occurs by programming the OVRMOD control bit of the ADC_CFGR1 register:

Figure 241. Example of overrun (OVRMOD = 0)

Timing diagram for Figure 241 showing an overrun condition when OVRMOD = 0. The diagram illustrates the relationship between ADSTART, EOC, OVR, ADSTP, TRGx, ADC state, ADC_DR read access, and ADC_DR (FIFO_DATA) signals. It shows that when a new conversion starts before the previous one is read, data is lost in the FIFO.

This timing diagram illustrates an overrun condition when OVRMOD = 0. The signals shown are:

Legend:
by s/w (software)
by h/w (hardware)
triggered
Indicative timings

MSv69549V1

Timing diagram for Figure 241 showing an overrun condition when OVRMOD = 0. The diagram illustrates the relationship between ADSTART, EOC, OVR, ADSTP, TRGx, ADC state, ADC_DR read access, and ADC_DR (FIFO_DATA) signals. It shows that when a new conversion starts before the previous one is read, data is lost in the FIFO.

Figure 242. Example of overrun (OVRMOD = 1)

Timing diagram for Figure 242 showing an overrun condition when OVRMOD = 1. The diagram illustrates the relationship between ADSTART, EOC, OVR, ADSTP, TRGx, ADC state, ADC_DR read access, and ADC_DR (OVRMOD = 1) signals. It shows that when OVRMOD = 1, the overrun flag is set but data is not lost in the dedicated injected channel registers.

This timing diagram illustrates an overrun condition when OVRMOD = 1. The signals shown are:

Legend:
by s/w (software)
by h/w (hardware)
triggered
Indicative timings

MSv65301V1

Timing diagram for Figure 242 showing an overrun condition when OVRMOD = 1. The diagram illustrates the relationship between ADSTART, EOC, OVR, ADSTP, TRGx, ADC state, ADC_DR read access, and ADC_DR (OVRMOD = 1) signals. It shows that when OVRMOD = 1, the overrun flag is set but data is not lost in the dedicated injected channel registers.

Note: There is no overrun detection on the injected channels since there is a dedicated data register for each of the four injected channels.

Managing a sequence of conversions without using the DMA

If the conversions are slow enough, the conversion sequence can be handled by the software. In this case, the software must use the EOC flag and its associated interrupt to handle each data. Each time a conversion is complete, EOC is set and the ADC_DR register can be read. OVRMOD must be configured to 0 to manage overrun events as an error.

Managing conversions without using the DMA and without overrun

It may be useful to let the ADC convert one or more channels without reading the data each time (for example if the device features an analog watchdog). In this case, the OVRMOD bit must be configured to 1 and the OVR flag must be ignored by the software. An overrun event does not prevent the ADC from continuing to convert and the ADC_DR register always contains the latest conversion.

Managing conversions using the DMA

Since converted channel values are stored in a unique data register, it is useful to use DMA to convert more than one channel. This avoids the loss of the data already stored in the ADC_DR register.

When the DMA mode is enabled (DMNGT[1:0] = 01 or 11 in the ADC_CFGR register in single ADC mode or DAMDF different from 00 in dual ADC mode), a DMA request is generated after each conversion of a channel. This allows the transfer of the converted data from the ADC_DR register to the destination location selected by the software.

Despite this, if an overrun occurs (OVR = 1) because the DMA cannot serve the DMA transfer request in time, the ADC stops generating DMA requests and the data corresponding to the new conversion is not transferred by the DMA. This means that all the data transferred to the RAM can be considered as valid.

Depending on the configuration of the OVRMOD bit, the data is either preserved or overwritten.

The DMA transfer requests are blocked until the software clears the OVR bit.

Two different DMA modes are proposed depending on the application. They can be configured through the DMNGT[1:0] bitfield of the ADC_CFGR1 register and the DAMDF bit of the ADC12_CCR register, in single ADC mode and in dual ADC mode, respectively:

DMA one shot mode (DMNGT[1:0] = 01)

In this mode, the ADC generates a DMA transfer request each time a new conversion data is available and stops generating DMA requests once the DMA has reached the last DMA transfer (when a transfer complete interrupt occurs - refer to DMA section) even if a conversion has been started again.

When the DMA transfer is complete (all the transfers configured in the DMA controller have been done):

DMA circular mode (DMNGT[1:0] = 11)

In this mode, the ADC generates a DMA transfer request each time a new conversion data is available in the data register, even if the DMA has reached the last DMA transfer. This allows configuring the DMA in circular mode to handle a continuous analog input data stream.

DMA with FIFO

The output data register features an eight-stage FIFO. Two different DMA requests are generated in parallel. When a data is available, an “SREQ single request” is generated. When four data are available, a “BREQ burst request” is generated. DMA can be programmed either single transfer mode or incremental burst mode (four beats), according to this mode, correct request line is selected by the DMA. Refer to the DMA chapter for further information.

33.4.27 Managing conversions using the MDF

The ADC conversion results can be transferred directly to the MDF.

In this case, the DMNGT[1:0] bits must be set to 10.

The ADC transfers the 16 least significant bits of the regular data register to the MDF through adcx_dat[15:0] bus, which in turn resets the EOC flag once the transfer is effective.

The data format must be in 16-bit signed format:

ADC_DR[31:16] = don't care

ADC_DR[15] = sign

ADC_DR[14:0] = data

Any value above 16-bit signed format is truncated.

33.4.28 Dynamic low-power features

Auto-delayed conversion mode (AUTDLY)

The ADC implements an auto-delayed conversion mode controlled by the AUTDLY configuration bit. Auto-delayed conversions are useful to simplify the software as well as to optimize performance of an application clocked at low frequency where there would be risk of encountering an ADC overrun.

When AUTDLY = 1 , a new conversion can start only if all the previous data of the same group has been treated:

The auto-delayed conversion mode enables to automatically adapt the speed of the ADC to the speed of the system which reads the data.

The delay is inserted after each regular conversion (whatever DISCEN = 0 or 1) and after each sequence of injected conversions (whatever JDISCEN = 0 or 1).

Note: There is no delay inserted between each conversion of the injected sequence, except after the last one.

During a conversion, a hardware trigger event (for the same group of conversions) occurring during this delay is ignored.

Note: This is not true for software triggers where it remains possible during this delay to set the bits ADSTART or JADSTART to restart a conversion: it is up to the software to read the data before launching a new conversion.

No delay is inserted between conversions of different groups (a regular conversion followed by an injected conversion or conversely):

The behavior is slightly different in auto-injected mode (JAUTO = 1) where a new regular conversion can start only when the automatic delay of the previous injected sequence of conversion has ended (when JEOS has been cleared). This is to ensure that the software can read all the data of a given sequence before starting a new sequence (see Figure 247 ).

To stop a conversion in continuous auto-injection mode combined with auto-delay mode (JAUTO = 1, CONT = 1 and AUTDLY = 1), follow the following procedure:

  1. 1. Wait until JEOS = 1 (no more conversions are restarted).
  2. 2. Clear JEOS.
  3. 3. Set ADSTP = 1.
  4. 4. Read the regular data.

If this procedure is not respected, a new regular sequence can restart if JEOS is cleared after ADSTP has been set.

In AUTDLY mode, a hardware regular trigger event is ignored if it occurs during an already ongoing regular sequence or during the delay that follows the last regular conversion of the sequence. It is however considered pending if it occurs after this delay, even if it occurs during an injected sequence or during the delay that follows it. The conversion then starts at the end of the delay of the injected sequence.

In AUTDLY mode, a hardware injected trigger event is ignored if it occurs during an already ongoing injected sequence or during the delay that follows the last injected conversion of the sequence.

Figure 243. AUTDLY = 1, regular conversion in continuous mode, software trigger

Timing diagram for Figure 243 showing ADC state transitions (RDY, CH1, DLY, CH2, DLY, CH3, DLY, CH1, DLY, STOP, RDY) and data output (D1, D2, D3, D1) over time. It includes signals for ADSTART(1), EOC, EOS, ADSTP, and ADC_DR read access. A legend indicates 'by SW' for software trigger and 'by HW' for hardware trigger. MS31020V1
Timing diagram for Figure 243 showing ADC state transitions (RDY, CH1, DLY, CH2, DLY, CH3, DLY, CH1, DLY, STOP, RDY) and data output (D1, D2, D3, D1) over time. It includes signals for ADSTART(1), EOC, EOS, ADSTP, and ADC_DR read access. A legend indicates 'by SW' for software trigger and 'by HW' for hardware trigger. MS31020V1
  1. 1. AUTDLY = 1.
  2. 2. Regular configuration: EXTEN[1:0] = 0x0 (software trigger), CONT = 1, CHANNELS = 1,2,3.
  3. 3. Injected configuration DISABLED.

Figure 244. AUTDLY = 1, regular hardware conversions interrupted by injected conversions (DISCEN = 0; JDISCEN = 0)

Timing diagram for Figure 244 showing regular and injected conversion sequences. Regular conversions (CH1, CH2, CH3) are interrupted by injected conversions (CH5, CH6). The diagram shows ADC state transitions, data outputs (D1, D2, D3, D1 for regular; D5, D6 for injected), and trigger signals (Regular trigger, Injected trigger). A legend indicates 'by s/w' for software trigger and 'by h/w' for hardware trigger. MS31021V2
Timing diagram for Figure 244 showing regular and injected conversion sequences. Regular conversions (CH1, CH2, CH3) are interrupted by injected conversions (CH5, CH6). The diagram shows ADC state transitions, data outputs (D1, D2, D3, D1 for regular; D5, D6 for injected), and trigger signals (Regular trigger, Injected trigger). A legend indicates 'by s/w' for software trigger and 'by h/w' for hardware trigger. MS31021V2
  1. 1. AUTDLY = 1.
  2. 2. Regular configuration: EXTEN[1:0] = 0x1 (hardware trigger), CONT = 0, DISCEN = 0, CHANNELS = 1, 2, 3.
  3. 3. Injected configuration: JEXTEN[1:0] = 0x1 (hardware Trigger), JDISCEN = 0, CHANNELS = 5,6.

Figure 245. AUTODLY = 1, regular hardware conversions interrupted by injected conversions (DISCEN = 1, JDISCEN = 1)

Timing diagram for ADC12 showing regular and injected conversions with delays and interruptions.

The diagram illustrates the timing of regular and injected conversions in the ADC12 when AUTODLY = 1, DISCEN = 1, and JDISCEN = 1. The sequence starts with a regular trigger (by SW) and proceeds through a series of regular conversions (CH1, CH2, CH3) and injected conversions (CH5, CH6). Delays (DLY) are applied between conversions. The diagram shows that injected conversions can interrupt the regular sequence, and that regular conversions are ignored if they occur during an injected sequence. The ADC state transitions between RDY (Ready) and CHx (Conversion in progress). The EOC (End of Conversion) signal is generated at the end of each sequence. The ADC_DR (Data Register) is updated with the conversion results (D1, D2, D3, D5, D6). The injected trigger (by HW) initiates the injected sequence. The JEOS (End of Injected Sequence) signal is generated at the end of the injected sequence. The ADC_JDR1 and ADC_JDR2 registers are updated with the injected conversion results (D5, D6). The legend indicates that solid lines represent software (SW) triggers and dashed lines represent hardware (HW) triggers. The text 'Indicative timings' is present in the bottom right corner of the diagram area.

Timing diagram for ADC12 showing regular and injected conversions with delays and interruptions.

MS31022V1

  1. 1. AUTODLY = 1.
  2. 2. Regular configuration: EXTEN[1:0] = 0x1 ( hardware trigger), CONT = 0, DISCEN = 1, DISCNUM = 1, CHANNELS = 1, 2, 3.
  3. 3. Injected configuration: JEXTEN[1:0] = 0x1 (hardware Trigger), JDISCEN = 1, CHANNELS = 5,6.

Figure 246. AUTODLY = 1, regular continuous conversions interrupted by injected conversions

Timing diagram for Figure 246 showing regular continuous conversions interrupted by injected conversions with AUTODLY = 1. The diagram illustrates the sequence of channels (CH1, CH2, CH5, CH6, CH3, CH1) and the associated delays (DLY) for each. It also shows the EOC, EOS, and ADC_DR signals, as well as the injected trigger and JEOS signals. Data values D1, D2, D3, D5, and D6 are indicated for the respective channels.

Timing diagram for Figure 246. The diagram shows the sequence of conversions and the associated delays. The ADC state starts at RDY and transitions through CH1 (regular), DLY (CH1), CH2 (regular), DLY (CH2), CH5 (injected), CH6 (injected), DLY (ignored), CH3 (regular), DLY (CH3), and CH1 (regular). The EOC signal is shown for each regular conversion. The ADC_DR read access is shown for each regular conversion. The injected trigger is shown for the injected conversions. The JEOS signal is shown for the injected conversions. The ADC_JDR1 and ADC_JDR2 registers are shown for the injected conversions. The data values D1, D2, D3, D5, and D6 are indicated for the respective channels. The diagram is labeled with 'by s/w' and 'by h/w' for the start of conversions. A legend indicates 'Indicative timings'.

Timing diagram for Figure 246 showing regular continuous conversions interrupted by injected conversions with AUTODLY = 1. The diagram illustrates the sequence of channels (CH1, CH2, CH5, CH6, CH3, CH1) and the associated delays (DLY) for each. It also shows the EOC, EOS, and ADC_DR signals, as well as the injected trigger and JEOS signals. Data values D1, D2, D3, D5, and D6 are indicated for the respective channels.

MS31023V3

  1. 1. AUTODLY = 1.
  2. 2. Regular configuration: EXTEN[1:0] = 0x0 (software trigger), CONT = 1, DISCEN = 0, CHANNELS = 1, 2, 3.
  3. 3. Injected configuration: JEXTEN[1:0] = 0x1 (hardware trigger), JDISCEN = 0, CHANNELS = 5,6.

Figure 247. AUTODLY = 1 in auto- injected mode (JAUTO = 1)

Timing diagram for Figure 247 showing AUTODLY = 1 in auto-injected mode (JAUTO = 1). The diagram illustrates the sequence of channels (CH1, CH2, CH5, CH6, CH3, CH1) and the associated delays (DLY) for each. It also shows the EOC, EOS, and ADC_DR signals, as well as the JEOS signal. Data values D1, D2, D3, D5, and D6 are indicated for the respective channels.

Timing diagram for Figure 247. The diagram shows the sequence of conversions and the associated delays. The ADC state starts at RDY and transitions through CH1 (regular), DLY (CH1), CH2 (regular), CH5 (injected), CH6 (injected), DLY (inj), CH3 (regular), DLY, and CH1 (regular). The 'No delay' label is shown between CH2 and CH5. The EOC signal is shown for each regular conversion. The ADC_DR read access is shown for each regular conversion. The JEOS signal is shown for the injected conversions. The ADC_JDR1 and ADC_JDR2 registers are shown for the injected conversions. The data values D1, D2, D3, D5, and D6 are indicated for the respective channels. The diagram is labeled with 'by s/w' and 'by h/w' for the start of conversions. A legend indicates 'Indicative timings'.

Timing diagram for Figure 247 showing AUTODLY = 1 in auto-injected mode (JAUTO = 1). The diagram illustrates the sequence of channels (CH1, CH2, CH5, CH6, CH3, CH1) and the associated delays (DLY) for each. It also shows the EOC, EOS, and ADC_DR signals, as well as the JEOS signal. Data values D1, D2, D3, D5, and D6 are indicated for the respective channels.

MS31024V4

  1. 1. AUTODLY = 1.
  2. 2. Regular configuration: EXTEN[1:0] = 0x0 (software trigger), CONT = 1, DISCEN = 0, CHANNELS = 1, 2.
  3. 3. Injected configuration: JAUTO = 1, CHANNELS = 5,6.

33.4.29 Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy)

The three AWD analog watchdogs monitor whether some channels remain within a configured voltage range (window).

Figure 248. Analog watchdog guarded area

Figure 248. Analog watchdog guarded area. A diagram showing a vertical axis for 'Analog voltage' with two horizontal lines representing thresholds: 'Higher threshold' (HTR) and 'Lower threshold' (LTR). The region between these two thresholds is shaded and labeled 'Guarded area'. The diagram is labeled 'ai16048' in the bottom right corner.
Figure 248. Analog watchdog guarded area. A diagram showing a vertical axis for 'Analog voltage' with two horizontal lines representing thresholds: 'Higher threshold' (HTR) and 'Lower threshold' (LTR). The region between these two thresholds is shaded and labeled 'Guarded area'. The diagram is labeled 'ai16048' in the bottom right corner.

AWDx flag and interrupt

An interrupt can be enabled for each of the three analog watchdogs by setting AWDyIE in the ADC_IER register (y = 1, 2, 3).

AWDy (y = 1, 2, 3) flag is cleared by software by writing 1 to it.

The ADC conversion result is compared to the lower and higher thresholds before alignment.

Description of analog watchdog 1

The AWD analog watchdog 1 is enabled by setting the AWD1EN bit in the ADC_CFGR1 register. This watchdog monitors whether either one selected channel or all enabled channels remain within a configured voltage range (window).

Table 316 shows how the ADC_CFGR1 registers must be configured to enable the analog watchdog on one or more channels.

Table 316. Analog watchdog channel selection

Channels guarded by the analog watchdogAWD1SGL bitAWD1EN bitJAWD1EN bit
Nonex00
All injected channels001
All regular channels010
All regular and injected channels011
Single (1) injected channel101
Single (1) regular channel110
Single (1) regular or injected channel111

1. Selected by the AWDyCH[4:0] bits. The channels must also be programmed to be converted in the appropriate regular or injected sequence.

The AWD1 analog watchdog status bit is set if the analog voltage converted by the ADC is below a lower threshold or above a higher threshold.

These thresholds are programmed in the HTR1[24:0] bits of the ADC_HTR1 register and LTR1[24:0] of the ADC_LTR1 register for the analog watchdog 1.

The threshold can be up to 25-bits (14-bit resolution with oversampling, OSR=256).

When converting data with a resolution of less than 14 bits (according to bits RES[1:0]), the LSBs of the programmed thresholds must be kept cleared, the internal comparison being performed on the full 14-bit converted data (left aligned to the half-word boundary).

Table 317 describes how the comparison is performed for all the possible resolutions for analog watchdog 1,2,3.

Table 317. Analog watchdog 1,2,3 comparison

Resolution
(bit
RES[1:0])
Analog watchdog comparison
between:
Comments
Raw converted
data, left aligned (1)
Thresholds
00: 14-bitDATA[13:0]LTR1[24:0] and
HTR1[24:0]
-
01: 12-bitDATA[13:2],00LTR1[24:0] and
HTR1[24:0]
User must configure LTR1[1:0] and
HTR1[1:0] to 00
10: 10-bitDATA[13:4],0000LTR1[24:0] and
HTR1[24:0]
User must configure LTR1[3:0] and
HTR1[3:0] to 0000
11: 8-bitDATA[13:6],000000LTR1[24:0] and
HTR1[24:0]
User must configure LTR1[5:0] and
HTR1[5:0] to 000000
  1. 1. The watchdog comparison is performed when the oversampling, the gain compensation and the offset compensation are complete (the data that are compared can be either signed or unsigned).

Analog watchdog filter for watchdog 1

When the ADC is configured with only one input channel (selecting several channels in scan mode not allowed), a valid ADC conversion data range can be configured through the ADC_LTR1 and ADC_HTR1 register:

Description of analog watchdog 2 and 3

The second and third analog watchdogs are more flexible and can guard several selected channels by programming the corresponding bits in AWDCHy[19:0] (y=2,3).

The corresponding watchdog is enabled when any bit of AWDCHy[19:0] (y=2,3) is set.

The threshold can be up to 25 bits (14-bit resolution with oversampling, OSR = 1024, and offset conversion in signed format) and are programmed with the ADC_HTR2, ADC_LTR2, ADC_HTR3, and ADC_LTR3 registers.

When converting data with a resolution of less than 14 bits (according to bits RES[1:0]), the LSBs of the programmed thresholds must be kept cleared, the internal comparison being performed on the full 14-bit converted data (left aligned).

ADC_AWDy_OUT signal output generation

Each analog watchdog is associated to an internal hardware signal ADC_AWDy_OUT (y being the watchdog number) which is directly connected to the ETR input (external trigger)

of some on-chip timers. Refer to the on-chip timers section to understand how to select the ADC_AWDy_OUT signal as ETR.

ADC_AWDy_OUT is activated when the associated analog watchdog is enabled:

Note: AWDx flag is set by hardware and reset by software: AWDy flag has no influence on the generation of ADC_AWDy_OUT (ex: ADCy_AWDy_OUT can toggle while AWDx flag remains at 1 if the software did not clear the flag).

Figure 249. ADCy_AWDx_OUT signal generation (on all regular channels)

Timing diagram for Figure 249 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over seven conversions. The AWDx FLAG is cleared by software after each 'outside' conversion.

The diagram shows the following signals over time for seven conversions:

Legend:

MS31025V1

Timing diagram for Figure 249 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over seven conversions. The AWDx FLAG is cleared by software after each 'outside' conversion.

Figure 250. ADC_AWDx_OUT signal generation (AWDx flag not cleared by software)

Timing diagram for Figure 250 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over seven conversions. The AWDx FLAG is not cleared by software after the first 'outside' conversion.

The diagram shows the following signals over time for seven conversions:

Legend:

MS31026V1

Timing diagram for Figure 250 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over seven conversions. The AWDx FLAG is not cleared by software after the first 'outside' conversion.

Figure 251. ADC_AWDx_OUT signal generation (on a single regular channel)

Timing diagram for Figure 251 showing ADC STATE, EOC FLAG, EOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over a sequence of regular channel conversions (Conversion1 and Conversion2). Conversion1 is guarded. The diagram shows states 'inside' and 'outside' for Conversion1. AWDx FLAG is cleared by software. ADCy_AWDx_OUT goes high when Conversion1 is outside and low when it is inside.

Legend:

MS31027V1

Timing diagram for Figure 251 showing ADC STATE, EOC FLAG, EOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over a sequence of regular channel conversions (Conversion1 and Conversion2). Conversion1 is guarded. The diagram shows states 'inside' and 'outside' for Conversion1. AWDx FLAG is cleared by software. ADCy_AWDx_OUT goes high when Conversion1 is outside and low when it is inside.

Figure 252. ADC_AWDx_OUT signal generation (on all injected channels)

Timing diagram for Figure 252 showing ADC STATE, JEOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over a sequence of injected channel conversions (Conversion1 to Conversion4). All injected channels are guarded. The diagram shows states 'inside' and 'outside' for each conversion. AWDx FLAG is cleared by software. ADCy_AWDx_OUT goes high if any guarded channel is outside and low only when all are inside.

Legend:

MS31028V1

Timing diagram for Figure 252 showing ADC STATE, JEOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over a sequence of injected channel conversions (Conversion1 to Conversion4). All injected channels are guarded. The diagram shows states 'inside' and 'outside' for each conversion. AWDx FLAG is cleared by software. ADCy_AWDx_OUT goes high if any guarded channel is outside and low only when all are inside.

Analog watchdog threshold control

LTRx[24:0] and HTRx[24:0] can be changed when an analog-to-digital conversion is ongoing (that is between the start of conversion and the end of conversion of the ADC internal state). If LTRx[24:0] and HTRx[24:0] are updated during the ADC conversion of the ADC guarded channel, the watchdog function is masked for this conversion. This masking is removed at the next start of conversion, resulting in an analog watchdog thresholds to be applied from the next ADC conversion. The analog watchdog comparison is performed at each end of conversion. If the current ADC data is out of the new interval, no interrupt and AWDx_OUT signal are issued. The interrupt and the AWD generation only happen at the end of the conversion which started after the threshold update. If AWD_xOUT is already asserted, programming the new thresholds does not deassert the AWD_OUT signal.

Analog watchdog with gain and offset compensation

When gain and offset compensation are enabled, the analog watchdog compares the threshold after the compensated data.

33.4.30 Oversampler

The oversampling unit performs data preprocessing to offload the CPU. It is able to handle multiple conversions and average them into a single data with increased data width, up to 24-bit (14-bit values and OSR = 1024).

It provides a result with the following form, where N and M can be adjusted:

\[ \text{Result} = \frac{1}{M} \times \sum_{n=0}^{n=N-1} \text{Conversion}(t_n) \]

It enables the following functions to be performed by hardware: averaging, data rate reduction, SNR improvement, basic filtering.

The oversampling ratio N is defined using the OSR[9:0] bits in the ADC_CFGR2 register, and can range from 2x to 1024x. The division coefficient M consists of a right bit shift up to 10 bits, and is defined using the OVSS[3:0] bits in the ADC_CFGR2 register.

The summation unit can yield a result up to 24 bits (1024 x 14-bit results), which can be left or right shifted. When right shifting is selected, it is rounded to the nearest value using the least significant bits left apart by the shifting, before being transferred into the ADC_DR data register.

Figure 253 gives a numerical example of the processing, from a raw 24-bit accumulated data to the final 14-bit result.

Figure 253. 14-bit result oversampling with 10-bits right shift and rounding

Diagram illustrating 14-bit result oversampling with 10-bits right shift and rounding. It shows two examples of 24-bit data being processed into 14-bit results.

The diagram illustrates the processing of 24-bit accumulated data into a 14-bit result using right shifting and rounding. It shows two examples of this process.

Example 1:

Example 2:

MSv62476V2

Diagram illustrating 14-bit result oversampling with 10-bits right shift and rounding. It shows two examples of 24-bit data being processed into 14-bit results.

The conversion timings in oversampling mode do not change: the sample time is maintained during the whole oversampling sequence. A new data is provided every N conversions with an equivalent delay equal to \( N \times T_{\text{CONV}} = N \times (t_{\text{SAMPL}} + t_{\text{SAR}}) \) . The flags are set as follows:

Operating modes supported during oversampling

In oversampling mode, most of the ADC operating modes are maintained:

Note: The alignment mode is not available when working with oversampled data. The ALIGN bit in ADC_CFGR is ignored and the data are always provided right-aligned.

Analog watchdog

The analog watchdog functionality is maintained, with the following differences:

Note: Care must be taken when using high shifting values, since this reduces the comparison range. For instance, if the oversampled result is shifted by 4 bits, thus yielding an 8-bit right-aligned data, the effective analog watchdog comparison can only be performed on 8 bits. The comparison is done between ADC_DR[11:4] and HT[7:0]/LT[7:0]. HT[11:8]/LT[11:8] must be kept reset.

Triggered mode

The averager can also be used for basic filtering purpose. Although not a very powerful filter (slow roll-off and limited stop band attenuation), it can be used as a notch filter to reject constant parasitic frequencies (typically coming from the mains or from a switched mode power supply). For this purpose, a specific discontinuous mode can be enabled with the TROVS bit of the DC_CFGR2, to be able to have an oversampling frequency defined by a user and independent from the conversion time itself.

The Figure 254 below shows how conversions are started in response to triggers during discontinuous mode.

If the TROVS bit is set, the content of the DISCEN bit is ignored and considered as 1.

Figure 254. Triggered regular oversampling mode (TROVS bit = 1)

Figure 254: Triggered regular oversampling mode (TROVS bit = 1). The diagram illustrates two scenarios for regular oversampling. The top scenario shows a sequence of four channels (Ch(N)0, Ch(N)1, Ch(N)2, Ch(N)3) being converted upon a trigger, with the EOC flag set after the last channel. The bottom scenario shows a sequence of seven channels (Ch(N)0, Ch(N)1, Ch(N)2, Ch(N)3, Ch(N)0, Ch(N)1, Ch(N)2) being converted upon a trigger, with the EOC flag set after the last channel. Both scenarios are controlled by the configuration: CONT=0, DISCEN = 1, and TROVS = 1. The diagram is labeled MS34455V2.

The diagram illustrates two examples of triggered regular oversampling mode (TROVS bit = 1) for an ADC12. Both examples show a sequence of channel conversions triggered by an external signal.

Top Example: Configuration: CONT=0, DISCEN = 1, TROVS = 0. A trigger initiates a sequence of four channel conversions: Ch(N) 0 , Ch(N) 1 , Ch(N) 2 , and Ch(N) 3 . The EOC flag is set after the last conversion (Ch(N) 3 ).

Bottom Example: Configuration: CONT=0, DISCEN = 1, TROVS = 1. A trigger initiates a sequence of seven channel conversions: Ch(N) 0 , Ch(N) 1 , Ch(N) 2 , Ch(N) 3 , Ch(N) 0 , Ch(N) 1 , and Ch(N) 2 . The EOC flag is set after the last conversion (Ch(N) 2 ).

The diagram is labeled MS34455V2.

Figure 254: Triggered regular oversampling mode (TROVS bit = 1). The diagram illustrates two scenarios for regular oversampling. The top scenario shows a sequence of four channels (Ch(N)0, Ch(N)1, Ch(N)2, Ch(N)3) being converted upon a trigger, with the EOC flag set after the last channel. The bottom scenario shows a sequence of seven channels (Ch(N)0, Ch(N)1, Ch(N)2, Ch(N)3, Ch(N)0, Ch(N)1, Ch(N)2) being converted upon a trigger, with the EOC flag set after the last channel. Both scenarios are controlled by the configuration: CONT=0, DISCEN = 1, and TROVS = 1. The diagram is labeled MS34455V2.

Injected and regular sequencer management when oversampling

In oversampling mode, injected and regular sequencers can have different behaviors. The oversampling can be enabled for both sequencers with some limitations if they have to be used simultaneously (this is related to a unique accumulation unit).

Oversampling regular channels only

The regular oversampling mode bit, ROVSM, defines how the regular oversampling sequence is resumed if it is interrupted by injected conversion:

Figure 255 gives examples for an oversampling ratio of 4x.

Figure 255. Regular oversampling modes (4x ratio)

Figure 255: Regular oversampling modes (4x ratio). The diagram is split into two parts: Continued mode and Resumed mode. In Continued mode (ROVSE = 1, JOVSE = 0, ROVSM = 0, TROVS = X), a sequence of regular channels Ch(N)0-3 and Ch(M)0-1 is interrupted by a trigger for injected channels Ch(J) and Ch(K). The regular oversampling is stopped and then continued from the next sample in the sequence (Ch(M)1) after the injected sequence finishes (JEOC). In Resumed mode (ROVSE = 1, JOVSE = 0, ROVSM = 1, TROVS = X), the regular oversampling is aborted and then resumed from the beginning of the current oversampling group (Ch(M)0) after the injected sequence finishes.

Continued mode: ROVSE = 1, JOVSE = 0, ROVSM = 0, TROVS = X

Resumed mode: ROVSE = 1, JOVSE = 0, ROVSM = 1, TROVS = X

MS34456V1

Figure 255: Regular oversampling modes (4x ratio). The diagram is split into two parts: Continued mode and Resumed mode. In Continued mode (ROVSE = 1, JOVSE = 0, ROVSM = 0, TROVS = X), a sequence of regular channels Ch(N)0-3 and Ch(M)0-1 is interrupted by a trigger for injected channels Ch(J) and Ch(K). The regular oversampling is stopped and then continued from the next sample in the sequence (Ch(M)1) after the injected sequence finishes (JEOC). In Resumed mode (ROVSE = 1, JOVSE = 0, ROVSM = 1, TROVS = X), the regular oversampling is aborted and then resumed from the beginning of the current oversampling group (Ch(M)0) after the injected sequence finishes.

Oversampling injected channels only

The injected oversampling mode bit, JOVSE, enables oversampling solely for conversions in the injected sequencer.

Oversampling regular and injected channels

Both ROVSE and JOVSE bits can be set simultaneously. In this case, the regular oversampling mode is forced to resumed mode (ROVSM bit ignored), as shown in Figure 256.

Figure 256. Regular and injected oversampling modes used simultaneously

Figure 256: Regular and injected oversampling modes used simultaneously. The diagram shows regular channels Ch(N)0-3 and Ch(M)0-1 being interrupted by a trigger for an injected oversampling sequence Ch(J)0-3. The regular oversampling is aborted. Once the injected sequence completes (JEOC), the regular oversampling resumes from the start of the aborted group (Ch(M)0). Configuration: ROVSE = 1, JOVSE = 1, ROVSM = 1, TROVS = 0.

ROVSE = 1, JOVSE = 1, ROVSM = 1, TROVS = 0

MS34457V2

Figure 256: Regular and injected oversampling modes used simultaneously. The diagram shows regular channels Ch(N)0-3 and Ch(M)0-1 being interrupted by a trigger for an injected oversampling sequence Ch(J)0-3. The regular oversampling is aborted. Once the injected sequence completes (JEOC), the regular oversampling resumes from the start of the aborted group (Ch(M)0). Configuration: ROVSE = 1, JOVSE = 1, ROVSM = 1, TROVS = 0.

Triggered regular oversampling with injected conversions

Injected conversions can be performed in triggered regular mode. In this case, the injected mode oversampling mode must be disabled, and the ROVSM bit is ignored (resumed mode forced). The JOVSE bit must be reset. The behavior is shown in Figure 257 .

Figure 257. Triggered regular oversampling with injection

Timing diagram for triggered regular oversampling with injection (MS34458V4).

The diagram shows a sequence of ADC conversions. It starts with regular channel triggers for Ch(N) 0 and Ch(N) 1 . A third trigger occurs for Ch(N) 2 , but an injected trigger occurs simultaneously or shortly after, causing an 'Abort' of the regular conversion. Injected channels Ch(J) and Ch(K) are then converted. After the injected sequence, oversampling is resumed, starting again with Ch(N) 0 and Ch(N) 1 . The configuration settings shown are: ROVSE = 1, JOVSE = 0, ROVSM = 1, TROVS = 1.

Timing diagram for triggered regular oversampling with injection (MS34458V4).

Auto-injected mode

It is possible to oversample auto-injected sequences and have all conversions results stored in registers. This enables to save a DMA resource. This mode is available only when both regular and injected oversampling active: JAUTO = 1, ROVSE = 1 and JOVSE = 1. Other combinations are not supported. The ROVSM bit is ignored in auto-injected mode.

Figure 258 shows how the conversions are sequenced.

Figure 258. Oversampling in auto-injected mode

Timing diagram for oversampling in auto-injected mode (MS34459V1).

The diagram illustrates a continuous sequence of conversions. It begins with a block of regular channels: N 0 , N 1 , N 2 , N 3 . This is immediately followed by a long sequence of injected channels: I 0 , I 1 , I 2 , I 3 , J 0 , J 1 , J 2 , J 3 , K 0 , K 1 , K 2 , K 3 , L 0 , L 1 , L 2 , L 3 . After the injected sequence, the regular sequence N 0 , N 1 , N 2 , N 3 repeats. The configuration settings are: JAUTO = 1, ROVSE = 1, JOVSE = 1, ROVSM = X, TROVS = 0.

Timing diagram for oversampling in auto-injected mode (MS34459V1).

It is possible to have also the triggered mode enabled, using the TROVS bit. In this case, the ADC must be configured as follows: JAUTO = 1, DISCEN = 0, JDISCEN = 0, ROVSE = 1, JOVSE = 1 and TROVSE = 1.

Dual ADC modes support when oversampling

It is possible to have oversampling enabled when working in dual ADC configuration, for the injected simultaneous mode and regular simultaneous mode. In this case, the two ADCs must be programmed with the very same settings (including oversampling).

All other dual ADC modes are not supported when either regular or injected oversampling is enabled (ROVSE = 1 or JOVSE = 1).

Summary of combined modes

Table 318 summarizes all mode combinations, including non-supported modes.

Table 318. Summary of oversampler operating modes

Regular oversampling:
ROVSE bit
Injected oversampling:
JOVSE bit
Oversampler mode:
ROVSM bit
0 = continued
1 = resumed
Triggered regular mode:
TROVS bit
Comment
100 (continued)0Regular continued mode
100 (continued)1Not supported
101 (resumed)0Regular resumed mode
101 (resumed)1Triggered regular resumed mode
110 (continued)XNot supported
111 (resumed)0Injected and regular resumed mode
111 (resumed)1Not supported
01XXInjected oversampling

33.4.31 Dual ADC modes

In devices with two ADCs or more, dual ADC modes can be used (see Figure 33.4.32 ):

In dual ADC mode the start of conversion is triggered alternately or simultaneously by the ADCx master to the ADC slave, depending on the mode selected by the DUAL[4:0] bits of the ADC12_CCR register.

Four possible modes are implemented:

It is also possible to use these modes combined in the following ways:

In dual ADC mode (when bits DUAL[4:0] in the ADC12_CCR register are not equal to zero), the bits CONT, AUTDLY, DISCEN, DISCNUM[2:0], JDISCEN, JAUTO of the ADC_CFGR register are shared between the master and slave ADC: the bits in the slave ADC are always equal to the corresponding bits of the master ADC.

To start a conversion in dual mode, the user must program the bits EXTEN[1:0], EXTSEL, JEXTEN[1:0], JEXTSEL of the master ADC only, to configure a software or hardware

trigger, and a regular or injected trigger. (the bits EXTEN[1:0] and JEXTEN[1:0] of the slave ADC are don't care).

In regular simultaneous or interleaved modes: once the user sets bit ADSTART or bit ADSTP of the master ADC, the corresponding bit of the slave ADC is also automatically set. However, bit ADSTART or bit ADSTP of the slave ADC is not necessary cleared at the same time as the master ADC bit.

In injected simultaneous or alternate trigger modes: once the user sets bit JADSTART or bit JADSTP of the master ADC, the corresponding bit of the slave ADC is also automatically set. However, bit JADSTART or bit JADSTP of the slave ADC is not necessary cleared at the same time as the master ADC bit.

In dual ADC mode, the converted data of the master and slave ADC can be read in parallel, by reading the ADC common data register (ADC12_CDR). The status bits can be also read in parallel by reading the dual-mode status register (ADC12_CSR).

Figure 259. Dual ADC block diagram (1)

Dual ADC block diagram showing Master ADC and Slave ADC components, their registers, and input sources.

The diagram illustrates the internal architecture of a Dual ADC system. It consists of two main ADC blocks: a Slave ADC at the top and a Master ADC at the bottom. Both ADCs have their own Regular channels and Injected channels . The Slave ADC's regular channels output to a Regular data register (32-bits) , and its injected channels output to Injected data registers (4 x32-bits) . The Master ADC has similar regular and injected channels, which output to their own respective Regular data register (32-bits) and Injected data registers (4 x32-bits) . All four data registers are connected to a common Address/data bus . Input sources for the ADCs include Internal analog inputs and GPIO ports (labeled with ADCx_INP0, ADCx_INN0, ADCx_INP2, ADCx_INN2, ..., ADCx_INP19, ADCx_INN19). The Master ADC features two Start trigger mux. units: one for the (regular group) and another for the (injected group) . These muxes are connected to Internal triggers and a Dual mode control block. The Slave ADC also receives Internal triggers . A small text label MSv41029V2 is located in the bottom right corner of the diagram.

Dual ADC block diagram showing Master ADC and Slave ADC components, their registers, and input sources.

Injected simultaneous mode

This mode is selected by programming bits DUAL[4:0] = 00101

This mode converts an injected group of channels. The external trigger source comes from the injected group multiplexer of the master ADC (selected by the JEXTSEL[4:0] bits in the ADC_JSQR register).

Note: Do not convert the same channel on the two ADCs (no overlapping sampling times for the two ADCs when converting the same channel).

In simultaneous mode, one must convert sequences with the same length and inside a sequence, the N-th conversion in master and slave must be configured with the same sampling time.

Regular conversions can be performed on one or all ADCs. In that case, they are independent of each other and are interrupted when an injected event occurs. They are resumed at the end of the injected conversion group.

Figure 260. Injected simultaneous mode on four channels: dual ADC mode

Diagram illustrating Injected simultaneous mode on four channels for dual ADC mode. It shows two ADCs, MASTER ADC and SLAVE ADC, each with four channels. The MASTER ADC channels are CH1, CH2, CH3, and CH4. The SLAVE ADC channels are CH15, CH14, CH13, and CH12. A 'Trigger' event initiates the sequence. A legend indicates that a light gray box represents 'Sampling' and a white box represents 'Conversion'. Arrows show the sequence of conversions for both ADCs, ending at 'End of injected sequence on MASTER and SLAVE ADC'. The diagram is labeled MS31900V1.
MASTER ADCCH1CH2CH3CH4
SLAVE ADCCH15CH14CH13CH12

Legend:
[Light Gray Box] Sampling
[White Box] Conversion

MS31900V1

Diagram illustrating Injected simultaneous mode on four channels for dual ADC mode. It shows two ADCs, MASTER ADC and SLAVE ADC, each with four channels. The MASTER ADC channels are CH1, CH2, CH3, and CH4. The SLAVE ADC channels are CH15, CH14, CH13, and CH12. A 'Trigger' event initiates the sequence. A legend indicates that a light gray box represents 'Sampling' and a white box represents 'Conversion'. Arrows show the sequence of conversions for both ADCs, ending at 'End of injected sequence on MASTER and SLAVE ADC'. The diagram is labeled MS31900V1.

If JDISCEN = 1, each simultaneous conversion of the injected sequence requires an injected trigger event to occur.

This mode can be combined with AUTDLY mode:

Regular simultaneous mode with independent injected

This mode is selected by programming bits DUAL[4:0] = 00110.

This mode is performed on a regular group of channels. The external trigger source comes from the regular group multiplexer of the master ADC (selected by the EXTSEL[4:0] bits in the ADC_CFGR register). A simultaneous trigger is provided to the slave ADC.

In this mode, independent injected conversions are supported. An injection request (either on master or on the slave) aborts the current simultaneous conversions, which are restarted once the injected conversion is completed.

Note: Do not convert the same channel on the two ADCs (no overlapping sampling times for the two ADCs when converting the same channel).

In regular simultaneous mode, one must convert sequences with the same length and inside a sequence, the N-th conversion in master and slave must be configured with the same sampling time.

Software is notified by interrupts when it can read the data:

It is also possible to read the regular data using the DMA. Two methods are possible:

Note: When DAMDF[1:0] = 10 or 11, the user must program the same number of conversions in the master's sequence as in the slave's sequence. Otherwise, the remaining conversions do not generate a DMA request.

Figure 261. Regular simultaneous mode on 16 channels: dual ADC mode

Diagram illustrating regular simultaneous mode on 16 channels in dual ADC mode. It shows two ADCs, MASTER ADC and SLAVE ADC, with their respective channel sequences. The MASTER ADC sequence is CH1, CH2, CH3, CH4, ..., CH16. The SLAVE ADC sequence is CH16, CH14, CH13, CH12, ..., CH1. A 'Trigger' arrow points to the start of the sequences. A legend indicates that a small rectangle represents 'Sampling' and a larger rectangle represents 'Conversion'. An arrow points to the end of the sequences, labeled 'End of regular sequence on MASTER and SLAVE ADC'. The diagram is labeled 'ai16054b' in the bottom right corner.
Diagram illustrating regular simultaneous mode on 16 channels in dual ADC mode. It shows two ADCs, MASTER ADC and SLAVE ADC, with their respective channel sequences. The MASTER ADC sequence is CH1, CH2, CH3, CH4, ..., CH16. The SLAVE ADC sequence is CH16, CH14, CH13, CH12, ..., CH1. A 'Trigger' arrow points to the start of the sequences. A legend indicates that a small rectangle represents 'Sampling' and a larger rectangle represents 'Conversion'. An arrow points to the end of the sequences, labeled 'End of regular sequence on MASTER and SLAVE ADC'. The diagram is labeled 'ai16054b' in the bottom right corner.

If DISCEN = 1 then each “n” simultaneous conversions of the regular sequence require a regular trigger event to occur (“n” is defined by DISCNUM).

This mode can be combined with AUTDLY mode:

It is possible to use the DMA to handle data in regular simultaneous mode combined with AUTDLY mode, assuming that multi-DMA mode is used: DAMDF[1:0] bits must be set to 10 or 11.

When regular simultaneous mode is combined with AUTDLY mode, it is mandatory for the user to ensure that:

Note: This combination of regular simultaneous mode and AUTDLY mode is restricted to the use case when only regular channels are programmed: it is forbidden to program injected channels in this combined mode.

Interleaved mode with independent injected

This mode is selected by programming bits DUAL[4:0] = 00111.

This mode can be started only on a regular group (usually one channel). The external trigger source comes from the regular channel multiplexer of the master ADC.

After an external trigger occurs:

The minimum delay which separates two conversions in interleaved mode is configured in the DELAY bits in the ADC12_CCR register. This delay starts to count after the end of the sampling phase of the master conversion. This way, an ADC cannot start a conversion if the

complementary ADC is still sampling its input (only one ADC can sample the input signal at a given time).

If the CONT bit is set on both master and slave ADCs, the selected regular channels of both ADCs are continuously converted.

The software is notified by interrupts when it can read the data at the end of each conversion event (EOC) on the slave ADC. A slave and master EOC interrupts are generated (if EOCIE is enabled) and the software can read the ADC_DR of the slave/master ADC.

Note: In 16-bit data format, enable only the slave EOC interrupt and read the common data register (ADC12_CDR). For 32-bit data format, enable both the slave and master EOC interrupts and read ADC12_CDR2 register. But in this case, the user must ensure that the duration of the conversions are compatible to ensure that inside the sequence, a master conversion is always followed by a slave conversion before a new master conversion restarts. It is recommended to use the MDMA mode.

It is also possible to have the regular data transferred by DMA. In this case, individual DMA requests on each ADC cannot be used and it is mandatory to use the DAMDF mode, as following:

Figure 262. Interleaved mode on one channel in continuous conversion mode: dual ADC mode

Timing diagram for Figure 262 showing continuous conversion mode for Master and Slave ADCs on channel CH1. The Master ADC starts with a sampling phase followed by a conversion phase (CH1). The Slave ADC is triggered by the Master ADC's conversion. Both ADCs have a sampling phase followed by a conversion phase (CH1). The duration of each conversion phase is 6 ADCCCLK cycles. The diagram shows two consecutive conversions. The end of the second conversion on both the Master and Slave ADCs is marked as the 'End of conversion on master and slave ADC'. A legend indicates that gray boxes represent 'Sampling' and white boxes represent 'Conversion'. The diagram is labeled MSv65310V1.
Timing diagram for Figure 262 showing continuous conversion mode for Master and Slave ADCs on channel CH1. The Master ADC starts with a sampling phase followed by a conversion phase (CH1). The Slave ADC is triggered by the Master ADC's conversion. Both ADCs have a sampling phase followed by a conversion phase (CH1). The duration of each conversion phase is 6 ADCCCLK cycles. The diagram shows two consecutive conversions. The end of the second conversion on both the Master and Slave ADCs is marked as the 'End of conversion on master and slave ADC'. A legend indicates that gray boxes represent 'Sampling' and white boxes represent 'Conversion'. The diagram is labeled MSv65310V1.

Figure 263. Interleaved mode on one channel in single conversion mode: dual ADC mode

Timing diagram for Figure 263 showing single conversion mode for Master and Slave ADCs on channel CH1. The Master ADC starts with a sampling phase followed by a conversion phase (CH1). The Slave ADC is triggered by the Master ADC's conversion. Both ADCs have a sampling phase followed by a conversion phase (CH1). The duration of each conversion phase is 6 ADCCCLK cycles. The diagram shows two consecutive conversions. The end of the first conversion on both the Master and Slave ADCs is marked as 'End of conversion on master and slave ADC'. The same pattern repeats for the second conversion. A legend indicates that gray boxes represent 'Sampling' and white boxes represent 'Conversion'. The diagram is labeled MSv65311V1.
Timing diagram for Figure 263 showing single conversion mode for Master and Slave ADCs on channel CH1. The Master ADC starts with a sampling phase followed by a conversion phase (CH1). The Slave ADC is triggered by the Master ADC's conversion. Both ADCs have a sampling phase followed by a conversion phase (CH1). The duration of each conversion phase is 6 ADCCCLK cycles. The diagram shows two consecutive conversions. The end of the first conversion on both the Master and Slave ADCs is marked as 'End of conversion on master and slave ADC'. The same pattern repeats for the second conversion. A legend indicates that gray boxes represent 'Sampling' and white boxes represent 'Conversion'. The diagram is labeled MSv65311V1.

If DISCEN = 1, each “n” simultaneous conversions (“n” is defined by DISCNUM) of the regular sequence require a regular trigger event to occur.

In this mode, injected conversions are supported. When injection is done (either on master or on slave), both the master and the slave regular conversions are aborted and the sequence is restarted from the master (see Figure 264 below).

Figure 264. Interleaved conversion with injection

Timing diagram for interleaved conversion with injection. The diagram shows two ADCs, ADC1 (master) and ADC2 (slave), performing conversions. ADC1 has channels CH1, CH1, CH1. ADC2 has channels CH2, CH2, CH2. An 'Injected trigger' occurs, causing ADC1 to convert CH11. After the trigger, ADC1 resumes with CH1, CH1, CH1. ADC2 resumes with CH2, CH2, CH0. 'read CDR' labels indicate when data is read. A 'Resume (always on master)' label indicates the resumption point. A legend shows 'Sampling' (light gray) and 'Conversion' (dark gray) phases. A dashed box around the third CH2 of ADC2 indicates 'conversions aborted'. The diagram is labeled MS34460V1.
Timing diagram for interleaved conversion with injection. The diagram shows two ADCs, ADC1 (master) and ADC2 (slave), performing conversions. ADC1 has channels CH1, CH1, CH1. ADC2 has channels CH2, CH2, CH2. An 'Injected trigger' occurs, causing ADC1 to convert CH11. After the trigger, ADC1 resumes with CH1, CH1, CH1. ADC2 resumes with CH2, CH2, CH0. 'read CDR' labels indicate when data is read. A 'Resume (always on master)' label indicates the resumption point. A legend shows 'Sampling' (light gray) and 'Conversion' (dark gray) phases. A dashed box around the third CH2 of ADC2 indicates 'conversions aborted'. The diagram is labeled MS34460V1.

Alternate trigger mode

This mode is selected by programming bits DUAL[4:0] = 01001.

This mode can be started only on an injected group. The source of external trigger comes from the injected group multiplexer of the master ADC.

This mode is only possible when selecting hardware triggers: JEXTEN[1:0] must not be 0x0.

Injected discontinuous mode disabled (JDISCEN = 0 for both ADC)

  1. 1. When the 1st trigger occurs, all injected master ADC channels in the group are converted.
  2. 2. When the 2nd trigger occurs, all injected slave ADC channels in the group are converted.
  3. 3. And so on.

A JEOS interrupt, if enabled, is generated after all injected channels of the master ADC in the group have been converted.

A JEOS interrupt, if enabled, is generated after all injected channels of the slave ADC in the group have been converted.

JEOC interrupts, if enabled, can also be generated after each injected conversion.

If another external trigger occurs after all injected channels in the group have been converted then the alternate trigger process restarts by converting the injected channels of the master ADC in the group.

Figure 265. Alternate trigger: injected group of each ADC

Timing diagram showing the sequence of injected group conversions for Master and Slave ADCs triggered by four external events. The diagram illustrates the flow of data from sampling to conversion and the generation of JEOC and JEOS interrupts.

The diagram illustrates the timing of injected group conversions for a Master ADC and a Slave ADC, triggered by four external events (1st, 2nd, 3rd, and 4th triggers). The sequence of events is as follows:

For each injected channel, the Master ADC generates a JEOC interrupt upon completion. The Slave ADC also generates a JEOC interrupt upon completion. The Master ADC generates a JEOS interrupt after all injected channels in its group have been converted. The Slave ADC generates a JEOS interrupt after all injected channels in its group have been converted.

Legend:

ai16059-m

Timing diagram showing the sequence of injected group conversions for Master and Slave ADCs triggered by four external events. The diagram illustrates the flow of data from sampling to conversion and the generation of JEOC and JEOS interrupts.

Note:

Regular conversions can be enabled on one or all ADCs. In this case, the regular conversions are independent of each other. A regular conversion is interrupted when the ADC has to perform an injected conversion. It is resumed when the injected conversion is finished.

The time interval between two trigger events must be greater than or equal to one ADC clock period. The minimum time interval between two trigger events that start conversions on the same ADC is the same as in the single ADC mode.

Injected discontinuous mode enabled (JDISCEN = 1 for both ADC)

If the injected discontinuous mode is enabled for both master and slave ADCs:

A JEOS interrupt, if enabled, is generated after all injected channels of the master ADC in the group have been converted.

A JEOS interrupt, if enabled, is generated after all injected channels of the slave ADC in the group have been converted.

JEOC interrupts, if enabled, can also be generated after each injected conversions.

If another external trigger occurs after all injected channels in the group have been converted, then the alternate trigger process restarts.

Figure 266. Alternate trigger: Four injected channels (each ADC) in discontinuous mode

Timing diagram for Figure 266 showing alternate trigger behavior for four injected channels in discontinuous mode. The diagram illustrates the sequence of sampling and conversion for a Master ADC and a Slave ADC. Triggers 1, 3, 5, and 7 start the Master ADC sequence, while triggers 2, 4, 6, and 8 start the Slave ADC sequence. Each trigger initiates a sampling phase followed by a conversion phase. End-of-conversion (JEOC) and end-of-sequence (JEOS) flags are indicated for each ADC. The legend shows a small square for Sampling and a larger rectangle for Conversion.

The diagram shows the timing of sampling and conversion for a Master ADC and a Slave ADC in discontinuous mode with alternate triggers. The Master ADC is triggered by the 1st, 3rd, 5th, and 7th triggers, while the Slave ADC is triggered by the 2nd, 4th, 6th, and 8th triggers. Each trigger initiates a sampling phase (small square) followed by a conversion phase (large rectangle). The Master ADC generates JEOC (End of Conversion) on master ADC after each conversion, and JEOC, JEOS (End of Sequence) on master ADC after the 4th conversion. The Slave ADC generates JEOC on slave ADC after each conversion, and JEOC, JEOS on slave ADC after the 4th conversion. The legend indicates that a small square represents Sampling and a large rectangle represents Conversion.

Timing diagram for Figure 266 showing alternate trigger behavior for four injected channels in discontinuous mode. The diagram illustrates the sequence of sampling and conversion for a Master ADC and a Slave ADC. Triggers 1, 3, 5, and 7 start the Master ADC sequence, while triggers 2, 4, 6, and 8 start the Slave ADC sequence. Each trigger initiates a sampling phase followed by a conversion phase. End-of-conversion (JEOC) and end-of-sequence (JEOS) flags are indicated for each ADC. The legend shows a small square for Sampling and a larger rectangle for Conversion.

Combined regular/injected simultaneous mode

This mode is selected by programming bits DUAL[4:0] = 00001.

It is possible to interrupt the simultaneous conversion of a regular group to start the simultaneous conversion of an injected group.

Note: The sequences must be converted with the same length, the N-th conversion in master and slave mode must be configured with the same sampling time inside a given sequence, or the interval between triggers has to be longer than the long conversion time of the two sequences. If the above conditions are not respected, the ADC with the shortest sequence may restart while the ADC with the longest sequence is completing the previous conversions.

Combined regular simultaneous + alternate trigger mode

This mode is selected by programming bits DUAL[4:0] = 00010.

It is possible to interrupt the simultaneous conversion of a regular group to start the alternate trigger conversion of an injected group. Figure 267 shows the behavior of an alternate trigger interrupting a simultaneous regular conversion.

The injected alternate conversion is immediately started after the injected event. If a regular conversion is already running, in order to ensure synchronization after the injected conversion, the regular conversion of all (master/slave) ADCs is stopped and resumed synchronously at the end of the injected conversion.

Note: The sequences must be converted with the same length, the N-th conversion in master and slave mode must be configured with the same sampling time inside a given sequence, or the interval between triggers has to be longer than the long conversion time of the two sequences. If the above conditions are not respected, the ADC with the shortest sequence may restart while the ADC with the longest sequence is completing the previous conversions.

Figure 267. Alternate + regular simultaneous

Figure 267: Alternate + regular simultaneous conversion diagram. The diagram shows four horizontal timelines: ADC MASTER reg, ADC MASTER inj, ADC SLAVE reg, and ADC SLAVE inj. The regular conversion sequence (ADC MASTER reg and ADC SLAVE reg) consists of a repeating pattern of three channels: CH1, CH2, CH3 followed by CH3, CH4 followed by CH4, CH5 for the master; and CH4, CH6, CH7 followed by CH7, CH8 followed by CH8, CH9 for the slave. The injected conversion sequence (ADC MASTER inj and ADC SLAVE inj) consists of a single channel, CH1. The 1st trigger (indicated by a downward arrow) occurs during the conversion of CH3 in the master regular sequence, causing the master injected sequence (CH1) to start. The 2nd trigger (indicated by an upward arrow) occurs during the conversion of CH1 in the slave injected sequence, causing the slave regular sequence (CH4, CH6, CH7) to start. A note indicates that synchronization is not lost.
Figure 267: Alternate + regular simultaneous conversion diagram. The diagram shows four horizontal timelines: ADC MASTER reg, ADC MASTER inj, ADC SLAVE reg, and ADC SLAVE inj. The regular conversion sequence (ADC MASTER reg and ADC SLAVE reg) consists of a repeating pattern of three channels: CH1, CH2, CH3 followed by CH3, CH4 followed by CH4, CH5 for the master; and CH4, CH6, CH7 followed by CH7, CH8 followed by CH8, CH9 for the slave. The injected conversion sequence (ADC MASTER inj and ADC SLAVE inj) consists of a single channel, CH1. The 1st trigger (indicated by a downward arrow) occurs during the conversion of CH3 in the master regular sequence, causing the master injected sequence (CH1) to start. The 2nd trigger (indicated by an upward arrow) occurs during the conversion of CH1 in the slave injected sequence, causing the slave regular sequence (CH4, CH6, CH7) to start. A note indicates that synchronization is not lost.

If a trigger occurs during an injected conversion that has interrupted a regular conversion, the alternate trigger is served. Figure 268 shows the behavior in this case (note that the 6th trigger is ignored because the associated alternate conversion is not complete).

Figure 268. Case of trigger occurring during injected conversion

Figure 268: Case of trigger occurring during injected conversion diagram. The diagram shows four horizontal timelines: ADC MASTER reg, ADC MASTER inj, ADC SLAVE reg, and ADC SLAVE inj. The regular conversion sequence (ADC MASTER reg and ADC SLAVE reg) consists of a repeating pattern of three channels: CH1, CH2, CH3 followed by CH3, CH4 followed by CH4, CH5 followed by CH5, CH6 for the master; and CH7, CH8, CH9 followed by CH9, CH10 followed by CH10, CH11 followed by CH11, CH12 for the slave. The injected conversion sequence (ADC MASTER inj and ADC SLAVE inj) consists of a single channel, CH14 for the master and CH15 for the slave. The 1st trigger (downward arrow) occurs during the conversion of CH3 in the master regular sequence, starting the master injected sequence (CH14). The 2nd trigger (upward arrow) occurs during the conversion of CH15 in the slave injected sequence, starting the slave regular sequence (CH7, CH8, CH9). The 3rd trigger (downward arrow) occurs during the conversion of CH4 in the master regular sequence, starting another master injected sequence (CH14). The 4th trigger (upward arrow) occurs during the conversion of CH15 in the slave injected sequence, starting another slave regular sequence (CH10, CH11). The 5th trigger (downward arrow) occurs during the conversion of CH5 in the master regular sequence, starting another master injected sequence (CH14). The 6th trigger (upward arrow) occurs during the conversion of CH15 in the slave injected sequence, but is ignored because the associated alternate conversion (slave regular sequence) is not complete.
Figure 268: Case of trigger occurring during injected conversion diagram. The diagram shows four horizontal timelines: ADC MASTER reg, ADC MASTER inj, ADC SLAVE reg, and ADC SLAVE inj. The regular conversion sequence (ADC MASTER reg and ADC SLAVE reg) consists of a repeating pattern of three channels: CH1, CH2, CH3 followed by CH3, CH4 followed by CH4, CH5 followed by CH5, CH6 for the master; and CH7, CH8, CH9 followed by CH9, CH10 followed by CH10, CH11 followed by CH11, CH12 for the slave. The injected conversion sequence (ADC MASTER inj and ADC SLAVE inj) consists of a single channel, CH14 for the master and CH15 for the slave. The 1st trigger (downward arrow) occurs during the conversion of CH3 in the master regular sequence, starting the master injected sequence (CH14). The 2nd trigger (upward arrow) occurs during the conversion of CH15 in the slave injected sequence, starting the slave regular sequence (CH7, CH8, CH9). The 3rd trigger (downward arrow) occurs during the conversion of CH4 in the master regular sequence, starting another master injected sequence (CH14). The 4th trigger (upward arrow) occurs during the conversion of CH15 in the slave injected sequence, starting another slave regular sequence (CH10, CH11). The 5th trigger (downward arrow) occurs during the conversion of CH5 in the master regular sequence, starting another master injected sequence (CH14). The 6th trigger (upward arrow) occurs during the conversion of CH15 in the slave injected sequence, but is ignored because the associated alternate conversion (slave regular sequence) is not complete.

Combined injected simultaneous plus interleaved

This mode is selected by programming bits DUAL[4:0] = 00011.

It is possible to interrupt an interleaved conversion with a simultaneous injected event.

In this case the interleaved conversion is interrupted immediately and the simultaneous injected conversion starts. At the end of the injected sequence the interleaved conversion is resumed. When the interleaved regular conversion resumes, the first regular conversion which is performed is always the master's one. Figure 269, Figure 270 and Figure 271 show the behavior using an example.

Caution: In this mode, it is mandatory to use the Common Data Register to read the regular data with a single read access. On the contrary, master-slave data coherency is not guaranteed.

Figure 269. Interleaved single channel CH0 with injected sequence CH11, CH12

Timing diagram for Figure 269 showing interleaved single channel CH0 with injected sequence CH11, CH12. It illustrates the interaction between ADC1 (master) and ADC2 (slave) channels, including sampling, conversion, and read CDR operations. The diagram shows that when an injected trigger occurs, the slave's current conversion is aborted and the injected sequence (CH11, CH12) is converted instead. Once the injected sequence is complete, the slave resumes its master conversions. A legend indicates that light gray represents sampling and dark gray represents conversion.

ADC1 (master) [CH0] [CH0] [CH0] ... [CH0] [CH0] [CH0]

ADC2 (slave) [CH0] [CH0] [CH0] ... [CH0] [CH0] [CH0]

read CDR

read CDR

Conversions aborted

Injected trigger

Resume (always restart with the master)

Legend:
Sampling Conversion

MS34461V1

Timing diagram for Figure 269 showing interleaved single channel CH0 with injected sequence CH11, CH12. It illustrates the interaction between ADC1 (master) and ADC2 (slave) channels, including sampling, conversion, and read CDR operations. The diagram shows that when an injected trigger occurs, the slave's current conversion is aborted and the injected sequence (CH11, CH12) is converted instead. Once the injected sequence is complete, the slave resumes its master conversions. A legend indicates that light gray represents sampling and dark gray represents conversion.

Figure 270. Two interleaved channels (CH1, CH2) with injected sequence CH11, CH12 - case 1: Master interrupted first

Timing diagram for Figure 270, case 1: Master interrupted first. It shows ADC1 (master) and ADC2 (slave) interleaved channels CH1 and CH2. When an injected trigger occurs, the master's conversion is interrupted, and the slave's conversion is aborted. The injected sequence (CH11, CH12) is then converted. After the injected sequence, the slave resumes its master conversions. A legend indicates that light gray represents sampling and dark gray represents conversion.

ADC1 (master) [CH1] [CH1] [CH1] ... [CH1] [CH1] [CH1]

ADC2 (slave) [CH2] [CH2] [CH2] ... [CH2] [CH2] [CH2]

read CDR

read CDR

Conversions aborted

Injected trigger

Resume (always restart with the master)

Legend:
Sampling Conversion

MS34462V1

Timing diagram for Figure 270, case 1: Master interrupted first. It shows ADC1 (master) and ADC2 (slave) interleaved channels CH1 and CH2. When an injected trigger occurs, the master's conversion is interrupted, and the slave's conversion is aborted. The injected sequence (CH11, CH12) is then converted. After the injected sequence, the slave resumes its master conversions. A legend indicates that light gray represents sampling and dark gray represents conversion.

Figure 271. Two Interleaved channels (CH1, CH2) with injected sequence CH11, CH12 - case 2: Slave interrupted first

Timing diagram for Figure 271, case 2: Slave interrupted first. It shows ADC1 (master) and ADC2 (slave) interleaved channels CH1 and CH2. When an injected trigger occurs, the slave's conversion is interrupted, and the master's conversion is aborted. The injected sequence (CH11, CH12) is then converted. After the injected sequence, the master resumes its conversions. A legend indicates that light gray represents sampling and dark gray represents conversion.

ADC1 (master) [CH1] [CH1] [CH1] ... [CH1] [CH1] [CH1]

ADC2 (slave) [CH2] [CH2] [CH2] ... [CH2] [CH2] [CH2]

read CDR

read CDR

Conversions aborted

Injected trigger

Resume (always restart with the master)

Legend:
Sampling Conversion

MS34463V2

Timing diagram for Figure 271, case 2: Slave interrupted first. It shows ADC1 (master) and ADC2 (slave) interleaved channels CH1 and CH2. When an injected trigger occurs, the slave's conversion is interrupted, and the master's conversion is aborted. The injected sequence (CH11, CH12) is then converted. After the injected sequence, the master resumes its conversions. A legend indicates that light gray represents sampling and dark gray represents conversion.

DMA requests in dual ADC mode

In all dual ADC modes, it is possible to use two DMA channels (one for the master, one for the slave) to transfer the data, like in single mode (refer to Figure 272: DMA Requests in regular simultaneous mode when DAMDF[1:0] = 00 ).

Figure 272. DMA Requests in regular simultaneous mode when DAMDF[1:0] = 00

Timing diagram showing DMA requests in regular simultaneous mode. The diagram illustrates the sequence of events for two ADC channels (Master and Slave) triggered by a common 'Trigger' signal. The Master channel (CH1) and Slave channel (CH2) both perform a conversion. The Master EOC (End of Conversion) and Slave EOC signals are shown. DMA requests are generated from both the Master and Slave ADCs. The Master DMA request is followed by 'DMA reads Master ADC_DR', and the Slave DMA request is followed by 'DMA reads Slave ADC_DR'.

Configuration where each sequence contains only one conversion

MSV31032V2

Timing diagram showing DMA requests in regular simultaneous mode. The diagram illustrates the sequence of events for two ADC channels (Master and Slave) triggered by a common 'Trigger' signal. The Master channel (CH1) and Slave channel (CH2) both perform a conversion. The Master EOC (End of Conversion) and Slave EOC signals are shown. DMA requests are generated from both the Master and Slave ADCs. The Master DMA request is followed by 'DMA reads Master ADC_DR', and the Slave DMA request is followed by 'DMA reads Slave ADC_DR'.

In simultaneous regular and interleaved modes, it is also possible to save one DMA channel and transfer both data using a single DMA channel. For this the DAMDF[1:0] bits must be configured in the ADC12_CCR register:

Example:

Interleaved dual mode: a DMA request is generated each time a new 32-bit data is available:

1st DMA request: \( ADC12\_CDR2[31:0] = MST\_ADC\_DR[31:0] \)

2nd DMA request: \( ADC12\_CDR2[31:0] = SLV\_ADC\_DR[31:0] \)

ADC-converted data items. The slave ADC data take the upper half-word and the master ADC data take the lower half-word.

This mode is used in interleaved mode and in regular simultaneous mode when resolution is ranging from 10 to 16-bit. Any value above 16-bit in the master or the slave converter is truncated to the least 16 significant bits.

Example:

Interleaved dual mode: a DMA request is generated each time 2 data items are available:

1st DMA request: \( ADC12\_CDR[31:0] = SLV\_ADC\_DR[15:0] \mid MST\_ADC\_DR[15:0] \)

2nd DMA request: \( ADC12\_CDR[31:0] = SLV\_ADC\_DR[15:0] \mid MST\_ADC\_DR[15:0] \)

Figure 273. DMA requests in regular simultaneous mode when DAMDF[1:0] = 10

Timing diagram showing ADC Master regular, ADC Master EOC, ADC Slave regular, ADC Slave EOC, DMA request from ADC Master, and DMA request from ADC Slave signals over time. The diagram illustrates two sequences of conversions. In each sequence, a 'Trigger' signal initiates the conversion. The 'ADC Master regular' signal shows a pulse for 'CH1'. The 'ADC Slave regular' signal shows a pulse for 'CH2'. The 'ADC Master EOC' signal goes high when the master conversion is complete. The 'ADC Slave EOC' signal goes high when the slave conversion is complete. The 'DMA request from ADC Master' signal goes high when the master conversion is complete. The 'DMA request from ADC Slave' signal goes high when the slave conversion is complete. The diagram is labeled 'Configuration where each sequence contains only one conversion' and 'MSV31033V3'.

Configuration where each sequence contains only one conversion

MSV31033V3

Timing diagram showing ADC Master regular, ADC Master EOC, ADC Slave regular, ADC Slave EOC, DMA request from ADC Master, and DMA request from ADC Slave signals over time. The diagram illustrates two sequences of conversions. In each sequence, a 'Trigger' signal initiates the conversion. The 'ADC Master regular' signal shows a pulse for 'CH1'. The 'ADC Slave regular' signal shows a pulse for 'CH2'. The 'ADC Master EOC' signal goes high when the master conversion is complete. The 'ADC Slave EOC' signal goes high when the slave conversion is complete. The 'DMA request from ADC Master' signal goes high when the master conversion is complete. The 'DMA request from ADC Slave' signal goes high when the slave conversion is complete. The diagram is labeled 'Configuration where each sequence contains only one conversion' and 'MSV31033V3'.

Figure 274. DMA requests in interleaved mode when DAMDF[1:0] = 10

Timing diagram showing DMA requests in interleaved mode. The diagram illustrates the sequence of events for ADC Master regular, ADC Master EOC, ADC Slave regular, ADC Slave EOC, DMA request from ADC Master, and DMA request from ADC Slave. It shows three triggers for the master ADC, with corresponding conversion blocks (CH1) and EOC signals. Delays are indicated between the EOC of one conversion and the start of the next. The slave ADC conversions (CH2) are interleaved with the master ADC conversions. DMA requests are generated when the EOC signal is active. The diagram is labeled 'Configuration where each sequence contains only one conversion' and 'MSV31034V2'.

Configuration where each sequence contains only one conversion

MSV31034V2

Timing diagram showing DMA requests in interleaved mode. The diagram illustrates the sequence of events for ADC Master regular, ADC Master EOC, ADC Slave regular, ADC Slave EOC, DMA request from ADC Master, and DMA request from ADC Slave. It shows three triggers for the master ADC, with corresponding conversion blocks (CH1) and EOC signals. Delays are indicated between the EOC of one conversion and the start of the next. The slave ADC conversions (CH2) are interleaved with the master ADC conversions. DMA requests are generated when the EOC signal is active. The diagram is labeled 'Configuration where each sequence contains only one conversion' and 'MSV31034V2'.
Note:

When using multiple-ADC mode, the user must take care to configure properly the duration of the master and slave conversions so that a DMA request is generated and served for reading both data (master + slave) before a new conversion is available.

This mode is used in interleaved and regular simultaneous mode when the result is 8-bit. A new DMA request is issued when four new 8-bit values are available.

Example:

Interleaved dual mode: a DMA request is generated each time 2 data items are available

DMA request:

ADC12_CDR[7:0] = MST_ADC_DR[7:0]

ADC12_CDR[15:8] = SLV_ADC_DR[7:0]

ADC12_CDR[31:16] = 0x0

Overrun detection

In dual ADC mode (when DUAL[4:0] is not equal to 0b00000), if an overrun is detected on one of the ADCs, the DMA requests are no longer issued to ensure that all the data transferred to the RAM are valid (this behavior occurs whatever the DAMDF configuration). It may happen that the EOC bit corresponding to one ADC remains set because the data register of this ADC contains valid data.

DMA one shot mode/ DMA circular mode when multiple-ADC mode is selected

When DAMDF mode is selected (10 or 11), bit DMNGT[1:0] = 10 in the master ADC ADC12_CCR register must also be configured to select between DMA one shot mode and circular mode, as explained in section Section : Managing conversions using the DMA .

Stopping the conversions in dual ADC modes

The user must set the control bits ADSTP/JADSTP of the master ADC to stop the conversions of both ADC in dual ADC mode. The other ADSTP control bit of the slave ADC has no effect in dual ADC mode.

Once both ADCs are effectively stopped, the bits ADSTART/JADSTART of the master and slave ADCs are both cleared by hardware.

MDF mode in dual ADC mode interleaved mode

In dual ADC interleaved modes, the ADC conversion results can be transferred directly to the multifunction digital filter (MDF).

This mode is enabled by setting the bits DMNGT[1:0] = 10 in the master ADC ADC_CFGR register.

The ADC transfers alternatively the 16 least significant bits of the regular data register from the master and the slave converter to a single channel of the MDF.

The data format must be 16-bit signed:

ADC_DR[31:16] = 0x0000

ADC_DR[15] = sign

ADC_DR[14:0] = data

Any value above 16-bit signed format in any converter is truncated.

MDF mode in dual ADC simultaneous mode

The dual mode is not required to use MDF in dual ADC simultaneous mode since conversion data are treated by each individual channel. Single mode with same trigger source results in simultaneous conversion with MDF interface.

33.4.32 Temperature sensor

The temperature sensor can measure the device junction temperature ( \( T_j \) ) in the \( -40 \) to \( 125 \) °C temperature range.

The temperature sensor is internally connected ADC input channels that are used to convert the sensor output voltage to a digital value (see Section 33.4.4: ADC connectivity for more details). The sampling time for the temperature sensor analog pin must be greater than the stabilization time specified in the device datasheet.

When it is not in use, the sensor can be placed in power-down mode.

Figure 275 shows the block diagram of the temperature sensor.

Figure 275. Temperature sensor channel block diagram

Figure 275. Temperature sensor channel block diagram. The diagram shows a 'Temperature sensor' block connected to a multiplexer. The multiplexer is controlled by the 'VSENSESEL control bit' and outputs 'V_SENSE' to the 'ADC input' of an 'ADCx' block. The 'ADCx' block outputs 'Converted data' to an 'Address/data bus'. The diagram is labeled 'MSv62477V2' in the bottom right corner.
Figure 275. Temperature sensor channel block diagram. The diagram shows a 'Temperature sensor' block connected to a multiplexer. The multiplexer is controlled by the 'VSENSESEL control bit' and outputs 'V_SENSE' to the 'ADC input' of an 'ADCx' block. The 'ADCx' block outputs 'Converted data' to an 'Address/data bus'. The diagram is labeled 'MSv62477V2' in the bottom right corner.

Reading the temperature

To use the sensor:

  1. 1. Select the input channels to which the temperature sensor is connected (with the appropriate sampling time).
  2. 2. Program with the appropriate sampling time (refer to electrical characteristics section of the device datasheet).
  3. 3. Set the VSENSESEL bit in the ADC12_CCR register to wake up the temperature sensor from power-down mode.
  4. 4. Start the ADC conversion.
  5. 5. Read the resulting data in the ADC data register.
  6. 6. Calculate the actual temperature using the following formula:

\[ \text{Temperature (in } ^\circ\text{C)} = \frac{\text{TS\_CAL2\_TEMP} - \text{TS\_CAL1\_TEMP}}{\text{TS\_CAL2} - \text{TS\_CAL1}} \times (\text{TS\_DATA} - \text{TS\_CAL1}) + \text{TS\_CAL1\_TEMP} \]

Where:

Refer to Section 33.3: ADC implementation for more information on TS_CAL1 and TS_CAL2 calibration points.

Note: The sensor has a startup time after waking from power-down mode and before it can output at the correct level. The ADC also has a startup time after power-on. As a result, to minimize the delay, the ADEN and VSENSESEL bits must be set simultaneously.

33.4.33 \( V_{BAT} \) supply monitoring

The VBATEN bit in the ADC12_CCR register is used to switch to the battery voltage. As the \( V_{BAT} \) voltage can be higher than \( V_{DDA} \) , the VBAT pin is internally connected to a bridge divider by 4 to ensure the correct operation of the ADC. This bridge is automatically enabled when VBATEN is set, to connect \( V_{BAT}/4 \) to the corresponding ADC input channels (see Section 33.4.4: ADC connectivity for more details). As a consequence, the converted digital value is one fourth of the \( V_{BAT} \) voltage. To prevent any unwanted consumption on the battery, it is recommended to enable the bridge divider only when needed, for ADC conversion.

Refer to the electrical characteristics of the device datasheet for the sampling time value to be applied when converting the \( V_{BAT}/4 \) voltage.

Figure 276 shows the block diagram of the \( V_{BAT} \) sensing feature.

Figure 276. \( V_{BAT} \) channel block diagram

Figure 276. VBAT channel block diagram. The diagram shows a VBAT pin connected to a switch controlled by the VBATEN control bit. The switch is connected to a bridge divider consisting of two resistors. The output of the divider is labeled VBAT/4 and is connected to an ADC input. The ADC input is part of an ADCx block, which is connected to an Address/data bus. The bottom of the bridge divider is connected to ground.

The diagram illustrates the internal circuitry for \( V_{BAT} \) monitoring. A VBAT pin is connected to a switch. This switch is controlled by the VBATEN control bit. When the switch is closed, it connects the VBAT pin to a bridge divider made of two resistors. The midpoint of this divider is labeled \( V_{BAT}/4 \) and is connected to an ADC input. The ADC input is part of an ADCx block, which is further connected to an Address/data bus. The bottom of the bridge divider is connected to ground.

Figure 276. VBAT channel block diagram. The diagram shows a VBAT pin connected to a switch controlled by the VBATEN control bit. The switch is connected to a bridge divider consisting of two resistors. The output of the divider is labeled VBAT/4 and is connected to an ADC input. The ADC input is part of an ADCx block, which is connected to an Address/data bus. The bottom of the bridge divider is connected to ground.

Note: The VBATEN bit of the ADC12_CCR register must be set to enable the conversion of the ADC internal channels to which VBAT is connected (see Section 33.4.4: ADC connectivity for more details).

33.4.34 Monitoring the internal voltage reference

The internal voltage reference can be monitored to have a reference point for evaluating the ADC \( V_{REF+} \) voltage level.

Refer to Section 33.4.4: ADC connectivity for details on the ADC input channels to which the internal voltage reference is internally connected.

The sampling time for this channel must be greater than the stabilization time specified in the device datasheet.

Figure 276 shows the block diagram of the \( V_{REFINT} \) sensing feature.

Figure 277. V REFINT channel block diagram Block diagram of the VREFINT channel. An 'Internal power block' outputs VREFINT, which passes through a switch controlled by the 'VREFEN control bit' and enters the 'ADCx' block at the 'ADC input'. The diagram is labeled MSv41033V7 in the bottom right corner.
graph LR; IPB[Internal power block] -- VREFINT --> Switch; Switch --> ADCx[ADCx]; VREFEN[VREFEN control bit] --> Switch; Switch --> AI[ADC input];
Block diagram of the VREFINT channel. An 'Internal power block' outputs VREFINT, which passes through a switch controlled by the 'VREFEN control bit' and enters the 'ADCx' block at the 'ADC input'. The diagram is labeled MSv41033V7 in the bottom right corner.

Note: The VREFEN bit of the ADC12_CCR register must be set to enable the conversion of the ADC internal channels to which VREFINT is connected (see Section 33.4.4: ADC connectivity for more details).

Calculating the actual V REF+ voltage using the internal reference voltage

The V DDA power supply voltage applied to the microcontroller may be subject to variation or not precisely known. The embedded internal voltage reference (V REFINT ) and its calibration data acquired by the ADC during the manufacturing process at V REF+ = 3.0 V can be used to evaluate the actual V REF+ voltage level, if VREF+ pin is connected to a variable V DDA power supply.

The following formula gives the actual V REF+ voltage supplying the device:

\[ V_{REF+} = 3.0 \text{ V} \times VREFINT\_CAL / VREFINT\_DATA \]

Where:

Converting a supply-relative ADC measurement to an absolute voltage value

The ADC is designed to deliver a digital value corresponding to the ratio between the voltage reference \( V_{REF+} \) and the voltage applied on the converted channel. For most application use cases, it is necessary to convert this ratio into a voltage independent of \( V_{DDA} \) . For applications where \( V_{DDA} \) is known and ADC converted values are right-aligned, the following formula can be used to calculate this absolute value:

\[ V_{CHANNELx} = \frac{V_{REF+}}{NUM\_CODES} \times ADC\_DATA \]

For applications where \( V_{DDA} \) value is not known, the internal voltage reference and \( V_{DDA} \) can be replaced by the expression provided in Section : Calculating the actual \( V_{REF+} \) voltage using the internal reference voltage , resulting in the following formula:

\[ V_{CHANNELx} = \frac{3.0\text{ V} \times VREFINT\_CAL \times ADC\_DATA}{VREFINT\_DATA \times NUM\_CODES} \]

Where:

\( VREFINT\_CAL \) is the \( VREFINT \) calibration value (refer to Section 33.3: ADC implementation for the value of \( VREFINT\_CAL \) ).

\( ADC\_DATA \) is the value measured by the ADC on channel x (right-aligned)

\( VREFINT\_DATA \) is the actual \( VREFINT \) output value converted by the ADC

\( NUM\_CODES \) is the number of ADC output codes. For example with 14-bit resolution, it is \( 2^{14} = 16384 \) or with 8-bit resolution, \( 2^8 = 256 \) .

Note: If ADC measurements are done using an output format other than 14-bit right-aligned, all the parameters must first be converted to a compatible format before the calculation is done.

33.5 ADC interrupts

For each ADC, an interrupt can be generated:

Separate interrupt enable bits are available for flexibility.

Table 319. ADC interrupts

Interrupt vectorInterrupt eventEvent flagEnable Control bitInterrupt clear methodExit from Sleep modeExit from Stop 0, Stop 1 and Stop 2 modesExit from Stop 3, Standby modes
ADCADC readyADRDYADRDYIESet by hardware and cleared by softwareYesNoNo
End of conversion of a regular groupEOCEOCIE
End of conversion sequence of a regular groupEOSEOSIE
End of conversion of an injected groupJEOCJEOCIE
End of conversion sequence of an injected groupJEOSJEOSIE
Analog watchdog 1 status bit is setAWD1AWD1IE
Analog watchdog 2 status bit is setAWD2AWD2IE
Analog watchdog 3 status bit is setAWD3AWD3IE
End of sampling phaseEOSMPEOSMPIE
OverrunOVROVRIE

33.6 ADC registers (for each ADC)

Refer to Section 1.2 for a list of abbreviations used in register descriptions.

33.6.1 ADC interrupt and status register (ADC_ISR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.LDO RDYRes.Res.AWD3AWD2AWD1JEOSJEOCOVREOSEOCEOSMPADRDY
rrc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1

Bits 31:13 Reserved, must be kept at reset value.

Bit 12 LDORDY : ADC voltage regulator ready

This bit is set by hardware. It indicates that the ADC internal supply is ready. The ADC is available after \( t_{ADCVREG\_SETUP} \) time.

0: ADC voltage regulator disabled

1: ADC voltage regulator enabled

Bits 11:10 Reserved, must be kept at reset value.

Bit 9 AWD3 : Analog watchdog 3 flag

This bit is set by hardware when the converted voltage crosses the values programmed in the fields LT3[7:0] and HT3[7:0] of ADC_LTR3 & ADC_HTR3 register. It is cleared by software writing 1 to it.

0: No analog watchdog 3 event occurred (or the flag event was already acknowledged and cleared by software)

1: Analog watchdog 3 event occurred

Bit 8 AWD2 : Analog watchdog 2 flag

This bit is set by hardware when the converted voltage crosses the values programmed in the fields LT2[7:0] and HT2[7:0] of ADC_LTR2 & ADC_HTR2 register. It is cleared by software writing 1 to it.

0: No analog watchdog 2 event occurred (or the flag event was already acknowledged and cleared by software)

1: Analog watchdog 2 event occurred

Bit 7 AWD1 : Analog watchdog 1 flag

This bit is set by hardware when the converted voltage crosses the values programmed in the fields LT1[11:0] and HT1[11:0] of ADC_LTR1, & ADC_HTR1 register. It is cleared by software. writing 1 to it.

0: No analog watchdog 1 event occurred (or the flag event was already acknowledged and cleared by software)

1: Analog watchdog 1 event occurred

Bit 6 JEOS : Injected channel end of sequence flag

This bit is set by hardware at the end of the conversions of all injected channels in the group. It is cleared by software writing 1 to it.

0: Injected conversion sequence not complete (or the flag event was already acknowledged and cleared by software)

1: Injected conversions complete

Bit 5 JEOC : Injected channel end of conversion flag

This bit is set by hardware at the end of each injected conversion of a channel when a new data is available in the corresponding ADC_JDRy register. It is cleared by software writing 1 to it or by reading the corresponding ADC_JDRy register

0: Injected channel conversion not complete (or the flag event was already acknowledged and cleared by software)

1: Injected channel conversion complete

Bit 4 OVR : ADC overrun

This bit is set by hardware when an overrun occurs on a regular channel, meaning that a new conversion has completed while the EOC flag was already set. It is cleared by software writing 1 to it.

0: No overrun occurred (or the flag event was already acknowledged and cleared by software)

1: Overrun has occurred

Bit 3 EOS : End of regular sequence flag

This bit is set by hardware at the end of the conversions of a regular sequence of channels. It is cleared by software writing 1 to it.

0: Regular conversions sequence not complete (or the flag event was already acknowledged and cleared by software)

1: Regular conversions sequence complete

Bit 2 EOC : End of conversion flag

This bit is set by hardware at the end of each regular conversion of a channel when a new data is available in the ADC_DR register. It is cleared by software writing 1 to it or by reading the ADC_DR register

0: Regular channel conversion not complete (or the flag event was already acknowledged and cleared by software)

1: Regular channel conversion complete

Bit 1 EOSMP : End of sampling flag

This bit is set by hardware during the conversion of any channel (only for regular channels), at the end of the sampling phase.

0: not at the end of the sampling phase (or the flag event was already acknowledged and cleared by software)

1: End of sampling phase reached

Bit 0 ADRDY : ADC ready

This bit is set by hardware after the ADC has been enabled (bit ADEN = 1) and when the ADC reaches a state where it is ready to accept conversion requests.

It is cleared by software writing 1 to it.

0: ADC not yet ready to start conversion (or the flag event was already acknowledged and cleared by software)

1: ADC is ready to start conversion

33.6.2 ADC interrupt enable register (ADC_IER)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.AWD3 IEAWD2 IEAWD1 IEJEOSIEJEOCIEOVRIEEOSIEEOCIEEOSMP IEADRDY IE
rwrwrwrwrwrwrwrwrwrw

Bits 31:10 Reserved, must be kept at reset value.

Bit 9 AWD3IE : Analog watchdog 3 interrupt enable

This bit is set and cleared by software to enable/disable the analog watchdog 2 interrupt.

0: Analog watchdog 3 interrupt disabled

1: Analog watchdog 3 interrupt enabled

Note: Software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 8 AWD2IE: Analog watchdog 2 interrupt enable

This bit is set and cleared by software to enable/disable the analog watchdog 2 interrupt.

0: Analog watchdog 2 interrupt disabled

1: Analog watchdog 2 interrupt enabled

Note: Software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 7 AWD1IE: Analog watchdog 1 interrupt enable

This bit is set and cleared by software to enable/disable the analog watchdog 1 interrupt.

0: Analog watchdog 1 interrupt disabled

1: Analog watchdog 1 interrupt enabled

Note: Software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 6 JEOSIE: End of injected sequence of conversions interrupt enable

This bit is set and cleared by software to enable/disable the end of injected sequence of conversions interrupt.

0: JEOS interrupt disabled

1: JEOS interrupt enabled. An interrupt is generated when the JEOS bit is set.

Note: Software is allowed to write this bit only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bit 5 JEOCIE: End of injected conversion interrupt enable

This bit is set and cleared by software to enable/disable the end of an injected conversion interrupt.

0: JEOC interrupt disabled.

1: JEOC interrupt enabled. An interrupt is generated when the JEOC bit is set.

Note: Software is allowed to write this bit only when JADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 4 OVRIE: Overrun interrupt enable

This bit is set and cleared by software to enable/disable the Overrun interrupt of a regular conversion.

0: Overrun interrupt disabled

1: Overrun interrupt enabled. An interrupt is generated when the OVR bit is set.

Note: Software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 3 EOSIE: End of regular sequence of conversions interrupt enable

This bit is set and cleared by software to enable/disable the end of regular sequence of conversions interrupt.

0: EOS interrupt disabled

1: EOS interrupt enabled. An interrupt is generated when the EOS bit is set.

Note: Software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 2 EOCIE: End of regular conversion interrupt enable

This bit is set and cleared by software to enable/disable the end of a regular conversion interrupt.

0: EOC interrupt disabled.

1: EOC interrupt enabled. An interrupt is generated when the EOC bit is set.

Note: Software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 1 EOSMPIE : End of sampling flag interrupt enable for regular conversions

This bit is set and cleared by software to enable/disable the end of the sampling phase interrupt for regular conversions.

0: EOSMP interrupt disabled.

1: EOSMP interrupt enabled. An interrupt is generated when the EOSMP bit is set.

Note: Software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 0 ADRDYIE : ADC ready interrupt enable

This bit is set and cleared by software to enable/disable the ADC Ready interrupt.

0: ADRDY interrupt disabled

1: ADRDY interrupt enabled. An interrupt is generated when the ADRDY bit is set.

Note: Software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.3 ADC control register (ADC_CR)

Address offset: 0x08

Reset value: 0x2000 0000

31302928272625242322212019181716
ADCALRes.DEEPPWDADVREG ENCALINDEX[3:0]Res.Res.Res.Res.Res.Res.Res.ADCALLIN
rsrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JADSTPADSTPJADSTARTADSTARTADDISADEN
rsrsrsrsrsrs

Bit 31 ADCAL : ADC calibration

This bit is set by software to start the ADC calibration.

It is cleared by hardware after calibration is complete.

0: Calibration complete

1: Write 1 to calibrate the ADC. Read at 1 means that a calibration in progress.

Note: The software is allowed to launch a calibration by setting ADCAL only when ADEN = 0.

Bit 30 Reserved, must be kept at reset value.

Bit 29 DEEPPWD : Deep-power-down enable

This bit is set and cleared by software to put the ADC in Deep-power-down mode.

0: ADC not in deep-power down

1: ADC in Deep-power-down (default reset state)

Note: The software is allowed to write this bit only when the ADC is disabled (ADCAL = 0, JADSTART = 0, JADSTP = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bit 28 ADVREGEN : ADC voltage regulator enable

This bit is set by software to enable the ADC voltage regulator.

Before performing any operation such as launching a calibration or enabling the ADC, the ADC voltage regulator must first be enabled and the software must wait for the regulator start-up time.

0: ADC Voltage regulator disabled

1: ADC Voltage regulator enabled.

For more details about the ADC voltage regulator enable and disable sequences, refer to

Section 33.4.6: ADC Deep-power-down mode (DEEPPWD) and ADC voltage regulator (ADVREGEN) .

The software can program this bitfield only when the ADC is disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bits 27:24 CALINDEX[3:0] : Calibration factor

This bitfield controls the calibration factor to be read or written.

Calibration index 0 is dedicated to single-ended and differential offsets, calibration index 1 to 7 to the linearity calibration factors, and index 8 to the internal offset:

0000: Offset calibration factor

0001: linearity calibration factor 1

0010: linearity calibration factor 2

0011: linearity calibration factor 3

0100: linearity calibration factor 4

0101: linearity calibration factor 5

0110: linearity calibration factor 6

0111: linearity calibration factor 7 and internal offset (write access only)

1000: internal offset (read access only)

1001: Calibration mode selection

Others: Reserved, must not be used

Note: ADC_CALFACT2[31:0] correspond to the location of CALINDEX[3:0] calibration factor data (see Section 33.4.8: Calibration (ADCAL, ADCALLIN, ADC_CALFACT) for details).

Bits 23:17 Reserved, must be kept at reset value.

Bit 16 ADCALLIN : Linearity calibration

This bit is set and cleared by software to enable the linearity calibration.

0: Writing ADCAL launches a calibration without the linearity calibration.

1: Writing ADCAL launches a calibration with the linearity calibration.

Note: The software is allowed to write this bit only when the ADC is disabled and is not calibrating (ADCAL = 0, JADSTART = 0, JADSTP = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bits 15:6 Reserved, must be kept at reset value.

Bit 5 JADSTP : ADC stop of injected conversion command

This bit is set by software to stop and discard an ongoing injected conversion (JADSTP Command). It is cleared by hardware when the conversion is effectively discarded and the ADC injected sequence and triggers can be re-configured. The ADC is then ready to accept a new start of injected conversions (JADSTART command).

0: No ADC stop injected conversion command ongoing

1: Write 1 to stop injected conversions ongoing. Read 1 means that an ADSTP command is in progress.

Note: The software is allowed to set JADSTP only when JADSTART = 1 and ADDIS = 0 (ADC is enabled and eventually converting an injected conversion and there is no pending request to disable the ADC).

In auto-injection mode (JAUTO = 1), setting ADSTP bit aborts both regular and injected conversions (do not use JADSTP)

Bit 4 ADSTP: ADC stop of regular conversion command

This bit is set by software to stop and discard an ongoing regular conversion (ADSTP Command). It is cleared by hardware when the conversion is effectively discarded and the ADC regular sequence and triggers can be re-configured. The ADC is then ready to accept a new start of regular conversions (ADSTART command).

0: No ADC stop regular conversion command ongoing

1: Write 1 to stop regular conversions ongoing. Read 1 means that an ADSTP command is in progress.

Note: The software is allowed to set ADSTP only when ADSTART = 1 and ADDIS = 0 (ADC is enabled and eventually converting a regular conversion and there is no pending request to disable the ADC).

In auto-injection mode (JAUTO = 1), setting ADSTP bit aborts both regular and injected conversions (do not use JADSTP).

Bit 3 JADSTART: ADC start of injected conversion

This bit is set by software to start ADC conversion of injected channels. Depending on the configuration bits JEXTEN[1:0], a conversion starts immediately (software trigger configuration) or once an injected hardware trigger event occurs (hardware trigger configuration).

It is cleared by hardware:

0: No ADC injected conversion is ongoing.

1: Write 1 to start injected conversions. Read 1 means that the ADC is operating and eventually converting an injected channel.

Note: The software is allowed to set JADSTART only when ADEN = 1 and ADDIS = 0 (ADC is enabled and there is no pending request to disable the ADC).

In auto-injection mode (JAUTO = 1), regular and auto-injected conversions are started by setting bit ADSTART (JADSTART must be kept cleared)

Bit 2 ADSTART: ADC start of regular conversion

This bit is set by software to start ADC conversion of regular channels. Depending on the configuration bits EXTEN[1:0], a conversion starts immediately (software trigger configuration) or once a regular hardware trigger event occurs (hardware trigger configuration).

It is cleared by hardware:

0: No ADC regular conversion is ongoing.

1: Write 1 to start regular conversions. Read 1 means that the ADC is operating and eventually converting a regular channel.

Note: The software is allowed to set ADSTART only when ADEN = 1 and ADDIS = 0 (ADC is enabled and there is no pending request to disable the ADC)

In auto-injection mode (JAUTO = 1), regular and auto-injected conversions are started by setting bit ADSTART (JADSTART must be kept cleared)

Bit 1 ADDIS : ADC disable command

This bit is set by software to disable the ADC (ADDIS command) and put it into power-down state (OFF state).

It is cleared by hardware once the ADC is effectively disabled (ADEN is also cleared by hardware at this time).

0: no ADDIS command ongoing

1: Write 1 to disable the ADC. Read 1 means that an ADDIS command is in progress.

Note: The software is allowed to set ADDIS only when ADEN = 1 and both ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing)

Bit 0 ADEN : ADC enable control

This bit is set by software to enable the ADC. The ADC is effectively ready to operate once the flag ADRDY has been set.

It is cleared by hardware when the ADC is disabled, after the execution of the ADDIS command.

0: ADC is disabled (OFF state)

1: Write 1 to enable the ADC.

Note: The software is allowed to set ADEN only when all bits of ADC_CR registers are 0 (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0) except for bit ADVREGEN which must be 1 (and the software must have wait for the startup time of the voltage regulator)

33.6.4 ADC configuration register (ADC_CFGR1)

Address offset: 0x0C

Reset value: 0x8000 0000

31302928272625242322212019181716
Res.AWD1CH[4:0]JAUTOJAWD1ENAWD1ENAWD1SGLRes.JDISCENDISCNUM[2:0]DISCEN
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
Res.AUTDLYCONTOVRMODEXTEN[1:0]EXTSEL[4:0]Res.RES[1:0]DMNGT[1:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 Reserved, must be kept at reset value.

Bits 30:26 AWD1CH[4:0] : Analog watchdog 1 channel selection

These bits are set and cleared by software. They select the input channel to be guarded by the analog watchdog.

00000: ADC analog input channel-0 monitored by AWD1

00001: ADC analog input channel-1 monitored by AWD1

.....

10011: ADC analog input channel-19 monitored by AWD1

Others: Reserved, must not be used

Note: The channel selected by AWD1CH must be also selected into the SQRI or JSQRI registers. Software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 25 JAUTO: Automatic injected group conversion

This bit is set and cleared by software to enable/disable automatic injected group conversion after regular group conversion.

0: Automatic injected group conversion disabled

1: Automatic injected group conversion enabled

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no regular nor injected conversion is ongoing).

Bit 24 JAWD1EN: Analog watchdog 1 enable on injected channels

This bit is set and cleared by software

0: Analog watchdog 1 disabled on injected channels

1: Analog watchdog 1 enabled on injected channels

Note: The software is allowed to write this bit only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bit 23 AWD1EN: Analog watchdog 1 enable on regular channels

This bit is set and cleared by software

0: Analog watchdog 1 disabled on regular channels

1: Analog watchdog 1 enabled on regular channels

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 22 AWD1SGL: Enable the watchdog 1 on a single channel or on all channels

This bit is set and cleared by software to enable the analog watchdog on the channel identified by the AWD1CH[4:0] bits or on all the channels

0: Analog watchdog 1 enabled on all channels

1: Analog watchdog 1 enabled on a single channel

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 21 Reserved, must be kept at reset value. Bit 20 JDISCEN: Discontinuous mode on injected channels

This bit is set and cleared by software to enable/disable discontinuous mode on the injected channels of a group.

0: Discontinuous mode on injected channels disabled

1: Discontinuous mode on injected channels enabled

Note: The software is allowed to write this bit only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

It is not possible to use both auto-injected mode and discontinuous mode simultaneously: the bits DISCEN and JDISCEN must be kept cleared by software when JAUTO is set.

Bits 19:17 DISCNUM[2:0]: Discontinuous mode channel count

These bits are written by software to define the number of regular channels to be converted in discontinuous mode, after receiving an external trigger.

000: 1 channel

001: 2 channels

...

111: 8 channels

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 16 DISCEN: Discontinuous mode for regular channels

This bit is set and cleared by software to enable/disable discontinuous mode for regular channels.

0: Discontinuous mode for regular channels disabled

1: Discontinuous mode for regular channels enabled

Note: It is not possible to have both discontinuous mode and continuous mode enabled: it is forbidden to set both DISCEN = 1 and CONT = 1.

It is not possible to use both auto-injected mode and discontinuous mode simultaneously: the bits DISCEN and JDISCEN must be kept cleared by software when JAUTO is set.

The software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 15 Reserved, must be kept at reset value. Bit 14 AUTDLY: Delayed conversion mode

This bit is set and cleared by software to enable/disable the auto-delayed conversion mode.

0: Auto-delayed conversion mode off

1: Auto-delayed conversion mode on

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 13 CONT: Single / continuous conversion mode for regular conversions

This bit is set and cleared by software. If it is set, regular conversion takes place continuously until it is cleared.

0: Single conversion mode

1: Continuous conversion mode

Note: It is not possible to have both discontinuous mode and continuous mode enabled: it is forbidden to set both DISCEN = 1 and CONT = 1.

The software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 12 OVRMOD: Overrun Mode

This bit is set and cleared by software and configure the way data overrun is managed.

0: ADC_DR register is preserved with the old data when an overrun is detected.

1: ADC_DR register is overwritten with the last conversion result when an overrun is detected.

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bits 11:10 EXTEN[1:0]: External trigger enable and polarity selection for regular channels

These bits are set and cleared by software to select the external trigger polarity and enable the trigger of a regular group.

00: Hardware trigger detection disabled (conversions can be launched by software)

01: Hardware trigger detection on the rising edge

10: Hardware trigger detection on the falling edge

11: Hardware trigger detection on both the rising and falling edges

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bits 9:5 EXTSEL[4:0] : External trigger selection for regular group

These bits select the external event used to trigger the start of conversion of a regular group:

00000: adc_ext_trg0

00001: adc_ext_trg1

...

Refer to the ADC external trigger for regular channels in Section 33.4.2: ADC pins and internal signals for details on trigger mapping.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 4 Reserved, must be kept at reset value.

Bits 3:2 RES[1:0] : Data resolution

These bits are written by software to select the resolution of the conversion.

00: 14 bits

01: 12 bits

10: 10 bits

11: 8 bits

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bits 1:0 DMNGT[1:0] : Data management configuration

This bit is set and cleared by software to select how the ADC interface output data are managed.

00: Regular conversion data stored in DR only

01: DMA One-shot mode selected

10: MDF mode selected

11: DMA circular mode selected

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.5 ADC configuration register 2 (ADC_CFGR2)

Address offset: 0x10

Reset value: 0x0000 0000

31302928272625242322212019181716
LSHIFT[3:0]Res.Res.OSR[9:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SMPTRIGSWTRIGBULBRes.Res.ROVSMTROVSOVSS[3:0]Res.Res.Res.JOVSE
rwrwrwrwrwrwrwrwrwrwrw
Bits 31:28 LSHIFT[3:0] : Left shift factor

This bitfield is set and cleared by software to define the left shifting applied to the final result with or without oversampling.

0000: No left shift

0001: 1-bit left shift

0010: 2-bit left shift

0011: 3-bit left shift

0100: 4-bit left shift

0101: 5-bit left shift

0110: 6-bit left shift

0111: 7-bit left shift

1000: 8-bit left shift

1001: 9-bit left shift

1010: 10-bit left shift

1011: 11-bit left shift

1100: 12-bit left shift

1101: 13-bit left shift

1110: 14-bit left shift

1111: 15-bit left shift

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bits 27:26 Reserved, must be kept at reset value.

Bits 25:16 OSR[9:0] : Oversampling ratio

This bitfield is set and cleared by software to define the oversampling ratio.

0: 1x (no oversampling)

1: 2x

2: 3x

...

1023: 1024x

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bit 15 SMPTRIG : Sampling time control trigger mode

This bit is set and cleared by software to enable the sampling time control trigger mode.

0: Sampling time control trigger mode disabled

1: Sampling time control trigger mode enabled

The sampling time starts on the trigger rising edge, and the conversion on the trigger falling edge.

EXTEN[1:0] bits must be set to 01. BULB bit must not be set when the SMPTRIG bit is set.

When EXTEN[1:0] bits is set to 00, set SWTRIG to start the sampling and clear SWTRIG bit to start the conversion.

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bit 14 SWTRIG : Software trigger bit for sampling time control trigger mode

This bit is set and cleared by software to enable the bulb sampling mode.

0: Software trigger starts the conversion for sampling time control trigger mode

1: Software trigger starts the sampling for sampling time control trigger mode.

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bit 13 BULB : Bulb sampling mode

This bit is set and cleared by software to select the bulb sampling mode.

0: Bulb sampling mode disabled

1: Bulb sampling mode enabled. The sampling period starts just after the previous end of the conversion.

SMPTRIG bit must not be set when the BULB bit is set.

The very first ADC conversion is performed with the sampling time specified in SMPx bits.

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bits 12:11 Reserved, must be kept at reset value.

Bit 10 ROVSM : Regular oversampling mode

This bit is set and cleared by software to select the regular oversampling mode.

0: Continued mode: When injected conversions are triggered, the oversampling is temporary stopped and continued after the injection sequence (oversampling buffer is maintained during injected sequence)

1: Resumed mode: When injected conversions are triggered, the current oversampling is aborted and resumed from start after the injection sequence (oversampling buffer is zeroed by injected sequence start)

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bit 9 TROVS : Triggered regular oversampling

This bit is set and cleared by software to enable triggered oversampling

0: All oversampled conversions for a channel are done consecutively following a trigger

1: Each oversampled conversion for a channel needs a new trigger

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bits 8:5 OVSS[3:0] : Oversampling right shift

This bitfield is set and cleared by software to define the right shifting applied to the raw oversampling result.

0000: No right shift

0001: 1-bit right shift

0010: 2-bit right shift

0011: 3-bit right shift

0100: 4-bit right shift

0101: 5-bit right shift

0110: 6-bit right shift

0111: 7-bit right shift

1000: 8-bit right shift

1001: 9-bit right shift

1010: 10-bit right shift

Others: Reserved, must not be used.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bits 4:2 Reserved, must be kept at reset value.

Bit 1 JOVSE : Injected oversampling enable

This bit is set and cleared by software to enable injected oversampling.

0: Injected oversampling disabled

1: Injected oversampling enabled

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing)

Bit 0 ROVSE : Regular oversampling enable

This bit is set and cleared by software to enable regular oversampling.

0: Regular oversampling disabled

1: Regular oversampling enabled

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing)

33.6.6 ADC sample time register 1 (ADC_SMPR1)

Address offset: 0x14

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.SMP9[2:0]SMP8[2:0]SMP7[2:0]SMP6[2:0]SMP5[2:1]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SMP5[0]SMP4[2:0]SMP3[2:0]SMP2[2:0]SMP1[2:0]SMP0[2:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 29:0 SMPx[2:0] : Channel x sampling time selection (x = 9 to 0)

These bits are written by software to select the sampling time individually for each channel.

During sample cycles, the channel selection bits must remain unchanged.

000: 5 ADC clock cycles

001: 6 ADC clock cycles

010: 12 ADC clock cycles

011: 20 ADC clock cycles

100: 36 ADC clock cycles

101: 68 ADC clock cycles

110: 391 ADC clock cycles

111: 814 ADC clock cycles

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.7 ADC sample time register 2 (ADC_SMPR2)

Address offset: 0x18

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.SMP19[2:0]SMP18[2:0]SMP17[2:0]SMP16[2:0]SMP15[2:1]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SMP15[0]SMP14[2:0]SMP13[2:0]SMP12[2:0]SMP11[2:0]SMP10[2:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 29:0 SMPx[2:0] : Channel x sampling time selection (x = 19 to 10)

These bits are written by software to select the sampling time individually for each channel. During sampling cycles, the channel selection bits must remain unchanged.

000: 5 ADC clock cycles

001: 6 ADC clock cycles

010: 12 ADC clock cycles

011: 20 ADC clock cycles

100: 36 ADC clock cycles

101: 68 ADC clock cycles

110: 391 ADC clock cycles

111: 814 ADC clock cycles

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.8 ADC channel preselection register (ADC_PCSEL)

Address offset: 0x1C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PCSEL1
9
PCSEL1
8
PCSEL1
7
PCSEL1
6
rwrwrwrw
1514131211109876543210
PCSEL
L15
PCSEL
L14
PCSEL
L13
PCSEL
L12
PCSEL
L11
PCSEL
L10
PCSEL
9
PCSEL
8
PCSEL
7
PCSEL
6
PCSEL
5
PCSEL
4
PCSEL3PCSEL2PCSEL1PCSEL0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 PCSEL[19:0] : Channel i ( \( V_{INP}[i] \) ) preselection

These bits are written by software to preselect the input channel I/O instance to be converted.

0: Input channel i ( \( V_{INP}[i] \) ) is not preselected for conversion, the ADC conversion of this channel shows a wrong result.

1: Input channel i ( \( V_{INP}[i] \) ) is preselected for conversion

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.9 ADC regular sequence register 1 (ADC_SQR1)

Address offset: 0x30

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.SQ4[4:0]Res.SQ3[4:0]Res.SQ2[4]
rwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SQ2[3:0]Res.SQ1[4:0]Res.Res.L[3:0]
rwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 Reserved, must be kept at reset value.

Bits 28:24 SQ4[4:0] : 4th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 4th in the regular conversion sequence.

Bit 23 Reserved, must be kept at reset value.

Bits 22:18 SQ3[4:0] : 3rd conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 3rd in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 17 Reserved, must be kept at reset value.

Bits 16:12 SQ2[4:0] : 2nd conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 2nd in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 11 Reserved, must be kept at reset value.

Bits 10:6 SQ1[4:0] : 1st conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 1st in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bits 5:4 Reserved, must be kept at reset value.

Bits 3:0 L[3:0] : Regular channel sequence length

These bits are written by software to define the total number of conversions in the regular channel conversion sequence.

0000: 1 conversion

0001: 2 conversions

...

1111: 16 conversions

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

33.6.10 ADC regular sequence register 2 (ADC_SQR2)

Address offset: 0x34

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.SQ9[4:0]Res.SQ8[4:0]Res.SQ7[4]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
SQ7[3:0]Res.SQ6[4:0]Res.SQ5[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 Reserved, must be kept at reset value.

Bits 28:24 SQ9[4:0] : 9th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 9th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 23 Reserved, must be kept at reset value.

Bits 22:18 SQ8[4:0] : 8th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 8th in the regular conversion sequence

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 17 Reserved, must be kept at reset value.

Bits 16:12 SQ7[4:0] : 7th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 7th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 11 Reserved, must be kept at reset value.

Bits 10:6 SQ6[4:0] : 6th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 6th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 5 Reserved, must be kept at reset value.

Bits 4:0 SQ5[4:0] : 5th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 5th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

33.6.11 ADC regular sequence register 3 (ADC_SQR3)

Address offset: 0x38

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.SQ14[4:0]Res.SQ13[4:0]Res.SQ12[4]
rwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
SQ12[3:0]Res.SQ11[4:0]Res.SQ10[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 Reserved, must be kept at reset value.

Bits 28:24 SQ14[4:0] : 14th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 14th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 23 Reserved, must be kept at reset value.

Bits 22:18 SQ13[4:0] : 13th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 13th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 17 Reserved, must be kept at reset value.

Bits 16:12 SQ12[4:0] : 12th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 12th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 11 Reserved, must be kept at reset value.

Bits 10:6 SQ11[4:0] : 11th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 11th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 5 Reserved, must be kept at reset value.

Bits 4:0 SQ10[4:0] : 10th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 10th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

33.6.12 ADC regular sequence register 4 (ADC_SQR4)

Address offset: 0x3C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.SQ16[4:0]Res.SQ15[4:0]
rwrwrwrwrwrwrwrwrwrw

Bits 31:11 Reserved, must be kept at reset value.

Bits 10:6 SQ16[4:0] : 16th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 16th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

Bit 5 Reserved, must be kept at reset value.

Bits 4:0 SQ15[4:0] : 15th conversion in regular sequence

These bits are written by software with the channel number (0..19) assigned as the 15th in the regular conversion sequence.

Note: The software is allowed to write these bits only when ADSTART = 0 (which ensures that no regular conversion is ongoing).

33.6.13 ADC regular data register (ADC_DR)

Address offset: 0x40

Reset value: 0x0000 0000

31302928272625242322212019181716
RDATA[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
RDATA[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 RDATA[31:0] : Regular data converted

These bits are read-only. They contain the conversion result from the last converted regular channel. The data are left- or right-aligned as described in Section 33.4.26: Data management .

33.6.14 ADC injected sequence register (ADC_JSQR)

Address offset: 0x4C

Reset value: 0x0000 0000

31302928272625242322212019181716
JSQ4[4:0]Res.JSQ3[4:0]Res.JSQ2[4:1]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
JSQ2[0]Res.JSQ1[4:0]JEXTEN[1:0]JEXTSEL[4:0]JL[1:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:27 JSQ4[4:0] : 4th conversion in the injected sequence

These bits are written by software with the channel number (0..19) assigned as the 4th in the injected conversion sequence.

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bit 26 Reserved, must be kept at reset value.

Bits 25:21 JSQ3[4:0] : 3rd conversion in the injected sequence

These bits are written by software with the channel number (0..19) assigned as the 3rd in the injected conversion sequence.

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bit 20 Reserved, must be kept at reset value.

Bits 19:15 JSQ2[4:0] : 2nd conversion in the injected sequence

These bits are written by software with the channel number (0..19) assigned as the 2nd in the injected conversion sequence.

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bit 14 Reserved, must be kept at reset value.

Bits 13:9 JSQ1[4:0] : 1st conversion in the injected sequence

These bits are written by software with the channel number (0..19) assigned as the 1st in the injected conversion sequence.

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bits 8:7 JEXTEN[1:0] : External trigger enable and polarity selection for injected channels

These bits are set and cleared by software to select the external trigger polarity and enable the trigger of an injected group.

00: Hardware trigger detection disabled (conversions can be launched by software)

01: Hardware trigger detection on the rising edge

10: Hardware trigger detection on the falling edge

11: Hardware trigger detection on both the rising and falling edges

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bits 6:2 JEXTSEL[4:0] : External trigger selection for injected group

These bits select the external event used to trigger the start of conversion of an injected group:

00000: adc_jext_trg0
00001: adc_jext_trg1
...

Refer to the ADC external trigger for injected channels in Section 33.4.2: ADC pins and internal signals for details on trigger mapping.

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

Bits 1:0 JL[1:0] : Injected channel sequence length

These bits are written by software to define the total number of conversions in the injected channel conversion sequence.

00: 1 conversion
01: 2 conversions
10: 3 conversions
11: 4 conversions

Note: The software is allowed to write these bits only when JADSTART = 0 (which ensures that no injected conversion is ongoing).

33.6.15 ADC offset y register (ADC_OFRy)

Address offset: \( 0x60 + 0x04 * (y - 1) \) , ( \( y = 1 \) to 4)

Reset value: 0x0000 0000

31302928272625242322212019181716
OFFSET_CH[4:0]SSATUSATPOSOFFOFFSET[23:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
OFFSET[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:27 OFFSET_CH[4:0] : Channel selection for the data offset y

These bits are written by software to define the channel to which the offset programmed into OFFSETy[25:0] bits applies.

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

If OFFSETy_EN bit is set, it is not allowed to select the same channel in different ADC_OFRy registers.

Bit 26 SSAT : Signed saturation enable

This bit is written by software to enable or disable the Signed saturation feature.

(see Section : Data register, data alignment and offset (ADC_DR, ADC_JDRy, OFFSETy, OFFSETy_CH, OVSS, LSHIFT, USAT, SSAT) for details).

0: Offset is subtracted maintaining data integrity and extending converted data size (9-bit and 15-bit signed format).
1: Offset is subtracted and result is saturated to maintain converted data size.

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 25 USAT : Unsigned saturation enable

This bit is written by software to enable or disable the unsigned saturation feature.

0: Offset is subtracted maintaining data integrity and keeping converted data size

1: Offset is subtracted and result is saturated to maintain converted data size.

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bit 24 POSOFF : offset sign

This bit is set and cleared by software to enable the positive offset.

0: Negative offset

1: Positive offset

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bits 23:0 OFFSET[23:0] : Data offset y for the channel programmed into OFFSETy_CH[4:0] bits

These bits are written by software to define the offset y to be subtracted from the raw converted data when converting a channel (regular or injected). The channel to which the data offset y applies must be programmed to the OFFSETy_CH[4:0] bits. The conversion result can be read from in the ADC_DR (regular conversion) or from in the ADC_JDRyi registers (injected conversion).

When OFFSETy[21:0] bitfield is reset, the offset compensation is disabled.

Note: The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

If several offsets (OFFSETy) point to the same channel, only the offset with the lowest y value is considered for the subtraction.

For example, if OFFSET1_CH[4:0] = 4 and OFFSET2_CH[4:0] = 4, this is OFFSET1[25:0] that is subtracted when converting channel 4.

33.6.16 ADC gain compensation register (ADC_GCOMP)

Address offset: 0x70

Reset value: 0x0000 0000

31302928272625242322212019181716
GCOMPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rw

1514131211109876543210
Res.Res.GCOMPCOEFF[13:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 GCOMP : Gain compensation mode

This bit is set and cleared by software to enable the gain compensation mode.

0: Regular ADC operating mode

1: Gain compensation enabled and applied on all channels

Note: The software is allowed to write this bit only when ADSTART = 0 (which ensures that no conversion is ongoing).

Bits 30:14 Reserved, must be kept at reset value.

Bits 13:0 GCOMPcoeff[13:0] : Gain compensation coefficient

These bits are set and cleared by software to program the gain compensation coefficient.

00 1000 0000 0000: gain factor of 0.5

...

01 0000 0000 0000: gain factor of 1

10 0000 0000 0000: gain factor of 2

11 0000 0000 0000: gain factor of 3

...

The coefficient is divided by 4096 to get the gain factor ranging from 0 to 3.999756.

Note: This gain compensation is only applied when GCOMP bit of ADCx_CFG2 register is 1.

33.6.17 ADC injected data register (ADC_JDRy)

Address offset: 0x80 + 0x04 * (y - 1), (y= 1 to 4)

Reset value: 0x0000 0000

31302928272625242322212019181716
JDATA[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
JDATA[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 JDATA[31:0] : Injected data

These bits are read-only. They contain the conversion result from injected channel y. The data are left -or right-aligned as described in Section 33.4.26: Data management .

33.6.18 ADC analog watchdog 2 configuration register (ADC_AWD2CR)

Address offset: 0xA0

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD2CH[19:16]
rwrwrwrw
1514131211109876543210
AWD2CH[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 AWD2CH[19:0] : Analog watchdog 2 channel selection

These bits are set and cleared by software. They enable and select the input channels to be guarded by the analog watchdog 2.

AWD2CH[i] = 0: ADC analog input channel-i is not monitored by AWD2

AWD2CH[i] = 1: ADC analog input channel-i is monitored by AWD2

When AWD2CH[19:0] = 000..0, the analog Watchdog 2 is disabled

Note: The channels selected by AWD2CH must be also selected into the SQRi or JSQRi registers.

Software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.19 ADC analog watchdog 3 configuration register (ADC_AWD3CR)

Address offset: 0xA4

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3CH[19:16]
rwrwrwrw
1514131211109876543210
AWD3CH[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 AWD3CH[19:0] : Analog watchdog 3 channel selection

These bits are set and cleared by software. They enable and select the input channels to be guarded by the analog watchdog 3.

AWD3CH[i] = 0: ADC analog input channel-i is not monitored by AWD3

AWD3CH[i] = 1: ADC analog input channel-i is monitored by AWD3

When AWD3CH[19:0] = 000..0, the analog Watchdog 3 is disabled

Note: The channels selected by AWD3CH must be also selected into the SQRi or JSQRi registers.

The software is allowed to write these bits only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

33.6.20 ADC watchdog threshold register 1 (ADC_LTR1)

Address offset: 0xA8

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.LTR1[24:16]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
LTR1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 LTR1[24:0] : Analog watchdog 1 lower threshold

These bits are written by software to define the lower threshold for the analog watchdog 1.

Refer to Section 33.4.29: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy) .

33.6.21 ADC watchdog threshold register 1 (ADC_HTR1)

Address offset: 0xAC

Reset value: 0x01FF FFFF

31302928272625242322212019181716
AWDFILT1[2:0]Res.Res.Res.Res.HTR1[24:16]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
HTR1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 AWDFILT1[2:0] : Analog watchdog filtering parameter

This bit is set and cleared by software.

000: No filtering

001: two consecutive detection generates an AWDx flag or an interrupt

...

111: Eight consecutive detection generates an AWDx flag or an interrupt

Note: The software is allowed to write this bit only when ADSTART = 0 and JADSTART = 0 (which ensures that no conversion is ongoing).

Bits 28:25 Reserved, must be kept at reset value.

Bits 24:0 HTR1[24:0] : Analog watchdog 1 higher threshold

These bits are written by software to define the higher threshold for the analog watchdog 1.

Refer to Section 33.4.29: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy) .

33.6.22 ADC watchdog lower threshold register 2 (ADC_LTR2)

Address offset: 0xB0

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.LTR2[24:16]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
LTR2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 LTR2[24:0] : Analog watchdog 2 lower threshold

These bits are written by software to define the lower threshold for the analog watchdog 2.

Refer to Section 33.4.29: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy) .

33.6.23 ADC watchdog higher threshold register 2 (ADC_HTR2)

Address offset: 0xB4

Reset value: 0x01FF FFFF

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.HTR2[24:16]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
HTR2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 HTR2[24:0] : Analog watchdog 2 higher threshold

These bits are written by software to define the higher threshold for the analog watchdog 2.

Refer to Section 33.4.29: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy) .

33.6.24 ADC watchdog lower threshold register 3 (ADC_LTR3)

Address offset: 0xB8

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.LTR3[24:16]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
LTR3[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 LTR3[24:0] : Analog watchdog 3 lower threshold

These bits are written by software to define the lower threshold for the analog watchdog 3.

Refer to Section 33.4.29: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy) .

33.6.25 ADC watchdog higher threshold register 3 (ADC_HTR3)

Address offset: 0xBC

Reset value: 0x01FF FFFF

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.HTR3[24:16]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
HTR3[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:0 HTR3[24:0] : Analog watchdog 3 higher threshold

These bits are written by software to define the higher threshold for the analog watchdog 3.

Refer to Section 33.4.29: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTRy, AWD_LTRy, AWDy) .

33.6.26 ADC differential mode selection register (ADC_DIFSEL)

Address offset: 0xC0

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DIFSEL[19:16]
rwrwrwrw
1514131211109876543210
DIFSEL[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 DIFSEL[19:0] : Differential mode for channels 19 to 0

These bits are set and cleared by software. They allow selecting if a channel is configured as single-ended or differential mode.

DIFSEL[i] = 0: ADC analog input channel-i is configured in single-ended mode

DIFSEL[i] = 1: ADC analog input channel-i is configured in differential mode

Note: The software is allowed to write these bits only when the ADC is disabled (ADCAL = 0, JADSTART = 0, JADSTP = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

33.6.27 ADC user control register (ADC_CALFACT)

Address offset: 0xC4

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.CAPTURE
_COEF
LATCH
_COEF
Res.Res.Res.Res.Res.Res.Res.VALIDITY
rwrwr

1514131211109876543210
I_APB_DATA[7:0]I_APB_ADDR[7:0]
rrrrrrrrrrrrrrrr

Bits 31:26 Reserved, must be kept at reset value.

Bit 25 CAPTURE_COEF : Calibration factor capture enable bit

Bit 24 LATCH_COEF : Calibration factor latch enable bit

Bits 23:17 Reserved, must be kept at reset value.

Bit 16 VALIDITY : Delayed write access status bit

Bits 15:8 I_APB_DATA[7:0] : Delayed write access data

This bitfield contains the data that are being written during delayed write accesses.

Bits 7:0 I_APB_ADDR[7:0] : Delayed write access address

This bitfield contains the address that is being written during delayed write accesses.

33.6.28 ADC calibration factor register (ADC_CALFACT2)

Address offset: 0xC8

Reset value: 0x0000 0000

31302928272625242322212019181716
CALFACT[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
CALFACT[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 CALFACT[31:0] : Linearity or offset calibration factor

These bits can be written either by hardware or by software.

They contain the 32-bit offset or linearity calibration factor.

When CAPTURE_COEF is set, the calibration factor of the analog block is read back and stored in CALFACT[31:0], indexed by CALINDEX[3:0] bits.

When LATCH_COEF is set, the calibration factor of the analog block is updated with the value programmed in CALFACT[31:0], indexed by CALINDEX[3:0] bits.

To read all calibration factors, perform nine accesses to the ADC_CALFACT2 register.

To write all calibration factors, perform eight accesses to the ADC_CALFACT2 register.

Note: The software is allowed to write these bits only when ADEN = 1, ADSTART = 0 and JADSTART = 0 (ADC is enabled and no calibration is ongoing and no conversion is ongoing).

33.7 ADC common registers

These registers define the control and status registers common to master and slave ADCs.

33.7.1 ADC common status register (ADC12_CSR)

Address offset: 0x00

Reset value: 0x0000 0000

The address offset is relative to the master ADC base address + 0x300.

This register provides an image of the status bits of the different ADCs. Nevertheless, it is read-only and does not clear the different status bits. Instead, each status bit must be cleared by writing 1 to it in the corresponding ADC_ISR register.

ADC1 and ADC2 are controlled by the same interface.

This register is available only the devices that support dual mode (see Section 33.3: ADC implementation ).

31302928272625242322212019181716
Res.Res.Res.LDORDY
_SLV
Res.Res.AWD3
_SLV
AWD2
_SLV
AWD1
_SLV
JEOS
_SLV
JEOC
_SLV
OVR
_SLV
EOS
_SLV
EOC
_SLV
EOSMP
_SLV
ADRDY
_SLV
rrrrrrrrrrr
1514131211109876543210
Res.Res.Res.LDORDY
_MST
Res.Res.AWD3
_MST
AWD2
_MST
AWD1
_MST
JEOS
_MST
JEOC
_MST
OVR
_MST
EOS
_MST
EOC
_MST
EOSMP
_MST
ADRDY
_MST
rrrrrrrrrrr

Bits 31:29 Reserved, must be kept at reset value.

Bit 28 LDORDY_SLV : ADC voltage regulator ready flag of the slave ADC

This bit is a copy of the LDORDY bit of the corresponding ADCx+1_ISR register.

Bits 27:26 Reserved, must be kept at reset value.

Bit 25 AWD3_SLV : Analog watchdog 3 flag of the slave ADC

This bit is a copy of the AWD3 bit in the corresponding ADCx+1_ISR register.

Bit 24 AWD2_SLV : Analog watchdog 2 flag of the slave ADC

This bit is a copy of the AWD2 bit in the corresponding ADCx+1_ISR register.

  1. Bit 23 AWD1_SLV : Analog watchdog 1 flag of the slave ADC
    This bit is a copy of the AWD1 bit in the corresponding ADCx+1_ISR register.
  2. Bit 22 JEOS_SLV : End of injected sequence flag of the slave ADC
    This bit is a copy of the JEOS bit in the corresponding ADCx+1_ISR register.
  3. Bit 21 JEOC_SLV : End of injected conversion flag of the slave ADC
    This bit is a copy of the JEOC bit in the corresponding ADCx+1_ISR register.
  4. Bit 20 OVR_SLV : Overrun flag of the slave ADC
    This bit is a copy of the OVR bit in the corresponding ADCx+1_ISR register.
  5. Bit 19 EOS_SLV : End of regular sequence flag of the slave ADC
    This bit is a copy of the EOS bit in the corresponding ADCx+1_ISR register.
  6. Bit 18 EOC_SLV : End of regular conversion of the slave ADC
    This bit is a copy of the EOC bit in the corresponding ADCx+1_ISR register.
  7. Bit 17 EOSMP_SLV : End of sampling phase flag of the slave ADC
    This bit is a copy of the EOSMP2 bit in the corresponding ADCx+1_ISR register.
  8. Bit 16 ADRDY_SLV : Slave ADC ready
    This bit is a copy of the ADRDY bit in the corresponding ADCx+1_ISR register.
  9. Bits 15:13 Reserved, must be kept at reset value.
  10. Bit 12 LDORDY_MST : ADC voltage regulator ready flag of the master ADC
    This bit is a copy of the LDORDY bit of the corresponding ADC_ISR register.
  11. Bits 11:10 Reserved, must be kept at reset value.
  12. Bit 9 AWD3_MST : Analog watchdog 3 flag of the master ADC
    This bit is a copy of the AWD3 bit in the corresponding ADC_ISR register.
  13. Bit 8 AWD2_MST : Analog watchdog 2 flag of the master ADC
    This bit is a copy of the AWD2 bit in the corresponding ADC_ISR register.
  14. Bit 7 AWD1_MST : Analog watchdog 1 flag of the master ADC
    This bit is a copy of the AWD1 bit in the corresponding ADC_ISR register.
  15. Bit 6 JEOS_MST : End of injected sequence flag of the master ADC
    This bit is a copy of the JEOS bit in the corresponding ADC_ISR register.
  16. Bit 5 JEOC_MST : End of injected conversion flag of the master ADC
    This bit is a copy of the JEOC bit in the corresponding ADC_ISR register.
  17. Bit 4 OVR_MST : Overrun flag of the master ADC
    This bit is a copy of the OVR bit in the corresponding ADC_ISR register.
  18. Bit 3 EOS_MST : End of regular sequence flag of the master ADC
    This bit is a copy of the EOS bit in the corresponding ADC_ISR register.
  19. Bit 2 EOC_MST : End of regular conversion of the master ADC
    This bit is a copy of the EOC bit in the corresponding ADC_ISR register.
  20. Bit 1 EOSMP_MST : End of Sampling phase flag of the master ADC
    This bit is a copy of the EOSMP bit in the corresponding ADC_ISR register.
  21. Bit 0 ADRDY_MST : Master ADC ready
    This bit is a copy of the ADRDY bit in the corresponding ADC_ISR register.

33.7.2 ADC system control register (ADC12_CCR)

Address offset: 0x08

Reset value: 0x0000 0000

The address offset is relative to the master ADC base address + 0x300.

ADC12_CCR is common to ADC1 and ADC2. ADC2 is not available on all devices (refer to Section 33.3: ADC implementation ).

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.VBATENVSENSE
SEL
VREFENPRESC[3:0]Res.Res.
rwrwrwrwrwrwrw
1514131211109876543210
1514131211109876543210
DAMDF[1:0]Res.Res.DELAY[3:0]Res.Res.Res.DUAL[4:0]
rwrwrwrwrwrwrwrwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bit 24 VBATEN : VBAT enable

This bit is set and cleared by software to control the V BAT channel.

0: V BAT channel disabled

1: V BAT channel enabled

Note: The software is allowed to write this bit only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bit 23 VSENSESEL : Temperature sensor voltage selection

This bit is set and cleared by software to control the temperature sensor channel.

0: Temperature sensor channel disabled

1: Temperature sensor channel enabled

Note: The software is allowed to write this bit only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bit 22 VREFEN : V REFINT enable

This bit is set and cleared by software to enable/disable the V REFINT buffer.

0: V REFINT channel disabled

1: V REFINT channel enabled

Note: The software is allowed to write this bit only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bits 21:18 PRESC[3:0] : ADC prescaler

These bits are set and cleared by software to select the frequency of the ADC clock. The clock is common to all ADCs.

0000: input ADC clock not divided

0001: input ADC clock divided by 2

0010: input ADC clock divided by 4

0011: input ADC clock divided by 6

0100: input ADC clock divided by 8

0101: input ADC clock divided by 10

0110: input ADC clock divided by 12

0111: input ADC clock divided by 16

1000: input ADC clock divided by 32

1001: input ADC clock divided by 64

1010: input ADC clock divided by 128

1011: input ADC clock divided by 256

Others: Reserved, must not be used

Note: The software is allowed to write this bit only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bits 17:16 Reserved, must be kept at reset value.

Bits 15:14 DAMDF[1:0] : Dual ADC mode data format

This bit-field is set and cleared by software. It specifies the data format in the common data register ADC12_CDR.

00: Dual ADC mode without data packing (ADC12_CDR and ADC12_CDR2 registers not used).

01: Reserved.

10: Data formatting mode for 32 down to 10-bit resolution

11: Data formatting mode for 8-bit resolution

Note: This register is available only the devices that support dual mode (see Section 33.3: ADC implementation ).

The software is allowed to write these bits only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bits 13:12 Reserved, must be kept at reset value.

Bits 11:8 DELAY[3:0] : Delay between the end of the master ADC sampling phase and the beginning of the slave ADC sampling phase.

These bits are set and cleared by software. These bits are used in dual interleaved modes. Refer to Table 320 for the value of ADC resolution versus DELAY bits values.

Note: This register is available only the devices that support dual mode (see Section 33.3: ADC implementation ).

The software is allowed to write these bits only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bits 7:5 Reserved, must be kept at reset value.

Bits 4:0 DUAL[4:0] : Dual ADC mode selection

These bits are written by software to select the operating mode.

All the ADCs are independent:

00000: Independent mode

The configurations 00001 to 01001 correspond to the following operating modes: dual mode, master and slave ADCs working together:

00001: Combined regular simultaneous + injected simultaneous mode

00010: Combined regular simultaneous + alternate trigger mode

00011: Combined interleaved mode + injected simultaneous mode

00100: Reserved.

00101: Injected simultaneous mode only

00110: Regular simultaneous mode only

00111: Interleaved mode only

01001: Alternate trigger mode only

All other combinations are reserved and must not be programmed

Note: This register is available only the devices that support dual mode (see Section 33.3: ADC implementation ).

The software is allowed to write these bits only when the ADCs are disabled (ADCAL = 0, JADSTART = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Table 320. DELAY bits versus ADC resolution

DELAY bits14-bit resolution12-bit resolution10-bit resolution8-bit resolution
0000\( 1 * F_{adc\_ker\_ck} \)\( 1 * F_{adc\_ker\_ck} \)\( 1 * F_{adc\_ker\_ck} \)\( 1 * F_{adc\_ker\_ck} \)
0001\( 2 * F_{adc\_ker\_ck} \)\( 2 * F_{adc\_ker\_ck} \)\( 2 * F_{adc\_ker\_ck} \)\( 2 * F_{adc\_ker\_ck} \)
0010\( 3 * F_{adc\_ker\_ck} \)\( 3 * F_{adc\_ker\_ck} \)\( 3 * F_{adc\_ker\_ck} \)\( 3 * F_{adc\_ker\_ck} \)
0011\( 4 * F_{adc\_ker\_ck} \)\( 4 * F_{adc\_ker\_ck} \)\( 4 * F_{adc\_ker\_ck} \)\( 4 * F_{adc\_ker\_ck} \)
0100\( 5 * F_{adc\_ker\_ck} \)\( 5 * F_{adc\_ker\_ck} \)\( 5 * F_{adc\_ker\_ck} \)\( 5 * F_{adc\_ker\_ck} \)
0101\( 6 * F_{adc\_ker\_ck} \)\( 6 * F_{adc\_ker\_ck} \)\( 6 * F_{adc\_ker\_ck} \)\( 6 * F_{adc\_ker\_ck} \)
0110\( 7 * F_{adc\_ker\_ck} \)\( 7 * F_{adc\_ker\_ck} \)\( 7 * F_{adc\_ker\_ck} \)\( 7 * F_{adc\_ker\_ck} \)
0111\( 8 * F_{adc\_ker\_ck} \)\( 8 * F_{adc\_ker\_ck} \)\( 8 * F_{adc\_ker\_ck} \)\( 8 * F_{adc\_ker\_ck} \)
1000\( 9 * F_{adc\_ker\_ck} \)\( 9 * F_{adc\_ker\_ck} \)\( 9 * F_{adc\_ker\_ck} \)\( 9 * F_{adc\_ker\_ck} \)
1001\( 10 * F_{adc\_ker\_ck} \)\( 10 * F_{adc\_ker\_ck} \)\( 10 * F_{adc\_ker\_ck} \)\( 10 * F_{adc\_ker\_ck} \)
1010\( 11 * F_{adc\_ker\_ck} \)\( 11 * F_{adc\_ker\_ck} \)\( 11 * F_{adc\_ker\_ck} \)\( 11 * F_{adc\_ker\_ck} \)
1011\( 12 * F_{adc\_ker\_ck} \)\( 12 * F_{adc\_ker\_ck} \)\( 12 * F_{adc\_ker\_ck} \)\( 12 * F_{adc\_ker\_ck} \)
1100\( 13 * F_{adc\_ker\_ck} \)\( 13 * F_{adc\_ker\_ck} \)\( 13 * F_{adc\_ker\_ck} \)\( 13 * F_{adc\_ker\_ck} \)
1101\( 14 * F_{adc\_ker\_ck} \)\( 14 * F_{adc\_ker\_ck} \)\( 14 * F_{adc\_ker\_ck} \)\( 13 * F_{adc\_ker\_ck} \)
1110\( 15 * F_{adc\_ker\_ck} \)\( 15 * F_{adc\_ker\_ck} \)\( 15 * F_{adc\_ker\_ck} \)\( 13 * F_{adc\_ker\_ck} \)
1111\( 16 * F_{adc\_ker\_ck} \)\( 16 * F_{adc\_ker\_ck} \)\( 15 * F_{adc\_ker\_ck} \)\( 13 * F_{adc\_ker\_ck} \)

33.7.3 ADC common regular data register for dual mode (ADC12_CDR)

Address offset: 0x0C

Reset value: 0x0000 0000

The address offset is relative to the master ADC base address + 0x300.

ADC1 and ADC2 are controlled by the same interface.

This register is available only the devices that support dual mode (see Section 33.3: ADC implementation ).

31302928272625242322212019181716
RDATA_SLV[15:0]
rrrrrrrrrrrrrrrr
1514131211109876543210
RDATA_MST[15:0]
rrrrrrrrrrrrrrrr

Bits 31:16 RDATA_SLV[15:0] : Regular data of the slave ADC

In dual mode, these bits contain the regular data of the slave ADC. Refer to Section 33.4.31: Dual ADC modes .

The data alignment is applied as described in Section : Data register, data alignment and offset (ADC_DR, ADC_JDRy, OFFSETy, OFFSETy_CH, OVSS, LSHIFT, USAT, SSAT)

Bits 15:0 RDATA_MST[15:0] : Regular data of the master ADC.

In dual mode, these bits contain the regular data of the master ADC. Refer to Section 33.4.31: Dual ADC modes .

The data alignment is applied as described in Section : Data register, data alignment and offset (ADC_DR, ADC_JDRy, OFFSETy, OFFSETy_CH, OVSS, LSHIFT, USAT, SSAT)

In DAMDF[1:0] = 11 mode, bits 15:8 contains SLV_ADC_DR[7:0], bits 7:0 contains MST_ADC_DR[7:0].

33.7.4 ADC common regular data register for 32-bit dual mode (ADC12_CDR2)

Address offset: 0x10

Reset value: 0x0000 0000

The address offset is relative to the master ADC base address + 0x300.

ADC1 and ADC2 are controlled by the same interface.

This register is available only the devices that support dual mode (see Section 33.3: ADC implementation ).

31302928272625242322212019181716
RDATA_ALT[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
RDATA_ALT[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 RDATA_ALT[31:0] : Regular data of the master/slave alternated ADCs

In dual mode, these bits alternatively contains the regular 32-bit data of the master and the slave ADC. Refer to Section 33.4.31: Dual ADC modes .

The data alignment is applied as described in Section : Data register, data alignment and offset (ADC_DR, ADC_JDRy, OFFSETy, OFFSETy_CH, OVSS, LSHIFT, USAT, SSAT) .

33.8 ADC register map

Table 321. ADC global register map

OffsetRegister
0x000 - 0x0D0Master ADC1
0x0D4 - 0x0FCReserved
0x100 - 0x1D0Slave ADC2
0x1D4 - 0x2FCReserved
0x300 - 0x310Master and slave ADC common registers

Table 322. ADC register map and reset values for each ADC (offset = 0x00 for master ADC, 0x100 for slave ADC)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x00ADC_ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.LDORDYRes.Res.AWD3AWD2AWD1JEOSJEOCOVREOSEOCEOSMPADRDY
Reset value00000000000
0x04ADC_IERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3IEAWD2IEAWD1IEJEOSIEJEOCIEOVRIEEOSIEEOCIEEOSMPIEADRDYIE
Reset value0000000000
0x08ADC_CRADCALRes.DEEPPWDADVREGENCALINDEX[3:0]Res.Res.Res.Res.Res.Res.ADCALLINRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.JADSTPADSTPJADSTARTADSTARTADDISADEN
Reset value00000000000000
0x0CADC_CFGR1Res.AWD1CH[4:0]JAUTOJAWD1ENAWD1ENAWD1SGLRes.JDISCENDISCNUM [2:0]DISCENRes.AUTDLYCONTOVRMODEXTEN[1:0]EXTSEL[4:0]Res.RES [1:0]DMNGT [1:0]
Reset value0000000000000000000000000000
0x10ADC_CFGR2LSHIFT[3:0]Res.Res.OSR[9:0]SMPTRIGSWTRIGBULBRes.Res.ROVSMTROVSOVSS[3:0]Res.Res.Res.JOVSEROVSE
Reset value0000000000000000000000000
0x14ADC_SMPR1Res.Res.SMP9[2:0]SMP8[2:0]SMP7[2:0]SMP6[2:0]SMP5[2:0]SMP4[2:0]SMP3[2:0]SMP2[2:0]SMP1[2:0]SMP0[2:0]
Reset value000000000000000000000000000000
0x18ADC_SMPR2Res.Res.SMP19 [2:0]SMP18 [2:0]SMP17 [2:0]SMP16 [2:0]SMP15 [2:0]SMP14 [2:0]SMP13 [2:0]SMP12 [2:0]SMP11 [2:0]SMP10 [2:0]
Reset value000000000000000000000000000000

Table 322. ADC register map and reset values for each ADC (offset = 0x00 for master ADC, 0x100 for slave ADC) (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x1CADC_PCSELRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PCSEL19PCSEL18PCSEL17PCSEL16PCSEL15PCSEL14PCSEL13PCSEL12PCSEL11PCSEL10PCSEL9PCSEL8PCSEL7PCSEL6PCSEL5PCSEL4PCSEL3PCSEL2PCSEL1PCSEL0
Reset value00000000000000000000
0x20-0x2CReservedRes.
0x30ADC_SQR1Res.Res.Res.SQ4[4:0]Res.SQ3[4:0]Res.SQ2[4:0]Res.SQ1[4:0]Res.Res.L[3:0]
Reset value000000000000000000000000
0x34ADC_SQR2Res.Res.Res.SQ9[4:0]Res.SQ8[4:0]Res.SQ7[4:0]Res.SQ6[4:0]Res.SQ5[4:0]
Reset value0000000000000000000000000
0x38ADC_SQR3Res.Res.Res.SQ14[4:0]Res.SQ13[4:0]Res.SQ12[4:0]Res.SQ11[4:0]Res.SQ10[4:0]
Reset value0000000000000000000000000
0x3CADC_SQR4Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SQ16[4:0]Res.SQ15[4:0]
Reset value0000000000
0x40ADC_DRRDATA[31:0]
Reset value00000000000000000000000000000000
0x44-0x48ReservedRes.
0x4CADC_JSQRJSQ4[4:0]Res.JSQ3[4:0]Res.JSQ2[4:0]Res.JSQ1[4:0]JEXTEN
[1:0]
JEXTSEL
[4:0]
JL[1:0]
Reset value00000000000000000000000000000
0x50-0x5CReservedRes.
0x60ADC_OFR1OFFSET1
_CH[4:0]
SSATUSATPOSOFFOFFSET[23:0]
Reset value00000000000000000000000000000000
0x64ADC_OFR2OFFSET2
_CH[4:0]
SSATUSATPOSOFFOFFSET[23:0]
Reset value00000000000000000000000000000000
0x68ADC_OFR3OFFSET3
_CH[4:0]
SSATUSATPOSOFFOFFSET[23:0]
Reset value00000000000000000000000000000000
0x6CADC_OFR4OFFSET4_CH[4:0]SSATUSATPOSOFFOFFSET[23:0]
Reset value00000000000000000000000000000000
0x70ADC_GCOMPRGCOMPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.GCOEFF[13:0]
Reset value000000000000000
0x74-0x7CReservedRes.
0x80ADC_JDR1JDATA1[31:0]
Reset value00000000000000000000000000000000

Table 322. ADC register map and reset values for each ADC (offset = 0x00 for master ADC, 0x100 for slave ADC) (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x84ADC_JDR2JDATA2[31:0]
Reset value00000000000000000000000000000000
0x88ADC_JDR3JDATA3[31:0]
Reset value00000000000000000000000000000000
0x8CADC_JDR4JDATA4[31:0]
Reset value00000000000000000000000000000000
0x90-
0x9C
ReservedRes.
0xA0ADC_AWD2CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD2CH[19:0]
Reset value00000000000000000000
0xA4ADC_AWD3CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3CH[19:0]
Reset value00000000000000000000
0xA8ADC_LTR1Res.Res.Res.Res.Res.Res.Res.LTR1[24:0]
Reset value000000000000000000000000
0xACADC_HTR1AWDFILT
1[2:0]
Res.Res.Res.Res.HTR1[24:0]
Reset value000100111111111111111111111
0xB0ADC_LTR2Res.Res.Res.Res.Res.Res.Res.LTR2[24:0]
Reset value000000000000000000000000
0xB4ADC_HTR2Res.Res.Res.Res.Res.Res.Res.HTR2[24:0]
Reset value100000000000000000000000
0xB8ADC_LTR3Res.Res.Res.Res.Res.Res.Res.LTR3[24:0]
Reset value000000000000000000000000
0xBCADC_HTR3Res.Res.Res.Res.Res.Res.Res.HTR3[24:0]
Reset value100000000000000000000000
0xC0ADC_DIFSELRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DIFSEL[19:0]
Reset value00000000000000000000
0xC4ADC_CALFACTRes.Res.Res.Res.Res.Res.CAPTURE_COEFLATCH_COEFRes.Res.Res.Res.Res.Res.VALIDITYI_APB_DATA[7:0]I_APB_ADDR[7:0]
Reset value000000000000000000
0xC8ADC_CALFACT2CALFACT[31:0]
Reset value00000000000000000000000000000000

Table 323. ADC register map and reset values (master and slave ADC common registers) offset = 0x300

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x00ADC12_CSRRes.Res.Res.LDORDY_SLVRes.Res.AWD3_SLVAWD2_SLVAWD1_SLVJEOS_SLVJEOC_SLVOVR_SLVEOS_SLVEOC_SLVEOSMP_SLVADRDY_SLVRes.Res.Res.LDORDY_MSTRes.Res.AWD3_MSTAWD2_MSTAWD1_MSTJEOS_MSTJEOC_MSTOVR_MSTEOS_MSTEOC_MSTEOSMP_MSTADRDY_MST
slave ADC2master ADC1
Reset value0000000000000000000000

Table 323. ADC register map and reset values (master and slave ADC common registers) offset = 0x300 (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x04ReservedRes
0x08ADC12_CCRResResResResResResResVBATENVSENSESELVREFENPRESC[3:0]ResResDAMDF[1:0]ResResDELAY[3:0]ResResResDUAL[4:0]
Reset value000000000000000000
0x0CADC12_CDRRDATA_SLV[15:0]RDATA_MST[15:0]
Reset value00000000000000000000000000000000
0x10ADC12_CDR2RDATA_ALT[31:0]
Reset value00000000000000000000000000000000
Refer to Section 2.3 on page 140 for the register boundary addresses.