15. Analog-to-digital converters (ADC)

15.1 Introduction

This section describes the implementation of up to 2 ADCs:

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

Each ADC consists of a 12-bit successive approximation analog-to-digital converter.

Each ADC has up to 19 multiplexed channels. A/D conversion of the various channels can be performed in single, continuous, scan or discontinuous mode. The result of the ADC is stored in a left-aligned or right-aligned 16-bit data register.

The ADCs are mapped on the AHB bus to allow fast data handling.

The analog watchdog features allow the application to detect if the input voltage goes outside the user-defined high or low thresholds.

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

Note: The STM32F302x6/8 devices have only ADC1. The STM32F302xB/C/D/E have ADC1 and ADC2.

15.2 ADC main features

The table below summarizes the different external channels available per ADC.

Table 81. ADC external channels mapping

DeviceADC1ADC2
STM32F302x6/815N.A
STM32F302xB/C1012
STM32F302xD/E1113
Table 82. ADC internal channels summary
ProductADC1ADC2Total of internal ADC channels
STM32F302xB/C/D/E
  • – 1 channel connected to temperature sensor.
  • – 1 channel connected to VBAT/2
  • – 1 channel connected to VREFINT
  • – 1 channel connected to OPAMP1 reference voltage output (VREFOPAMP1).
  • – 1 channel connected to temperature sensor.
  • – 1 channel connected to VBAT/2
  • – 1 channel connected to VREFINT.
  • – 1 channel connected to OPAMP2 reference voltage output (VREFOPAMP2).
5
STM32F302x6/8
  • – 1 channel connected to temperature sensor.
  • – 1 channel connected to VBAT/2
  • – 1 channel connected to VREFINT
-3

Figure 51 shows the block diagram of one ADC.

15.3 ADC functional description

15.3.1 ADC block diagram

Figure 51 shows the ADC block diagram and Table 84 gives the ADC pin description.

Figure 51. ADC block diagram

ADC block diagram showing internal components like SAR ADC, Input selection & scan control, Start & Stop Control, and external connections to Cortex M4, DMA, and Timers.

The block diagram illustrates the internal architecture and external connections of the ADC. At the core is the SAR ADC block, which receives analog signals through Input selection & scan control and produces CONVERTED DATA . The Start & Stop Control block manages the conversion process, supported by autodly (auto delayed) and ADSTP (stop conv) features. The Input selection & scan control block is connected to ADC_IN [15:1] pins, which include VREF+ , VREF- , VBAT , VREFINT , VTS , and VOPAMPx . It also receives configuration from JAUTO , ADC_JSQRx , ADC_SQRx , and CONT (single/cont) settings. The SAR ADC is connected to an AHB interface which provides READY , EOSMP , EOC , EOS , OVR , JEOS , JQOVF , and AWDx signals to the Cortex M4 with FPU via ADC Interrupt and IRQ lines. The interface also supports DMA requests through DMACFG and DMAEN settings. Data is output via RDATA[11:0] and JDATA1[11:0] through JDATA4[11:0] . The SAR ADC also features autopower-down , ADCAL (self calibration), and Bias & Ref (connected to VREF+ 1.8 to 3.6 V and Analog Supply (VDDA) 1.8V to 3.6 V ) blocks. Configuration for the SAR ADC includes ADEN/ADDS , SMPx[2:0] (sampling time), OVERMOD (overrun mode), ALIGN (left/right), RES[1:0] (12, 10, 8 bits), JOFFSETx[11:0] , and JOFFSETx_CH[11:0] . The EXTI mapped at product level (EXT0 to EXT15) and JEXTI mapped at product level (JEXT0 to JEXT15) are connected to Start & Stop Control and SAR ADC via S/W trigger and h/w trigger blocks. These triggers are configured with EXTEN[1:0] (trigger enable and edge selection), EXTSEL[3:0] (trigger selection), JEXTEN[1:0] (trigger enable and edge selection), and JEXTSEL[3:0] (trigger selection). The SAR ADC also supports DISCEN (discontinuous mode) and JDISCEN (injected Context Queue Mode) with JDISCNUM[2:0] . An Analog watchdog 1,2,3 block compares the CONVERTED DATA with thresholds AWD1 , AWD2 , and AWD3 , generating AWD1_OUT , AWD2_OUT , and AWD3_OUT signals to TIMERs (ETR). The Analog watchdog is configured with AWD1EN , JAWD1EN , AWD1SGL , AWDCH1[4:0] , LT1[11:0] , HT1[11:0] , AWDCH2[18:0] , LT2[7:0] , AWDCH3[18:0] , HT2[7:0] , HT3[7:0] , and LT3[7:0] settings. The diagram is identified by the code MSV30260V3 in the bottom right corner.

ADC block diagram showing internal components like SAR ADC, Input selection & scan control, Start & Stop Control, and external connections to Cortex M4, DMA, and Timers.

15.3.2 Pins and internal signals

Table 83. ADC internal signals

Internal signal nameSignal typeDescription
EXT[15:0]InputsUp to 16 external trigger inputs for the regular conversions (can be connected to on-chip timers).
These inputs are shared between the ADC master and the ADC slave.
JEXT[15:0]InputsUp to 16 external trigger inputs for the injected conversions (can be connected to on-chip timers).
These inputs are shared between the ADC master and the ADC slave.
ADC1_AWDx_OUT
ADC2_AWDx_OUT
OutputInternal analog watchdog output signal connected to on-chip timers. (x = Analog watchdog number 1,2,3)
V REFOPAMP1InputReference voltage output from internal operational amplifier 1
V REFOPAMP2InputReference voltage output from internal operational amplifier 2
V TSInputOutput voltage from internal temperature sensor
V REFINTInputOutput voltage from internal reference voltage
V BATInput supplyExternal battery voltage supply

Table 84. ADC pins

NameSignal typeComments
V REF+Input, analog reference positiveThe higher/positive reference voltage for the ADC, \( 1.8\text{ V} \leq V_{REF+} \leq V_{DDA} \)
V DDAInput, analog supplyAnalog power supply equal V DDA :
\( 1.8\text{V} \leq V_{DDA} \leq 3.6\text{ V} \)
V REF-Input, analog reference negativeThe lower/negative reference voltage for the ADC, \( V_{REF-} = V_{SSA} \)
V SSAInput, analog supply groundGround for analog power supply equal to V SS
V INP [18:1]Positive input analog channels for each ADCConnected either to external channels: ADC_INi or internal channels.
V INN [18:1]Negative input analog channels for each ADCConnected to V REF- or external channels: ADC_INi-1
ADCx_IN15:1External analog input signalsUp to 16 analog input channels (x = ADC number = 1 or 2):
– 5 fast channels
– 10 slow channels

15.3.3 Clocks

Dual clock domain architecture

The dual clock-domain architecture means that each ADC clock is independent from the AHB bus clock.

The input clock of the two ADCs (master and slave) can be selected between two different clock sources (see Figure 52: ADC clock scheme ):

  1. The ADC clock can be a specific clock source, named “ADCxy_CK (xy=12 or 34) which is independent and asynchronous with the AHB clock”.
    It can be configured in the RCC to deliver up to 72 MHz (PLL output). Refer to RCC Section for more information on generating ADC12_CK.
    To select this scheme, bits CKMODE[1:0] of the ADCx_CCR register must be reset.
  2. The ADC clock can be derived from the AHB clock of the ADC bus interface, divided by a programmable factor (1, 2 or 4). In this mode, a programmable divider factor can be selected (/1, 2 or 4 according to bits CKMODE[1:0]).
    To select this scheme, bits CKMODE[1:0] of the ADCx_CCR register must be different from “00”.

Note: Software can use option b) by writing CKMODE[1:0]=01 only if the AHB prescaler of the RCC is set to 1 (the duty cycle of the AHB clock must be 50% in this configuration).

Option a) has the advantage of reaching the maximum ADC clock frequency whatever the AHB clock scheme selected. The ADC clock can eventually be divided by the following ratio: 1, 2, 4, 6, 8, 12, 16, 32, 64, 128, 256; using the prescaler configured with bits ADCxPRES[4:0] in register RCC_CFGR2 (Refer to Section 9: Reset and clock control (RCC) ).

Option b) has the advantage of bypassing the clock domain resynchronizations. This can be useful when the ADC is triggered by a timer and if the application requires that the ADC is precisely triggered without any uncertainty (otherwise, an uncertainty of the trigger instant is added by the resynchronizations between the two clock domains).

Figure 52. ADC clock scheme

Figure 52: ADC clock scheme diagram. The diagram shows the RCC (Reset and clock controller) block on the left providing two clock signals: HCLK and ADC12_CK. The HCLK signal is connected to the AHB interface of the ADC1 & ADC2 block. The ADC12_CK signal is connected to a multiplexer (labeled '00') within the ADC1 & ADC2 block. The multiplexer also receives inputs from a divider block labeled '/1 or /2 or /4' and from a block labeled 'Others'. The output of the multiplexer is connected to the Analog ADC1 (master) and Analog ADC2 (slave) blocks. The divider block is controlled by bits CKMODE[1:0] of the ADC12_CCR register. The 'Others' block is also controlled by bits CKMODE[1:0] of the ADC12_CCR register. The diagram is labeled MSv32648V1.
Figure 52: ADC clock scheme diagram. The diagram shows the RCC (Reset and clock controller) block on the left providing two clock signals: HCLK and ADC12_CK. The HCLK signal is connected to the AHB interface of the ADC1 & ADC2 block. The ADC12_CK signal is connected to a multiplexer (labeled '00') within the ADC1 & ADC2 block. The multiplexer also receives inputs from a divider block labeled '/1 or /2 or /4' and from a block labeled 'Others'. The output of the multiplexer is connected to the Analog ADC1 (master) and Analog ADC2 (slave) blocks. The divider block is controlled by bits CKMODE[1:0] of the ADC12_CCR register. The 'Others' block is also controlled by bits CKMODE[1:0] of the ADC12_CCR register. The diagram is labeled MSv32648V1.
  1. Refer to the RCC section to see how HCLK and ADC12_CK can be generated.
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 except if some injected channels are programmed. In this case, it is mandatory to respect the following ratio:

15.3.4 ADC1/2 connectivity

ADC1 and ADC2 are tightly coupled and share some external channels as described in Figure 53.

Figure 53. ADC1 and ADC2 connectivity

Schematic diagram showing the connectivity of ADC1 and ADC2 to an STM32F3xx microcontroller. It details the internal channel selection for both ADCs, including fast and slow channels, and their connection to external pins and internal reference voltages.

The diagram illustrates the internal architecture and connectivity of ADC1 and ADC2 within an STM32F3xx microcontroller. Both ADCs are connected to a common SAR (Successive Approximation Register) block. The diagram is divided into two main sections: ADC1 and ADC2.

ADC1 Section:

ADC2 Section:

The diagram also shows the connection of various internal voltage sources (V REF+ , V REF- , V OPAMP1 , V TS , V BAT/2 , V REFIN , V OPAMP2 ) to the ADCs. The code MSv36493V1 is visible in the bottom right corner.

Schematic diagram showing the connectivity of ADC1 and ADC2 to an STM32F3xx microcontroller. It details the internal channel selection for both ADCs, including fast and slow channels, and their connection to external pins and internal reference voltages.
  1. 1. On STM32F302x6/8, this channel is available on ADC1 only.
  2. 2. STM32F302x6/8 devices only.
  3. 3. On STM32F302xB/CD/E devices only.
  4. 4. On STM32F302x6/8/D/E devices.

15.3.5 Slave AHB interface

The ADCs implement 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.

15.3.6 ADC voltage regulator (ADVREGEN)

The sequence below is required to start ADC operations:

  1. 1. Enable the ADC internal voltage regulator (refer to the ADC voltage regulator enable sequence).
  2. 2. 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 temporization must be implemented by software. \( T_{ADCVREG\_STUP} \) is equal to 10 µs in the worst case process/temperature/power supply.

After ADC operations are complete, the ADC is disabled (ADEN=0).

It is possible to save power by disabling the ADC voltage regulator (refer to the ADC voltage regulator disable sequence).

Note: When the internal voltage regulator is disabled, the internal analog calibration is kept.

ADVREG enable sequence

To enable the ADC voltage regulator, perform the sequence below:

  1. 1. Change ADVREGEN[1:0] bits from '10' (disabled state, reset state) into '00'.
  2. 2. Change ADVREGEN[1:0] bits from '00' into '01' (enabled state).
ADVREG disable sequence

To disable the ADC voltage regulator, perform the sequence below:

  1. 1. Change ADVREGEN[1:0] bits from '01' (enabled state) into '00'.
  2. 2. Change ADVREGEN[1:0] bits from '00' into '10' (disabled state)

15.3.7 Single-ended and differential input channels

Channels can be configured to be either single-ended input or differential input by writing into bits DIFSEL[15:1] in the ADCx_DIFSEL register. This configuration must be written while the ADC is disabled (ADEN=0). Note that DIFSEL[18:16] are fixed to single ended channels (internal channels only) and are always read as 0.

In single-ended input mode, the analog voltage to be converted for channel "i" is the difference between the external voltage ADC_IN 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 ADC_INi (positive input) and ADC_INi+1 (negative input).

For a complete description of how the input channels are connected for each ADC, refer to Figure 53: ADC1 and ADC2 connectivity on page 298 .

Caution: When configuring the channel “i” in differential input mode, its negative input voltage is connected to ADC_INi+1. As a consequence, channel “i+1” is no longer usable in single-ended mode or in differential mode and must never be configured to be converted. Some channels are shared between ADC1 and ADC2: this can make the channel on the other ADC unusable. Only exception is interleaved mode for ADC master and the slave.

Example: Configuring ADC1_IN5 in differential input mode will make ADC2_IN6 not usable: in that case, the channels 6 of both ADC1 and ADC2 must never be converted.

Note: Channels 16, 17 and 18 of ADC1 and channels 17 and 18 of ADC2 are connected to internal analog channels and are internally fixed to single-ended inputs configuration (corresponding bits DIFSEL[i] is always zero). Channel 15 of ADC1 is also an internal channel and the user must configure the corresponding bit DIFSEL[15] to zero.

15.3.8 Calibration (ADCAL, ADCALDIF, ADCx_CALFACT)

Each ADC provides an automatic calibration procedure which drives all the calibration sequence including the power-on/off sequence of the ADC. During the procedure, the ADC calculates a calibration factor which is 7-bit wide and which is 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 calibration is complete.

Calibration is preliminary to any ADC operation. It removes the offset error which may vary from chip to chip due to process or bandgap variation.

The calibration factor to be applied for single-ended input conversions is different from the factor to be applied for differential input conversions:

The calibration is then initiated by software by setting bit ADCAL=1. Calibration can only be initiated when the ADC is disabled (when ADEN=0). ADCAL bit stays at 1 during all the calibration sequence. It is then cleared by hardware as soon as the calibration completes. At this time, the associated calibration factor is stored internally in the analog ADC and also in the bits CALFACT_S[6:0] or CALFACT_D[6:0] of ADCx_CALFACT register (depending on single-ended or differential input calibration)

The internal analog calibration is kept if the ADC is disabled (ADEN=0). However, if the ADC is disabled for extended periods, then it is recommended that a new calibration cycle is run before re-enabling the ADC.

The internal analog calibration is kept if the ADC is disabled (ADEN=0). When the ADC operating conditions change (V REF+ changes are the main contributor to ADC offset variations, V DDA and temperature change to a lesser extent), it is recommended to re-run a calibration cycle.

The internal analog calibration is lost each time the power of the ADC is removed (example, when the product enters in STANDBY or VBAT mode). In this case, to avoid spending time recalibrating the ADC, it is possible to re-write the calibration factor into the

ADCx_CALFACT register without recalibrating, supposing that the software has previously saved the calibration factor delivered during the previous calibration.

The calibration factor can be written if the ADC is enabled but not converting (ADEN=1 and ADSTART=0 and JADSTART=0). Then, at the next start of conversion, the calibration factor will automatically be injected into the analog ADC. This loading is transparent and does not add any cycle latency to the start of the conversion.

Software procedure to calibrate the ADC

  1. 1. Ensure ADVREGEN[1:0]=01 and that ADC voltage regulator startup time has elapsed.
  2. 2. Ensure that ADEN=0.
  3. 3. Select the input mode for this calibration by setting ADCALDIF=0 (Single-ended input) or ADCALDIF=1 (Differential input).
  4. 4. Set ADCAL=1.
  5. 5. Wait until ADCAL=0.
  6. 6. The calibration factor can be read from ADCx_CALFACT register.

Figure 54. ADC calibration

Timing diagram for ADC calibration showing signals ADCALDIF, ADCAL, ADC State, and CALFACT_x[6:0].

The diagram shows the sequence of events for ADC calibration:

Legend: Upward arrow indicates action "by S/W", downward arrow indicates action "by H/W". \( t_{CAB} \) indicates indicative timings.

MSV30263V2

Timing diagram for ADC calibration showing signals ADCALDIF, ADCAL, ADC State, and CALFACT_x[6:0].

Software procedure to re-inject a calibration factor into the ADC

  1. 1. Ensure ADEN=1 and ADSTART=0 and JADSTART=0 (ADC enabled and no conversion is ongoing).
  2. 2. Write CALFACT_S and CALFACT_D with the new calibration factors.
  3. 3. When a conversion is launched, the calibration factor will be injected into the analog ADC only if the internal analog calibration factor differs from the one stored in bits CALFACT_S for single-ended input channel or bits CALFACT_D for differential input channel.

Figure 55. Updating the ADC calibration factor

Timing diagram for updating the ADC calibration factor. It shows the ADC state (Ready, Converting channel), Internal calibration factor[6:0] (F1, F2), Start conversion (hardware or software), WRITE ADC_CALFACT, and CALFACT_S[6:0] signals over time. The diagram illustrates that writing a new calibration factor (F2) while the ADC is in a converting channel updates the internal factor, which is then reflected in the CALFACT_S register.

The diagram shows the following signals and states over time:

Legend:
by s/w (software)
by h/w (hardware)

MSV30529V2

Timing diagram for updating the ADC calibration factor. It shows the ADC state (Ready, Converting channel), Internal calibration factor[6:0] (F1, F2), Start conversion (hardware or software), WRITE ADC_CALFACT, and CALFACT_S[6:0] signals over time. The diagram illustrates that writing a new calibration factor (F2) while the ADC is in a converting channel updates the internal factor, which is then reflected in the CALFACT_S register.

Converting single-ended and differential analog inputs with a single ADC

If the ADC is supposed to convert both differential and single-ended inputs, two calibrations must be performed, one with ADCALDIF=0 and one with ADCALDIF=1. The procedure is the following:

  1. 1. Disable the ADC.
  2. 2. Calibrate the ADC in single-ended input mode (with ADCALDIF=0). This updates the register CALFACT_S[6:0].
  3. 3. Calibrate the ADC in Differential input modes (with ADCALDIF=1). This updates the register CALFACT_D[6:0].
  4. 4. Enable the ADC, configure the channels and launch the conversions. Each time there is a switch from a single-ended to a differential inputs channel (and vice-versa), the calibration will automatically be injected into the analog ADC.

Figure 56. Mixing single-ended and differential channels

Timing diagram for mixing single-ended and differential channels. It shows the Trigger event, ADC state (RDY, CONV CH 1 to 4), Internal calibration factor[6:0] (F2, F3), CALFACT_S[6:0] (F2), and CALFACT_D[6:0] (F3) signals. The diagram shows that the internal calibration factor automatically switches between F2 (for single-ended) and F3 (for differential) as the ADC converts different channel types.

The diagram shows the following signals and states over time:

MSV30530V2

Timing diagram for mixing single-ended and differential channels. It shows the Trigger event, ADC state (RDY, CONV CH 1 to 4), Internal calibration factor[6:0] (F2, F3), CALFACT_S[6:0] (F2), and CALFACT_D[6:0] (F3) signals. The diagram shows that the internal calibration factor automatically switches between F2 (for single-ended) and F3 (for differential) as the ADC converts different channel types.

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

First of all, follow the procedure explained in Section 15.3.6: ADC voltage regulator (ADVREGEN) .

Once ADVREGEN[1:0] = 01, the ADC can be enabled and the ADC needs a stabilization time of \( t_{STAB} \) before it starts converting accurately, as shown in Figure 57 . Two control bits enable or disable the ADC:

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

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

Software procedure to enable the ADC

  1. 1. Set ADEN=1.
  2. 2. Wait until ADRDY=1 (ADRDY is set after the ADC startup time). This can be done using the associated interrupt (setting ADRDYIE=1).

Note: ADEN bit cannot be set during ADCAL=1 and 4 ADC clock cycle after the ADCAL bit is cleared by hardware(end of the calibration).

Software procedure to disable the ADC

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

Figure 57. 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 low, ADRDY is low, ADDIS is low, and ADC state is OFF. 2. Enabling: ADEN is set high (by S/W). ADRDY goes high after a stabilization time t_STAB. ADC state transitions from OFF to Startup, then to RDY. 3. Conversions: ADEN remains high. ADRDY is high. ADDIS is low. ADC state transitions from RDY to Converting CH, then back to RDY. 4. Disabling: ADDIS is set high (by S/W). ADC state transitions from RDY to REQ-OF, then to OFF. ADRDY goes low. ADEN is set low (by H/W). rising edge falling edge

The diagram illustrates the timing for enabling and disabling the ADC. It shows four signal lines: ADEN, ADRDY, ADDIS, and ADC state.
- ADEN : Set high by software (S/W) to enable the ADC. It is set low by hardware (H/W) when the ADC is disabled.
- ADRDY : Goes high after a stabilization time \( t_{STAB} \) following the setting of ADEN. It goes low when the ADC is disabled.
- ADDIS : Set high by software to disable the ADC. It is automatically reset by hardware when the ADC is disabled.
- ADC state : Transitions from OFF to Startup (when ADEN is set), then to RDY (when ADRDY is set). It can transition to Converting CH and back to RDY while ADEN is high. When ADDIS is set, it transitions to REQ-OF and then back to OFF.

by S/W by H/W

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 low, ADRDY is low, ADDIS is low, and ADC state is OFF. 2. Enabling: ADEN is set high (by S/W). ADRDY goes high after a stabilization time t_STAB. ADC state transitions from OFF to Startup, then to RDY. 3. Conversions: ADEN remains high. ADRDY is high. ADDIS is low. ADC state transitions from RDY to Converting CH, then back to RDY. 4. Disabling: ADDIS is set high (by S/W). ADC state transitions from RDY to REQ-OF, then to OFF. ADRDY goes low. ADEN is set low (by H/W). rising edge falling edge

MSV30264V2

15.3.10 Constraints when writing the ADC control bits

The software is allowed to write the RCC control bits to configure and enable the ADC clock (refer to RCC Section), the control bits DIFSEL in the ADCx_DIFSEL register and the control bits ADCAL and ADEN in the ADCx_CR register, only if the ADC is disabled (ADEN must be equal to 0).

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

For all the other control bits of the ADCx_CFGR, ADCx_SMPRx, ADCx_TRx, ADCx_SQRx, ADCx_JDRy, ADCx_OF Ry, ADCx_OFCHR and ADCx_IER registers:

The software is allowed to write the control bits ADSTP or JADSTP of the ADCx_CR register only if the ADC is enabled and eventually converting and if there is no pending request to disable the ADC (ADSTART or JADSTART must be equal to 1 and ADDIS to 0).

The software can write the register ADCx_JSQR at any time, when the ADC is enabled (ADEN=1).

Note: There is no hardware protection to prevent these forbidden write accesses and ADC behavior may become in an unknown state. To recover from this situation, the ADC must be disabled (clear ADEN=0 as well as all the bits of ADCx_CR register).

15.3.11 Channel selection (SQRx, JSQRx)

There are up to 18 multiplexed channels per ADC:


Warning: The user must ensure that only one of the two ADCs is converting \( V_{REFINT} \) at the same time (it is forbidden to have several ADCs converting \( V_{REFINT} \) at the same time).


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

It is possible to organize the conversions 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.

ADCx_SQR registers must not be modified while regular conversions can occur. For this, the ADC regular conversions must be first stopped by writing ADSTP=1 (refer to Section 15.3.17: Stopping an ongoing conversion (ADSTP, JADSTP) ).

It is possible to modify the ADCx_JSQR registers on-the-fly while injected conversions are occurring. Refer to Section 15.3.21: Queue of context for injected conversions

15.3.12 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 which is programmable using the SMP[2:0] bits in the ADCx_SMPR1 and ADCx_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} + 12.5 \text{ ADC clock cycles} \]

Example:

With \( F_{\text{ADC\_CLK}} = 72 \text{ MHz} \) and a sampling time of 1.5 ADC clock cycles:

\[ T_{\text{conv}} = (1.5 + 12.5) \text{ ADC clock cycles} = 14 \text{ ADC clock cycles} = 0.194 \text{ } \mu\text{s} \text{ (for fast channels)} \]

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

Constraints on the sampling time for fast and slow channels

For each channel, SMP[2:0] bits must be programmed to respect a minimum sampling time as specified in the ADC characteristics section of the datasheets.

15.3.13 Single conversion mode (CONT=0)

In Single conversion mode, the ADC performs once all the conversions of the 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.

15.3.14 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 re-starts and continuously converts each conversions of the sequence. This mode is started with the CONT bit at 1 either by external trigger or by setting the ADSTART bit in the ADCx_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 JAUTO bit), refer to Auto-injection mode section ).

15.3.15 Starting conversions (ADSTART, JADSTART)

Software starts ADC regular conversions by setting ADSTART=1.

When ADSTART is set, the conversion starts:

Software starts ADC injected conversions by setting JADSTART=1.

When JADSTART is set, the conversion starts:

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

ADSTART and JADSTART also provide information on whether any ADC operation is currently ongoing. It is possible to re-configure the ADC while ADSTART=0 and JADSTART=0 are both true, indicating that 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 EXTSEL !=0x00), ADSTART is not cleared by hardware with the assertion of EOS to help the software which 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:

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

\[ T_{ADC} = T_{SMPL} + T_{SAR} = [ 1.5 \text{ } |_{min} + 12.5 \text{ } |_{12bit} ] \times T_{ADC\_CLK} \]
\[ T_{ADC} = T_{SMPL} + T_{SAR} = 20.83 \text{ ns } |_{min} + 173.6 \text{ ns } |_{12bit} = 194.4 \text{ ns (for } F_{ADC\_CLK} = 72 \text{ MHz)} \]

Figure 58. Analog to digital conversion time

Timing diagram for ADC conversion showing ADC state, Analog channel, Internal S/H, ADSTART, EOSMP, EOC, and ADC_DR signals over time. It illustrates the sampling and conversion phases for channels Ch(N) and Ch(N+1).

The diagram shows the timing of an ADC conversion across several signals:

MS30532V1

Timing diagram for ADC conversion showing ADC state, Analog channel, Internal S/H, ADSTART, EOSMP, EOC, and ADC_DR signals over time. It illustrates the sampling and conversion phases for channels Ch(N) and Ch(N+1).
  1. 1. \( T_{SMPL} \) depends on SMP[2:0]
  2. 2. \( T_{SAR} \) depends on RES[2:0]

15.3.17 Stopping an ongoing conversion (ADSTP, JADSTP)

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

Stopping conversions will reset the ongoing ADC operation. Then the ADC can be reconfigured (ex: changing the channel selection or the trigger) ready for a new operation.

Note that it is possible to stop injected conversions while regular conversions are still operating and vice-versa. This allows, for instance, re-configuration of the injected conversion sequence and triggers while regular conversions are still operating (and vice-versa).

When the ADSTP bit is set by software, any ongoing regular conversion is aborted with partial result discarded (ADCx_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 (ADCx_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, bits ADSTP/ADSTART (in case of regular conversion), or JADSTP/JADSTART (in case of injected conversion) are cleared by hardware and the software must wait until ADSTART = 0 (or JADSTART = 0) before starting a new conversion.

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

Figure 59. Stopping ongoing regular conversions

Timing diagram showing the process of stopping ongoing regular conversions in an ADC.

The diagram illustrates the timing of ADC operations when stopping ongoing regular conversions. It consists of four horizontal timelines:

Vertical dashed lines indicate the sequence of events: the first trigger starts the first conversion (Sample Ch(N-1), Convert Ch(N-1)), which produces Data N-2; the second trigger starts the second conversion (Sample Ch(N), C), which produces Data N-1; the ADSTART bit is set by software to start these conversions; the ADSTP bit is set by software to stop them; and finally, both ADSTART and ADSTP are cleared by hardware.

MS30533V2

Timing diagram showing the process of stopping ongoing regular conversions in an ADC.

Figure 60. Stopping ongoing regular and injected conversions

Timing diagram showing ADC state, JADSTART, JADSTP, ADC_JDR, ADSTART, ADSTP, and ADC_DR signals over time. It illustrates how to stop ongoing regular and injected conversions using software triggers and status flags. The diagram shows the ADC state transitioning between RDY, Sample, and Convert phases for both regular and injected conversions. JADSTART and ADSTART are set by software (SW) and cleared by hardware (HW) when conversions are ongoing. JADSTP and ADSTP are also set by software to stop ongoing conversions. ADC_JDR and ADC_DR show the data output for injected and regular conversions respectively.

The diagram illustrates the timing and control signals for stopping ongoing ADC conversions. The top row shows the ADC state: RDY, Sample Ch(N-1), Convert Ch(N-1), RDY, Sample Ch(M), C, RDY, Sample, RDY. Triggers are indicated by arrows: Regular trigger, Injected trigger, and Regular trigger. The JADSTART signal is set by software (SW) and cleared by hardware (HW) when injected conversions are ongoing. A note indicates that software is not allowed to configure injected conversions selection and triggers. The JADSTP signal is set by software (SW) and cleared by hardware (HW). The ADC_JDR signal shows DATA M-1. The ADSTART signal is set by software (SW) and cleared by hardware (HW) when regular conversions are ongoing. A note indicates that software is not allowed to configure regular conversions selection and triggers. The ADSTP signal is set by software (SW) and cleared by hardware (HW). The ADC_DR signal shows DATA N-2 and DATA N-1. The diagram is labeled MS30534V1.

Timing diagram showing ADC state, JADSTART, JADSTP, ADC_JDR, ADSTART, ADSTP, and ADC_DR signals over time. It illustrates how to stop ongoing regular and injected conversions using software triggers and status flags. The diagram shows the ADC state transitioning between RDY, Sample, and Convert phases for both regular and injected conversions. JADSTART and ADSTART are set by software (SW) and cleared by hardware (HW) when conversions are ongoing. JADSTP and ADSTP are also set by software to stop ongoing conversions. ADC_JDR and ADC_DR show the data output for injected and regular conversions respectively.

15.3.18 Conversion on external trigger and trigger polarity (EXTSEL, EXTEN, JEXTSEL, JEXTEN)

A conversion or a sequence of conversions can be triggered either by software or by an external event (e.g. 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 0b00, 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 triggers which occur while a conversion is ongoing are ignored.

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

Table 85. 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 86. Configuring the trigger polarity for injected external triggers

JEXTEN[1:0]Source
00Hardware Trigger with detection on the rising edge
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 injected trigger can be anticipated and changed on-the-fly. Refer to Section 15.3.21: Queue of context for injected conversions .

The EXTSEL[3:0] and JEXTSEL[3:0] control bits select which out of 16 possible events can trigger conversion for the regular and injected groups.

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

Note: The regular trigger selection cannot be changed on-the-fly. The injected trigger selection can be anticipated and changed on-the-fly. Refer to Section 15.3.21: Queue of context for injected conversions on page 315

Each ADC master shares the same input triggers with its ADC slave as described in Figure 61 .

Figure 61. Triggers are shared between ADC master & ADC slave

Diagram showing trigger sharing between ADC Master and ADC Slave. On the left, external triggers (EXTI mapped at product level: EXT0, EXT1, ..., EXT15) and injected triggers (JEXTI mapped at product level: JEXT0, JEXT1, ..., JEXT15) are shown. These triggers are connected to multiplexers within the ADC MASTER and ADC SLAVE blocks. The ADC MASTER has inputs for External regular trigger, External injected trigger, and control bits EXTSEL[3:0] and JEXTSEL[3:0]. The ADC SLAVE has similar inputs. The diagram illustrates that the same external and injected triggers are shared between the master and slave ADC units.

The diagram illustrates the trigger architecture for an ADC Master and Slave. On the left, two groups of triggers are shown:

Both the ADC MASTER and ADC SLAVE have control bits for trigger selection: EXTSEL[3:0] for regular triggers and JEXTSEL[3:0] for injected triggers. The diagram shows that the same external triggers can be selected for both regular and injected conversions in both the master and slave units.

Diagram showing trigger sharing between ADC Master and ADC Slave. On the left, external triggers (EXTI mapped at product level: EXT0, EXT1, ..., EXT15) and injected triggers (JEXTI mapped at product level: JEXT0, JEXT1, ..., JEXT15) are shown. These triggers are connected to multiplexers within the ADC MASTER and ADC SLAVE blocks. The ADC MASTER has inputs for External regular trigger, External injected trigger, and control bits EXTSEL[3:0] and JEXTSEL[3:0]. The ADC SLAVE has similar inputs. The diagram illustrates that the same external and injected triggers are shared between the master and slave ADC units.

Table 87 to Table 88 give all the possible external triggers of the two ADCs for regular and injected conversion.

Table 87. ADC1 (master) & 2 (slave) - External triggers for regular channels

NameSourceTypeEXTSEL[3:0]
EXT0TIM1_CC1 eventInternal signal from on chip timers0000
EXT1TIM1_CC2 eventInternal signal from on chip timers0001
EXT2TIM1_CC3 eventInternal signal from on chip timers0010
EXT3TIM2_CC2 eventInternal signal from on chip timers0011
EXT4TIM3_TRGO eventInternal signal from on chip timers0100
EXT5TIM4_CC4 eventInternal signal from on chip timers0101
EXT6EXTI line 11External pin0110
EXT7Reserved0111
EXT8Reserved1000
EXT9TIM1_TRGO eventInternal signal from on chip timers1001
EXT10TIM1_TRGO2 eventInternal signal from on chip timers1010
EXT11TIM2_TRGO eventInternal signal from on chip timers1011
EXT12TIM4_TRGO eventInternal signal from on chip timers1100
EXT13TIM6_TRGO eventInternal signal from on chip timers1101
EXT14TIM15_TRGO eventInternal signal from on chip timers1110
EXT15TIM3_CC4 eventInternal signal from on chip timers1111

Table 88. ADC1 & ADC2 - External trigger for injected channels

NameSourceTypeJEXTSEL[3..0]
JEXT0TIM1_TRGO eventInternal signal from on chip timers0000
JEXT1TIM1_CC4 eventInternal signal from on chip timers0001
JEXT2TIM2_TRGO eventInternal signal from on chip timers0010
JEXT3TIM2_CC1 eventInternal signal from on chip timers0011
JEXT4TIM3_CC4 eventInternal signal from on chip timers0100
JEXT5TIM4_TRGO eventInternal signal from on chip timers0101
JEXT6EXTI line 15External pin0110
JEXT7Reserved-0111
JEXT8TIM1_TRGO2 eventInternal signal from on chip timers1000
JEXT9Reserved1001
JEXT10Reserved1010
JEXT11TIM3_CC3 eventInternal signal from on chip timers1011
JEXT12TIM3_TRGO eventInternal signal from on chip timers1100

Table 88. ADC1 & ADC2 - External trigger for injected channels (continued)

NameSourceTypeJEXTSEL[3..0]
JEXT13TIM3_CC1 eventInternal signal from on chip timers1101
JEXT14TIM6_TRGO eventInternal signal from on chip timers1110
JEXT15TIM15_TRGO eventInternal signal from on chip timers1111

15.3.19 Injected channel management

Triggered injection mode

To use triggered injection, the JAUTO bit in the ADCx_CFGR register must be cleared.

    1. 1. Start the conversion of a group of regular channels either by an external trigger or by setting the ADSTART bit in the ADCx_CR register.
    2. 2. If an external injected trigger occurs, or if the JADSTART bit in the ADCx_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.
  1. Figure 62 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 28 ADC clock cycles (that is two conversions with a sampling time of 1.5 clock periods), the minimum interval between triggers must be 29 ADC clock cycles.

Auto-injection mode

If the JAUTO bit in the ADCx_CFGR register is set, then 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 ADCx_SQR and ADCx_JSQR registers.

In this mode, the ADSTART bit in the ADCx_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, 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 regular sequencer's data in JAUTO mode, it is necessary to program it in circular mode (CIRC bit set in DMA_CCRx register). If the CIRC bit is reset (single-shot mode), the JAUTO sequence will be stopped upon DMA Transfer Complete event.

Figure 62. Injected conversion latency

Timing diagram for injected conversion latency. The diagram shows four waveforms: ADCCLK (a periodic square wave), Injection event (a single pulse), Reset ADC (a pulse that goes high after the injection event), and SOC (Start of Conversion, a pulse that goes high after the Reset ADC pulse). A horizontal double-headed arrow labeled 'max. latency (1)' indicates the time interval between the rising edge of the Injection event and the rising edge of the SOC pulse. Vertical dashed lines mark these two rising edges. The diagram is labeled 'ai16049b' in the bottom right corner.
Timing diagram for injected conversion latency. The diagram shows four waveforms: ADCCLK (a periodic square wave), Injection event (a single pulse), Reset ADC (a pulse that goes high after the injection event), and SOC (Start of Conversion, a pulse that goes high after the Reset ADC pulse). A horizontal double-headed arrow labeled 'max. latency (1)' indicates the time interval between the rising edge of the Injection event and the rising edge of the SOC pulse. Vertical dashed lines mark these two rising edges. The diagram is labeled 'ai16049b' in the bottom right corner.

1. The maximum latency value can be found in the electrical characteristics of the STM32F302xx datasheets.

15.3.20 Discontinuous mode (DISCEN, DISCNUM, JDISCEN)

Regular group mode

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

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

When an external trigger occurs, it starts the next n conversions selected in the ADCx_SQR registers until all the conversions in the sequence are done. The total sequence length is defined by the L[3:0] bits in the ADCx_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 ADCx_CFGR register. It converts the sequence selected in the ADCx_JSQR register, channel by channel, after an external injected trigger event. This is equivalent to discontinuous mode for regular channels where 'n' is fixed to 1.

When an external trigger occurs, it starts the next channel conversions selected in the ADCx_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 ADCx_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.

15.3.21 Queue of context for injected conversions

A queue of context is implemented to anticipate up to 2 contexts for the next injected sequence of conversions.

This context consists of:

All the parameters of the context are defined into a single register ADCx_JSQR and this register implements a queue of 2 buffers, allowing the bufferization of up to 2 sets of parameters:

Note: When configured in discontinuous mode (bit JDISCEN=1), only the last trigger of the injected sequence changes the context and consumes the Queue. The 1 st trigger only consumes the queue but others are still valid triggers as shown by the discontinuous mode example below (length = 3 for both contexts):

Behavior when changing the trigger or sequence context

The Figure 63 and Figure 64 show the behavior of the context Queue when changing the sequence or the triggers.

Figure 63. Example of JSQR queue of context (sequence change)

Timing diagram for Figure 63 showing JSQR queue behavior during sequence changes. It tracks 'Write JSQR' signals for sequences P1, P2, and P3, the 'JSQR queue' state (EMPTY, P1, P1,P2, P2, P2,P3, P3), 'Trigger 1' pulses, the 'ADC J context' (returned by reading JQSR), and the 'ADC state' (RDY, Conversion1, Conversion2, Conversion3).

MS30536V2

Timing diagram for Figure 63 showing JSQR queue behavior during sequence changes. It tracks 'Write JSQR' signals for sequences P1, P2, and P3, the 'JSQR queue' state (EMPTY, P1, P1,P2, P2, P2,P3, P3), 'Trigger 1' pulses, the 'ADC J context' (returned by reading JQSR), and the 'ADC state' (RDY, Conversion1, Conversion2, Conversion3).
  1. Parameters:
    P1: sequence of 3 conversions, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 4 conversions, hardware trigger 1

Figure 64. Example of JSQR queue of context (trigger change)

Timing diagram for Figure 64 showing JSQR queue behavior during trigger changes. It tracks 'Write JSQR' signals for sequences P1, P2, and P3, the 'JSQR queue' state (EMPTY, P1, P1,P2, P2, P2,P3, P3), 'Trigger 1' and 'Trigger 2' pulses (noting 'Ignored' events), the 'ADC J context' (returned by reading JQSR), and the 'ADC state' (RDY, Conversion1, Conversion2, RDY, Conversion1, RDY).

MS30537V2

Timing diagram for Figure 64 showing JSQR queue behavior during trigger changes. It tracks 'Write JSQR' signals for sequences P1, P2, and P3, the 'JSQR queue' state (EMPTY, P1, P1,P2, P2, P2,P3, P3), 'Trigger 1' and 'Trigger 2' pulses (noting 'Ignored' events), the 'ADC J context' (returned by reading JQSR), and the 'ADC state' (RDY, Conversion1, Conversion2, RDY, Conversion1, RDY).
  1. Parameters:
    P1: sequence of 2 conversions, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 2
    P3: sequence of 4 conversions, hardware trigger 1

Queue of context: Behavior when a queue overflow occurs

The Figure 65 and Figure 66 show the behavior of the context Queue if an overflow occurs before or during a conversion.

Figure 65. Example of JSQR queue of context with overflow before conversion

Timing diagram for Figure 65 showing JSQR queue overflow before conversion. The diagram tracks signals: Write JSQR, JSQR queue, JQOVF, Trigger 1, Trigger 2, ADC J context, ADC state, and JEOS. It shows P1, P2, and P4 being added to the queue, while P3 is ignored due to overflow. Conversion1 and Conversion2 are shown occurring for P1 and P2 respectively.

The diagram illustrates the state of the JSQR queue and ADC signals over time.
1. Write JSQR : Shows pulses for parameters P1, P2, P3, and P4.
2. JSQR queue : Starts as EMPTY . After P1 is written, it contains P1 . After P2, it contains P1, P2 . When P3 is written, it results in Overflow, ignored , and the JQOVF flag is set. After P4 is written, the queue contains P2 and P2, P4 . The JQOVF flag is later Cleared by SW .
3. ADC J context (returned by reading JQSR) : Shows EMPTY , then P1 , then P2 .
4. ADC state : Starts as RDY . It becomes Conversion1 (triggered by P1), then Conversion2 (triggered by P2), then returns to RDY , and finally becomes Conversion1 again (triggered by P4).
5. JEOS : Shows a pulse when the conversion sequence for P1 completes.
Reference: MS30538V2

Timing diagram for Figure 65 showing JSQR queue overflow before conversion. The diagram tracks signals: Write JSQR, JSQR queue, JQOVF, Trigger 1, Trigger 2, ADC J context, ADC state, and JEOS. It shows P1, P2, and P4 being added to the queue, while P3 is ignored due to overflow. Conversion1 and Conversion2 are shown occurring for P1 and P2 respectively.
  1. 1. Parameters:
    P1: sequence of 2 conversions, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 2
    P3: sequence of 3 conversions, hardware trigger 1
    P4: sequence of 4 conversions, hardware trigger 1

Figure 66. Example of JSQR queue of context with overflow during conversion

Timing diagram for Figure 66 showing JSQR queue overflow during conversion. Similar to Figure 65, but the overflow (P3) occurs while Conversion2 (for P2) is still active. The JQOVF flag is set during the conversion and cleared by software after the conversion sequence completes.

This diagram is similar to Figure 65 but with a key difference in the timing of the overflow.
1. Write JSQR : Pulses for P1, P2, P3, and P4.
2. JSQR queue : Starts as EMPTY . Contains P1 , then P1, P2 . When P3 is written while P2 is still being processed, it results in Overflow, ignored , and the JQOVF flag is set. After P4 is written, the queue contains P2 and P2, P4 . The JQOVF flag is Cleared by SW after the conversions are complete.
3. ADC J context : Shows EMPTY , then P1 , then P2 .
4. ADC state : Starts as RDY . It becomes Conversion1 (for P1), then Conversion2 (for P2). While Conversion2 is active, the overflow occurs. After Conversion2 finishes, it returns to RDY , and then becomes Conversion1 (for P4).
5. JEOS : Shows a pulse when the conversion sequence for P1 completes.
Reference: MS30538V2

Timing diagram for Figure 66 showing JSQR queue overflow during conversion. Similar to Figure 65, but the overflow (P3) occurs while Conversion2 (for P2) is still active. The JQOVF flag is set during the conversion and cleared by software after the conversion sequence completes.
  1. 1. Parameters:
    P1: sequence of 2 conversions, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 2
    P3: sequence of 3 conversions, hardware trigger 1
    P4: sequence of 4 conversions, hardware trigger 1

It is recommended to manage the queue overflows as described below:

Queue of context: Behavior when the queue becomes empty

Figure 67 and Figure 68 show the behavior of the context Queue when the Queue becomes empty in both cases JQM=0 or 1.

Figure 67. Example of JSQR queue of context with empty queue (case JQM=0)

Timing diagram showing the behavior of the JSQR queue when it becomes empty (case JQM=0). The diagram illustrates the sequence of events for writing contexts (P1, P2, P3) into the JSQR queue, triggering conversions, and the resulting ADC state. The queue is not empty and maintains P2 because JQM=0. The queue is not empty (P3 maintained).

The diagram shows the following signals and states over time:

MS30540V3

Timing diagram showing the behavior of the JSQR queue when it becomes empty (case JQM=0). The diagram illustrates the sequence of events for writing contexts (P1, P2, P3) into the JSQR queue, triggering conversions, and the resulting ADC state. The queue is not empty and maintains P2 because JQM=0. The queue is not empty (P3 maintained).
  1. 1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Note: When writing P3, the context changes immediately. However, because of internal resynchronization, there is a latency and if a trigger occurs just after or before writing P3, it can happen that the conversion is launched considering the context P2. To avoid this situation, the user must ensure that there is no ADC trigger happening when writing a new context that applies immediately.

Figure 68. Example of JSQR queue of context with empty queue (case JQM=1)

Timing diagram for Figure 68 showing the JSQR queue behavior when JQM=1. The diagram includes signals for Write JSQR, JSQR queue, Trigger 1, ADC J context, and ADC state. It shows sequences P1, P2, and P3 being added to the queue, and how the queue becomes empty and triggers are ignored when JQM=1.

The diagram illustrates the following sequence of events:

MS30541V1

Timing diagram for Figure 68 showing the JSQR queue behavior when JQM=1. The diagram includes signals for Write JSQR, JSQR queue, Trigger 1, ADC J context, and ADC state. It shows sequences P1, P2, and P3 being added to the queue, and how the queue becomes empty and triggers are ignored when JQM=1.
  1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Flushing the queue of context

The figures below show the behavior of the context Queue in various situations when the queue is flushed.

Figure 69. Flushing JSQR queue of context by setting JADSTP=1 (JQM=0). Case when JADSTP occurs during an ongoing conversion.

Timing diagram for Figure 69 showing the JSQR queue behavior when JADSTP=1 (JQM=0) during an ongoing conversion. The diagram includes signals for Write JSQR, JSQR queue, JADSTP, JADSTART, Trigger 1, ADC J context, and ADC state. It shows how setting JADSTP=1 flushes the queue and maintains the last active context (P2 is lost).

The diagram illustrates the following sequence of events:

MS30544V2

Timing diagram for Figure 69 showing the JSQR queue behavior when JADSTP=1 (JQM=0) during an ongoing conversion. The diagram includes signals for Write JSQR, JSQR queue, JADSTP, JADSTART, Trigger 1, ADC J context, and ADC state. It shows how setting JADSTP=1 flushes the queue and maintains the last active context (P2 is lost).
  1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Figure 70. Flushing JSQR queue of context by setting JADSTP=1 (JQM=0). Case when JADSTP occurs during an ongoing conversion and a new trigger occurs.

Timing diagram for Figure 70 showing the interaction between Write JSQR, JSQR queue, JADSTP, JADSTART, Trigger 1, ADC J context, and ADC state. It illustrates that when JADSTP is set during an ongoing conversion (P1) and a new trigger occurs, the queue is flushed and only the last active context (P3) is maintained, with P2 being lost.

The diagram shows the following signal transitions and states:

MS30543V1

Timing diagram for Figure 70 showing the interaction between Write JSQR, JSQR queue, JADSTP, JADSTART, Trigger 1, ADC J context, and ADC state. It illustrates that when JADSTP is set during an ongoing conversion (P1) and a new trigger occurs, the queue is flushed and only the last active context (P3) is maintained, with P2 being lost.
  1. 1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Figure 71. Flushing JSQR queue of context by setting JADSTP=1 (JQM=0). Case when JADSTP occurs outside an ongoing conversion

Timing diagram for Figure 71 showing the interaction between Write JSQR, JSQR queue, JADSTP, JADSTART, Trigger 1, ADC J context, and ADC state. It illustrates that when JADSTP is set outside an ongoing conversion, the queue is flushed and only the last active context (P3) is maintained, with P2 being lost.

The diagram shows the following signal transitions and states:

MS30544V1

Timing diagram for Figure 71 showing the interaction between Write JSQR, JSQR queue, JADSTP, JADSTART, Trigger 1, ADC J context, and ADC state. It illustrates that when JADSTP is set outside an ongoing conversion, the queue is flushed and only the last active context (P3) is maintained, with P2 being lost.
  1. 1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Figure 72. Flushing JSQR queue of context by setting JADSTP=1 (JQM=1)

Timing diagram for Figure 72 showing the effect of setting JADSTP=1 on the JSQR queue. It tracks the JSQR queue, JADSTP/JADSTART signals, Trigger 1, ADC J context, and ADC state over time. When JADSTP is set, the queue is flushed and becomes empty, losing P2. Subsequent triggers result in only P1 and P3 being processed.

The diagram illustrates the sequence of events when flushing the JSQR queue by setting JADSTP=1 (JQM=1).
1. Write JSQR: P1 and P2 are written to the queue.
2. JSQR queue: Initially EMPTY, then contains P1, then P1 and P2.
3. JADSTP: Set by software (S/W).
4. JADSTART: Reset by hardware (H/W), then Set by S/W.
5. Trigger 1: Hardware trigger occurs.
6. ADC J context: Returns EMPTY (0x0000) because the queue was flushed.
7. ADC state: RDY → Conv1 (Aborted) → STP → RDY.
8. Subsequent events: After JADSTP is reset by H/W and then Set by S/W again, a second Trigger 1 occurs. The JSQR queue now contains P3. The ADC J context returns P3. The ADC state goes RDY → Conversion1 → RDY.
A note indicates: "Queue is flushed and becomes empty (P2 is lost)".
Reference: MS30545V1.

Timing diagram for Figure 72 showing the effect of setting JADSTP=1 on the JSQR queue. It tracks the JSQR queue, JADSTP/JADSTART signals, Trigger 1, ADC J context, and ADC state over time. When JADSTP is set, the queue is flushed and becomes empty, losing P2. Subsequent triggers result in only P1 and P3 being processed.
  1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Figure 73. Flushing JSQR queue of context by setting ADDIS=1 (JQM=0)

Timing diagram for Figure 73 showing the effect of setting ADDIS=1 on the JSQR queue. It tracks the JSQR queue, ADDIS signal, ADC J context, and ADC state. When ADDIS is set, the queue is flushed but maintains the last active context (P1). P2 is lost. The ADC state becomes OFF.

The diagram illustrates the sequence of events when flushing the JSQR queue by setting ADDIS=1 (JQM=0).
1. JSQR queue: Initially contains P1 and P2.
2. ADDIS: Set by software (S/W).
3. ADC J context: Returns P1 (the last active context).
4. ADC state: RDY → REQ-OFF → OFF.
5. Subsequent events: After ADDIS is reset by hardware (H/W), the JSQR queue contains only P1.
A note indicates: "Queue is flushed and maintains the last active context (P2 which was not consumed is lost)".
Reference: MS30546V1.

Timing diagram for Figure 73 showing the effect of setting ADDIS=1 on the JSQR queue. It tracks the JSQR queue, ADDIS signal, ADC J context, and ADC state. When ADDIS is set, the queue is flushed but maintains the last active context (P1). P2 is lost. The ADC state becomes OFF.
  1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Figure 74. Flushing JSQR queue of context by setting ADDIS=1 (JQM=1)

Timing diagram for Figure 74 showing the flushing of the JSQR queue. The diagram illustrates the state of the JSQR queue, ADDIS register, ADC J context, and ADC state over time. The JSQR queue starts with P1 and P2. When ADDIS is set by software, the queue becomes empty. The ADC J context is then read as 0x0000. The ADC state changes from RDY to REQ-OFF and then to OFF when ADDIS is reset by hardware.

Figure 74 is a timing diagram illustrating the flushing of the JSQR queue. The diagram shows four horizontal timelines:

The diagram is labeled with MS30547V2.

Timing diagram for Figure 74 showing the flushing of the JSQR queue. The diagram illustrates the state of the JSQR queue, ADDIS register, ADC J context, and ADC state over time. The JSQR queue starts with P1 and P2. When ADDIS is set by software, the queue becomes empty. The ADC J context is then read as 0x0000. The ADC state changes from RDY to REQ-OFF and then to OFF when ADDIS is reset by hardware.
  1. Parameters:
    P1: sequence of 1 conversion, hardware trigger 1
    P2: sequence of 1 conversion, hardware trigger 1
    P3: sequence of 1 conversion, hardware trigger 1

Changing context from hardware to software (or software to hardware) injected trigger

When changing the context from hardware trigger to software injected trigger, it is necessary to stop the injected conversions by setting JADSTP=1 after the last hardware triggered conversions. This is necessary to re-enable the software trigger (a rising edge on JADSTART is necessary to start a software injected conversion). Refer to Figure 75 .

When changing the context from software trigger to hardware injected trigger, after the last software trigger, it is necessary to set JADSTART=1 to enable the hardware triggers. Refer to Figure 75 .

Figure 75. Example of JSQR queue of context when changing SW and HW triggers

Timing diagram for Figure 75 showing the JSQR queue of context when changing software and hardware triggers. The diagram illustrates the state of the JSQR queue, H/W trigger, ADC J context, ADC state, JADSTART, and JADSTP over time. The JSQR queue contains sequences P1, P2, P3, and P4. P1 and P2 are hardware triggers, P3 is a software trigger, and P4 is a hardware trigger. The ADC state shows conversions triggered by hardware and software. JADSTART is set by software to start conversions, and JADSTP is set by software to stop them.

Figure 75 is a timing diagram illustrating the JSQR queue of context when changing software and hardware triggers. The diagram shows six horizontal timelines:

The diagram is labeled with MS30548V1.

Timing diagram for Figure 75 showing the JSQR queue of context when changing software and hardware triggers. The diagram illustrates the state of the JSQR queue, H/W trigger, ADC J context, ADC state, JADSTART, and JADSTP over time. The JSQR queue contains sequences P1, P2, P3, and P4. P1 and P2 are hardware triggers, P3 is a software trigger, and P4 is a hardware trigger. The ADC state shows conversions triggered by hardware and software. JADSTART is set by software to start conversions, and JADSTP is set by software to stop them.
  1. Parameters:
    P1: sequence of 1 conversion, hardware trigger (JEXTEN /=0x0)
    P2: sequence of 1 conversion, hardware trigger (JEXTEN /= 0x0)
    P3: sequence of 1 conversion, software trigger (JEXTEN = 0x0)
    P4: sequence of 1 conversion, hardware trigger (JEXTEN /= 0x0)

Queue of context: Starting the ADC with an empty queue

The following procedure must be followed to start ADC operation with an empty queue, in case the first context is not known at the time the ADC is initialized. This procedure is only applicable when JQM bit is reset:

  1. 5. Write a dummy JSQR with JEXTEN not equal to 0 (otherwise triggering a software conversion)
  2. 6. Set JADSTART
  3. 7. Set JADSTP
  4. 8. Wait until JADSTART is reset
  5. 9. Set JADSTART.

15.3.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 12, 10, 8, or 6 bits by programming the control bits RES[1:0]. Figure 80 , Figure 81 , Figure 82 and Figure 83 show the conversion result format with respect to the resolution as well as to the data alignment.

Lower resolution allows 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 89 .

Table 89. T SAR timings depending on resolution

RES (bits)T SAR (ADC clock cycles)T SAR (ns) at F ADC =72 MHzT ADC (ADC clock cycles) (with Sampling Time= 1.5 ADC clock cycles)T ADC (ns) at F ADC =72 MHz
1212.5 ADC clock cycles173.6 ns14 ADC clock cycles194.4 ns
1010.5 ADC clock cycles145.8 ns12 ADC clock cycles166.7 ns
88.5 ADC clock cycles118.0 ns10 ADC clock cycles138.9 ns
66.5 ADC clock cycles90.3 ns8 ADC clock cycles111.1 ns

15.3.23 End of conversion, 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 ADCx_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 ADCx_DR.

The ADC sets the JEOC flag as soon as a new injected conversion data is available in one of the ADCx_JDRy register. 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 ADCx_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.

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

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

Figure 76. Single conversions of a sequence, software trigger

Timing diagram for single conversions of a sequence with software trigger. The diagram shows four signal lines: ADSTART, EOC, EOS, and ADC state/ADC_DR. ADSTART is triggered by software (SW) and hardware (HW). EOC pulses for each conversion. EOS goes high after the last conversion (CH17) and low when cleared. ADC state shows a sequence of RDY, CH1, CH9, CH10, CH17, RDY, CH1, CH9, CH10, CH17, RDY. ADC_DR shows data D1, D9, D10, D17, D1, D9, D10, D17. A legend indicates 'Indicative timings' and reference MS30549V1.
Timing diagram for single conversions of a sequence with software trigger. The diagram shows four signal lines: ADSTART, EOC, EOS, and ADC state/ADC_DR. ADSTART is triggered by software (SW) and hardware (HW). EOC pulses for each conversion. EOS goes high after the last conversion (CH17) and low when cleared. ADC state shows a sequence of RDY, CH1, CH9, CH10, CH17, RDY, CH1, CH9, CH10, CH17, RDY. ADC_DR shows data D1, D9, D10, D17, D1, D9, D10, D17. A legend indicates 'Indicative timings' and reference MS30549V1.
  1. 1. EXTEN=0x0, CONT=0
  2. 2. Channels selected = 1,9, 10, 17; AUTDLY=0.

Figure 77. Continuous conversion of a sequence, software trigger

Timing diagram for continuous conversion of a sequence with software trigger. The diagram shows five signal lines: ADCSTART, EOC, EOS, ADSTP, and ADC state/ADC_DR. ADCSTART is triggered by software (SW) and hardware (HW). EOC pulses for each conversion. EOS goes high after the last conversion (CH17) and low when cleared. ADSTP goes high when the sequence reaches CH10 and low when cleared. ADC state shows a sequence of READY, CH1, CH9, CH10, CH17, CH1, CH9, CH10, STP, READY, CH1, CH9. ADC_DR shows data D1, D9, D10, D17, D1, D9, D1. A legend indicates 'Indicative timings' and reference MS30550V1.
Timing diagram for continuous conversion of a sequence with software trigger. The diagram shows five signal lines: ADCSTART, EOC, EOS, ADSTP, and ADC state/ADC_DR. ADCSTART is triggered by software (SW) and hardware (HW). EOC pulses for each conversion. EOS goes high after the last conversion (CH17) and low when cleared. ADSTP goes high when the sequence reaches CH10 and low when cleared. ADC state shows a sequence of READY, CH1, CH9, CH10, CH17, CH1, CH9, CH10, STP, READY, CH1, CH9. ADC_DR shows data D1, D9, D10, D17, D1, D9, D1. A legend indicates 'Indicative timings' and reference MS30550V1.
  1. 1. EXTEN=0x0, CONT=1
  2. 2. Channels selected = 1,9, 10, 17; AUTDLY=0.

Figure 78. Single conversions of a sequence, hardware trigger

Timing diagram for single conversions of a sequence with hardware trigger. It shows the relationship between ADSTART, EOC, EOS, TRGX, ADC state, and ADC_DR signals over time. The diagram illustrates the flow from a hardware trigger to the conversion of four channels (CH1, CH2, CH3, CH4) and the resulting data (D1, D2, D3, D4) being stored in the ADC_DR register. The ADC state transitions from RDY to CH1, CH2, CH3, CH4, READ, CH1, CH2, CH3, CH4, and back to RDY. The legend indicates that rising edges represent 'by s/w', 'by h/w', and 'triggered' events, while falling edges represent 'ignored' events. A note 'Indicative timings' is present.
Timing diagram for single conversions of a sequence with hardware trigger. It shows the relationship between ADSTART, EOC, EOS, TRGX, ADC state, and ADC_DR signals over time. The diagram illustrates the flow from a hardware trigger to the conversion of four channels (CH1, CH2, CH3, CH4) and the resulting data (D1, D2, D3, D4) being stored in the ADC_DR register. The ADC state transitions from RDY to CH1, CH2, CH3, CH4, READ, CH1, CH2, CH3, CH4, and back to RDY. The legend indicates that rising edges represent 'by s/w', 'by h/w', and 'triggered' events, while falling edges represent 'ignored' events. A note 'Indicative timings' is present.
  1. 1. TRGX (1) (over-frequency) is selected as trigger source, EXTEN = 01, CONT = 0
  2. 2. Channels selected = 1, 2, 3, 4; AUTDLY=0.

Figure 79. Continuous conversions of a sequence, hardware trigger

Timing diagram for continuous conversions of a sequence with hardware trigger. It shows the relationship between ADSTART, EOC, EOS, ADSTP, TRGX, ADC state, and ADC_DR signals. The diagram illustrates continuous conversion of four channels (CH1, CH2, CH3, CH4) with data (D1, D2, D3, D4) being stored in the ADC_DR register. The ADC state transitions from RDY to CH1, CH2, CH3, CH4, CH1, CH2, CH3, CH4, CH1, STOP, and back to RDY. The legend indicates that rising edges represent 'by s/w', 'by h/w', and 'triggered' events, while falling edges represent 'ignored' events. A note 'Not in scale timings' is present.
Timing diagram for continuous conversions of a sequence with hardware trigger. It shows the relationship between ADSTART, EOC, EOS, ADSTP, TRGX, ADC state, and ADC_DR signals. The diagram illustrates continuous conversion of four channels (CH1, CH2, CH3, CH4) with data (D1, D2, D3, D4) being stored in the ADC_DR register. The ADC state transitions from RDY to CH1, CH2, CH3, CH4, CH1, CH2, CH3, CH4, CH1, STOP, and back to RDY. The legend indicates that rising edges represent 'by s/w', 'by h/w', and 'triggered' events, while falling edges represent 'ignored' events. A note 'Not in scale timings' is present.
  1. 1. TRGX is selected as trigger source, EXTEN = 10, CONT = 1
  2. 2. Channels selected = 1, 2, 3, 4; AUTDLY=0.

15.3.26 Data management

Data register, data alignment and offset (ADCx_DR, OFFSETy, OFFSETy_CH, ALIGN)

Data and alignment

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

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

The ALIGN bit in the ADCx_CFGR register selects the alignment of the data stored after conversion. Data can be right- or left-aligned as shown in Figure 80 , Figure 81 , Figure 82 and Figure 83 .

Special case: when left-aligned, the data are aligned on a half-word basis except when the resolution is set to 6-bit. In that case, the data are aligned on a byte basis as shown in Figure 82 and Figure 83 .

Offset

An offset y (y=1,2,3,4) can be applied to a channel by setting the bit OFFSETy_EN=1 into ADCx_OFRY register. The channel to which the offset will be applied is programmed into the bits OFFSETy_CH[4:0] of ADCx_OFRY register. In this case, the converted value is decreased by the user-defined offset written in the bits OFFSETy[11:0]. The result may be a negative value so the read data is signed and the SEXT bit represents the extended sign value.

Table 92 describes how the comparison is performed for all the possible resolutions for analog watchdog 1.

Table 90. Offset computation versus data resolution

Resolution
(bits
RES[1:0])
Substraction between raw
converted data and offset
ResultComments
Raw converted
data, left aligned
Offset
00: 12-bitDATA[11:0]OFFSET[11:0]Signed 12-bit data-
01: 10-bitDATA[11:2],00OFFSET[11:0]Signed 10-bit dataThe user must configure OFFSET[1:0] to "00"
10: 8-bitDATA[11:4],0000OFFSET[11:0]Signed 8-bit dataThe user must configure OFFSET[3:0] to "0000"
11: 6-bitDATA[11:6],000000OFFSET[11:0]Signed 6-bit dataThe user must configure OFFSET[5:0] to "000000"

When reading data from ADCx_DR (regular channel) or from ADCx_JDRy (injected channel, y=1,2,3,4) corresponding to the channel "i":

Figure 80 , Figure 81 , Figure 82 and Figure 83 show alignments for signed and unsigned data.

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

Diagram showing right alignment for unsigned values with 12-bit, 10-bit, 8-bit, and 6-bit data formats. Each format shows a 16-bit register with data bits D15-D0 right-aligned and the upper bits set to 0.

12-bit data
bit15 bit7 bit0

0000D11D10D9D8D7D6D5D4D3D2D1D0

10-bit data
bit15 bit7 bit0

000000D9D8D7D6D5D4D3D2D1D0

8-bit data
bit15 bit7 bit0

00000000D7D6D5D4D3D2D1D0

6-bit data
bit15 bit7 bit0

0000000000D5D4D3D2D1D0

MS31015V1

Diagram showing right alignment for unsigned values with 12-bit, 10-bit, 8-bit, and 6-bit data formats. Each format shows a 16-bit register with data bits D15-D0 right-aligned and the upper bits set to 0.

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

Diagram showing right alignment for signed values with 12-bit, 10-bit, 8-bit, and 6-bit data formats. Each format shows a 16-bit register with data bits D15-D0 right-aligned, the upper bits filled with SEXT (sign extension), and the lower bits containing the data.

12-bit data
bit15 bit7 bit0

SEXTSEXTSEXTSEXTD11D10D9D8D7D6D5D4D3D2D1D0

10-bit data
bit15 bit7 bit0

SEXTSEXTSEXTSEXTSEXTSEXTD9D8D7D6D5D4D3D2D1D0

8-bit data
bit15 bit7 bit0

SEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTD7D6D5D4D3D2D1D0

6-bit data
bit15 bit7 bit0

SEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTD5D4D3D2D1D0

MS31016V1

Diagram showing right alignment for signed values with 12-bit, 10-bit, 8-bit, and 6-bit data formats. Each format shows a 16-bit register with data bits D15-D0 right-aligned, the upper bits filled with SEXT (sign extension), and the lower bits containing the data.

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

Diagram showing 12-bit, 10-bit, 8-bit, and 6-bit data alignment for left alignment with offset disabled. Each section shows a 16-bit register with data bits D15-D0 and trailing zeros.

12-bit data
bit15 bit7 bit0

D11D10D9D8D7D6D5D4D3D2D1D00000

10-bit data
bit15 bit7 bit0

D9D8D7D6D5D4D3D2D1D0000000

8-bit data
bit15 bit7 bit0

D7D6D5D4D3D2D1D000000000

6-bit data
bit15 bit7 bit0

00000000D5D4D3D2D1D000

MS31017V1

Diagram showing 12-bit, 10-bit, 8-bit, and 6-bit data alignment for left alignment with offset disabled. Each section shows a 16-bit register with data bits D15-D0 and trailing zeros.

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

Diagram showing 12-bit, 10-bit, 8-bit, and 6-bit data alignment for left alignment with offset enabled (signed value). Each section shows a 16-bit register with a SEXT bit followed by data bits and trailing zeros.

12-bit data
bit15 bit7 bit0

SEXTD11D10D9D8D7D6D5D4D3D2D1D0000

10-bit data
bit15 bit7 bit0

SEXTD9D8D7D6D5D4D3D2D1D000000

8-bit data
bit15 bit7 bit0

SEXTD7D6D5D4D3D2D1D00000000

6-bit data
bit15 bit7 bit0

SEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTD5D4D3D2D1D00

MS31018V1

Diagram showing 12-bit, 10-bit, 8-bit, and 6-bit data alignment for left alignment with offset enabled (signed value). Each section shows a 16-bit register with a SEXT bit followed by data bits and trailing zeros.

ADC overrun (OVR, OVRMOD)

The overrun flag (OVR) notifies of a buffer overrun event, when the regular converted data was not read (by the CPU or the DMA) before new converted data became available.

The OVR flag is set if the EOC flag is still 1 at the time when a new conversion completes. An interrupt can be generated if bit OVRIE=1.

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

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

It is possible to configure if data is preserved or overwritten when an overrun event occurs by programming the control bit OVRMOD:

Figure 84. Example of overrun (OVR)

Timing diagram showing ADC signals (ADSTART, EOC, EOS, OVR, ADSTP, TRGx) and data states (RDY, CH1-CH7, STOP) over time. It illustrates an overrun condition where a new conversion (CH5) completes before the previous data (CH4) is read. Two data register scenarios are shown: OVRMOD=0 (data D4 is preserved) and OVRMOD=1 (data D4 is overwritten by D5).

The diagram illustrates the timing of an ADC overrun event. The top section shows signal transitions for ADSTART (1) , EOC, EOS, OVR, ADSTP, and TRGx (1) . Below this, the 'ADC state (2) ' is shown as a sequence of states: RDY, CH1, CH2, CH3, CH4, CH5, CH6, CH7, STOP, and RDY. An 'Overrun' condition is indicated during the CH5 state. The 'ADC_DR read access' line shows when data is read from the data register. Below this, two data register scenarios are shown: 'ADC_DR (OVRMOD=0)' where data D4 is preserved despite the overrun, and 'ADC_DR (OVRMOD=1)' where data D4 is overwritten by D5. A legend at the bottom indicates that rising arrows represent 'by s/w' (software), 'by h/w' (hardware), and 'triggered' events. A box labeled 'Indicative timings' is also present. The document code MS31019V1 is in the bottom right corner.

Timing diagram showing ADC signals (ADSTART, EOC, EOS, OVR, ADSTP, TRGx) and data states (RDY, CH1-CH7, STOP) over time. It illustrates an overrun condition where a new conversion (CH5) completes before the previous data (CH4) is read. Two data register scenarios are shown: OVRMOD=0 (data D4 is preserved) and OVRMOD=1 (data D4 is overwritten by D5).

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 conversion 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 ADCx_DR register can be read. OVRMOD should 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 (if there is an analog watchdog for instance). In this case, the OVRMOD bit must be configured to 1 and OVR flag should be ignored by the software. An overrun event will not prevent the ADC from continuing to convert and the ADCx_DR register will always contain the latest conversion.

Managing conversions using the DMA

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

When the DMA mode is enabled (DMAEN bit set to 1 in the ADCx_CFGR register in single ADC mode or MDMA different from 0b00 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 ADCx_DR register to the destination location selected by the software.

Despite this, if an overrun occurs (OVR=1) because the DMA could not 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. Which means that all the data transferred to the RAM can be considered as valid.

Depending on the configuration of OVRMOD bit, the data is either preserved or overwritten (refer to Section : ADC overrun (OVR, OVRMOD) ).

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

Two different DMA modes are proposed depending on the application use and are configured with bit DMACFG of the ADCx_CFGR register in single ADC mode, or with bit DMACFG of the ADCx_CCR register in dual ADC mode:

DMA one shot mode (DMACFG=0)

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 DMA_EOT interrupt occurs - refer to DMA paragraph) 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 (DMACFG=1)

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.

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

This is a way to automatically adapt the speed of the ADC to the speed of the system which will read 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 conversions 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 re-start 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 89 ).

To stop a conversion in continuous auto-injection mode combined with autodelay 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 re-start 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 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 85. AUTDLY=1, regular conversion in continuous mode, software trigger

Timing diagram for Figure 85 showing ADC signals and state transitions. The diagram includes waveforms for ADSTART(1), EOC, EOS, ADSTP, ADC_DR read access, ADC state, and ADC_DR. The ADC state transitions between RDY, CH1, DLY, CH2, CH3, STOP, and RDY. The ADC_DR register holds data D1, D2, and D3. Triggers are indicated by 'by SW' (software) and 'by HW' (hardware) labels. The diagram is labeled 'Indicative timings' and 'MS31020V1'.

The timing diagram illustrates the operation of an ADC in continuous mode with AUTDLY=1, triggered by software. The signals shown are:

Triggers are indicated by arrows: 'by SW' (software) for the initial start and 'by HW' (hardware) for subsequent restarts after a delay (DLY). The diagram is labeled 'Indicative timings' and 'MS31020V1'.

Timing diagram for Figure 85 showing ADC signals and state transitions. The diagram includes waveforms for ADSTART(1), EOC, EOS, ADSTP, ADC_DR read access, ADC state, and ADC_DR. The ADC state transitions between RDY, CH1, DLY, CH2, CH3, STOP, and RDY. The ADC_DR register holds data D1, D2, and D3. Triggers are indicated by 'by SW' (software) and 'by HW' (hardware) labels. The diagram is labeled 'Indicative timings' and 'MS31020V1'.
  1. 1. AUTDLY=1
  2. 2. Regular configuration: EXTEN=0x0 (SW trigger), CONT=1, CHANNELS = 1,2,3
  3. 3. Injected configuration DISABLED

Figure 86. AUTODLY=1, regular HW conversions interrupted by injected conversions (DISCEN=0; JDISCEN=0)

Timing diagram showing ADC state, triggers, and data registers (ADC_DR, ADC_JDR1, ADC_JDR2) over time. It illustrates regular conversions (CH1, CH2, CH3) and injected conversions (CH5, CH6) with delays (DLY).

The diagram illustrates the timing of ADC conversions when AUTODLY=1. The 'Regular trigger' line shows a software (s/w) rising edge followed by hardware (h/w) rising edges. The 'ADC state' line shows the sequence: RDY → CH1 regular → DLY (CH1) → CH2 regular → DLY (CH2) → CH5 injected → CH6 injected → CH3 regular → DLY (CH3) → CH1 regular → DLY (CH1) → CH2 regular. The 'EOC' (End of Conversion) signal pulses for each regular conversion. The 'EOS' (End of Sequence) signal pulses after CH3 regular. The 'ADC_DR' (Data Register) contains D1, D2, D3, and D1 for the regular conversions. The 'Injected trigger' line shows a hardware rising edge during the regular sequence, which is ignored. A subsequent hardware rising edge starts an injected sequence: DLY (inj) → CH5 injected → CH6 injected. The 'JEOS' signal pulses after CH6 injected. The 'ADC_JDR1' and 'ADC_JDR2' registers contain D5 and D6 respectively. A legend indicates that solid arrows represent software (s/w) triggers and dashed arrows represent hardware (h/w) triggers. The text 'Indicative timings' is present at the bottom right of the diagram area.

Timing diagram showing ADC state, triggers, and data registers (ADC_DR, ADC_JDR1, ADC_JDR2) over time. It illustrates regular conversions (CH1, CH2, CH3) and injected conversions (CH5, CH6) with delays (DLY).
  1. 1. AUTODLY=1
  2. 2. Regular configuration: EXTEN=0x1 (HW trigger), CONT=0, DISCEN=0, CHANNELS = 1, 2, 3
  3. 3. Injected configuration: JEXTEN=0x1 (HW Trigger), JDISCEN=0, CHANNELS = 5,6

Figure 87. AUTODLY=1, regular HW conversions interrupted by injected conversions (DISCEN=1, JDISCEN=1)

Timing diagram showing regular and injected ADC conversions with delays and triggers. The diagram includes signals for Regular trigger, ADC state (RDY, CH1, DLY, CH2, CH5, CH6, CH3), EOC, EOS, ADC_DR, read access, Injected trigger, JEOS, ADC_JDR1, and ADC_JDR2. It illustrates how injected conversions (CH5, CH6) interrupt regular conversions (CH1, CH2, CH3) when DISCEN=1 and JDISCEN=1. Delays (DLY) are shown for regular channels and the injected sequence. Data values D1, D2, D3, D5, and D6 are indicated in the ADC_DR and ADC_JDR registers.

The timing diagram illustrates the sequence of events for regular and injected ADC conversions. The 'Regular trigger' signal shows falling edges that initiate regular conversions. The 'ADC state' shows the sequence of channels: CH1 (regular), DLY (CH1), CH2 (regular), DLY (CH2), CH5 (injected), CH6 (injected), CH3 (regular), DLY (CH3), CH1 (regular), DLY (CH1), CH2 (regular). The 'EOC' (End of Conversion) signal pulses for each regular conversion. The 'EOS' (End of Sequence) signal pulses when the regular sequence (CH1, CH2, CH3) is complete. The 'ADC_DR' (Data Register) shows data values D1, D2, D3 for regular conversions. The 'Injected trigger' signal shows falling edges that initiate injected conversions. The 'JEOS' (End of Injected Sequence) signal pulses when the injected sequence (CH5, CH6) is complete. The 'ADC_JDR1' and 'ADC_JDR2' registers show data values D5 and D6 for injected conversions. The diagram also indicates 'Ignored' triggers and 'Not ignored (occurs during injected sequence)' triggers. A legend at the bottom indicates 'by SW' (software trigger) and 'by HW' (hardware trigger) for the regular trigger. A box labeled 'Indicative timings' is present in the bottom right of the diagram area.

Timing diagram showing regular and injected ADC conversions with delays and triggers. The diagram includes signals for Regular trigger, ADC state (RDY, CH1, DLY, CH2, CH5, CH6, CH3), EOC, EOS, ADC_DR, read access, Injected trigger, JEOS, ADC_JDR1, and ADC_JDR2. It illustrates how injected conversions (CH5, CH6) interrupt regular conversions (CH1, CH2, CH3) when DISCEN=1 and JDISCEN=1. Delays (DLY) are shown for regular channels and the injected sequence. Data values D1, D2, D3, D5, and D6 are indicated in the ADC_DR and ADC_JDR registers.

MS31022V1

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

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

Timing diagram for Figure 88 showing regular continuous conversions interrupted by injected conversions. The diagram includes signals for ADSTART, ADC state (RDY, CH1, CH2, CH5, CH6, CH3), EOC, EOS, ADC_DR read access, ADC_DR (D1, D2, D3), Injected trigger, JEOS, ADC_JDR1 (D5), and ADC_JDR2 (D6). It illustrates the sequence of regular conversions (CH1, CH2, CH3) being interrupted by injected conversions (CH5, CH6). Delays (DLY) are shown for regular channels. A legend indicates 'by s/w' (software) and 'by h/w' (hardware) triggers.
Timing diagram for Figure 88 showing regular continuous conversions interrupted by injected conversions. The diagram includes signals for ADSTART, ADC state (RDY, CH1, CH2, CH5, CH6, CH3), EOC, EOS, ADC_DR read access, ADC_DR (D1, D2, D3), Injected trigger, JEOS, ADC_JDR1 (D5), and ADC_JDR2 (D6). It illustrates the sequence of regular conversions (CH1, CH2, CH3) being interrupted by injected conversions (CH5, CH6). Delays (DLY) are shown for regular channels. A legend indicates 'by s/w' (software) and 'by h/w' (hardware) triggers.
  1. 1. AUTODLY=1
  2. 2. Regular configuration: EXTEN=0x0 (SW trigger), CONT=1, DISCEN=0, CHANNELS = 1, 2, 3
  3. 3. Injected configuration: JEXTEN=0x1 (HW Trigger), JDISCEN=0, CHANNELS = 5,6

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

Timing diagram for Figure 89 showing AUTODLY=1 in auto-injected mode (JAUTO=1). The diagram shows a sequence of regular conversions (CH1, CH2, CH3) and injected conversions (CH5, CH6) occurring without delay between them. Signals include ADSTART, ADC state (RDY, CH1, CH2, CH5, CH6, CH3), EOC, EOS, ADC_DR read access, ADC_DR (D1, D2, D3), JEOS, ADC_JDR1 (D5), and ADC_JDR2 (D6). A legend indicates 'by s/w' (software) and 'by h/w' (hardware) triggers.
Timing diagram for Figure 89 showing AUTODLY=1 in auto-injected mode (JAUTO=1). The diagram shows a sequence of regular conversions (CH1, CH2, CH3) and injected conversions (CH5, CH6) occurring without delay between them. Signals include ADSTART, ADC state (RDY, CH1, CH2, CH5, CH6, CH3), EOC, EOS, ADC_DR read access, ADC_DR (D1, D2, D3), JEOS, ADC_JDR1 (D5), and ADC_JDR2 (D6). A legend indicates 'by s/w' (software) and 'by h/w' (hardware) triggers.
  1. 1. AUTODLY=1
  2. 2. Regular configuration: EXTEN=0x0 (SW trigger), CONT=1, DISCEN=0, CHANNELS = 1, 2
  3. 3. Injected configuration: JAUTO=1, CHANNELS = 5,6

15.3.28 Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)

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

Figure 90. Analog watchdog's guarded area

Figure 90. Analog watchdog's guarded area. A graph showing Analog voltage on the y-axis. Two horizontal lines represent the Higher threshold (HTR) and Lower threshold (LTR). The area between these thresholds is shaded and labeled 'Guarded area'. The diagram is labeled ai16048.
Figure 90. Analog watchdog's guarded area. A graph showing Analog voltage on the y-axis. Two horizontal lines represent the Higher threshold (HTR) and Lower threshold (LTR). The area between these thresholds is shaded and labeled 'Guarded area'. The diagram is labeled ai16048.

AWDx flag and interrupt

An interrupt can be enabled for each of the 3 analog watchdogs by setting AWDxIE in the ADCx_IER register (x=1,2,3).

AWDx (x=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 ADCx_CFGFR register. This watchdog monitors whether either one selected channel or all enabled channels (1) remain within a configured voltage range (window).

Table 91 shows how the ADCx_CFGFR registers should be configured to enable the analog watchdog on one or more channels.

Table 91. 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 AWD1CH[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 bits HT1[11:0] and LT1[11:0] of the ADCx_TR1 register for the analog watchdog 1. When converting data with a resolution of less than 12 bits (according to bits RES[1:0]), the LSB of the programmed thresholds must be kept cleared because the internal comparison is always performed on the full 12-bit raw converted data (left aligned).

Table 92 describes how the comparison is performed for all the possible resolutions for analog watchdog 1.

Table 92. Analog watchdog 1 comparison

Resolution
(bit
RES[1:0])
Analog watchdog comparison
between:
Comments
Raw converted
data, left aligned (1)
Thresholds
00: 12-bitDATA[11:0]LT1[11:0] and
HT1[11:0]
-
01: 10-bitDATA[11:2],00LT1[11:0] and
HT1[11:0]
User must configure LT1[1:0] and HT1[1:0] to 00
10: 8-bitDATA[11:4],0000LT1[11:0] and
HT1[11:0]
User must configure LT1[3:0] and HT1[3:0] to 0000
11: 6-bitDATA[11:6],000000LT1[11:0] and
HT1[11:0]
User must configure LT1[5:0] and HT1[5:0] to 000000
  1. 1. The watchdog comparison is performed on the raw converted data before any alignment calculation and before applying any offsets (the data which is compared is not signed).

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 AWDxCH[18:1] (x=2,3).

The corresponding watchdog is enabled when any bit of AWDxCH[18:0] (x=2,3) is set.

They are limited to a resolution of 8 bits and only the 8 MSBs of the thresholds can be programmed into HTx[7:0] and LTx[7:0]. Table 93 describes how the comparison is performed for all the possible resolutions.

Table 93. Analog watchdog 2 and 3 comparison

Resolution
(bits
RES[1:0])
Analog watchdog comparison between:Comments
Raw converted data,
left aligned (1)
Thresholds
00: 12-bitDATA[11:4]LTx[7:0] and
HTx[7:0]
DATA[3:0] are not relevant for the comparison
01: 10-bitDATA[11:4]LTx[7:0] and
HTx[7:0]
DATA[3:2] are not relevant for the comparison
10: 8-bitDATA[11:4]LTx[7:0] and
HTx[7:0]
-
11: 6-bitDATA[11:6],00LTx[7:0] and
HTx[7:0]
User must configure LTx[1:0] and HTx[1:0] to 00
  1. 1. The watchdog comparison is performed on the raw converted data before any alignment calculation and before applying any offsets (the data which is compared is not signed).

ADC y _AWD x _OUT signal output generation

Each analog watchdog is associated to an internal hardware signal ADC y _AWD x _OUT (y=ADC number, x=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 y _AWD x _OUT signal as ETR.

ADC y _AWD x _OUT is activated when the associated analog watchdog is enabled:

Note: AWD x flag is set by hardware and reset by software: AWD x flag has no influence on the generation of ADC y _AWD x _OUT (ex: ADC y _AWD x _OUT can toggle while AWD x flag remains at 1 if the software did not clear the flag).

Figure 91. ADC y _AWD x _OUT signal generation (on all regular channels)

Timing diagram showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over a sequence of conversions. The diagram shows how the output signal toggles based on whether conversions are 'inside' or 'outside' thresholds, while the AWDx flag remains high as long as any conversion is outside.

The timing diagram illustrates the relationship between the ADC state, End of Conversion (EOC) flag, Watchdog Flag (AWD x ), and the hardware output signal (ADC y _AWD x _OUT) during a sequence of regular conversions. The sequence starts in the 'RDY' state and proceeds through seven conversions. The 'inside' or 'outside' status of each conversion determines the state of the output signal. The AWD x flag is set by hardware when a conversion is outside and is only reset by software (S/W) when all subsequent conversions are inside. The output signal follows the 'outside' status of the current conversion, toggling when the status changes from inside to outside or vice versa.

ADC STATERDYConversion1Conversion2Conversion3Conversion4Conversion5Conversion6Conversion7
EOC FLAGLowPulsePulsePulsePulsePulsePulsePulse
AWD x FLAGLowHighHighHighHighHighHighHigh
ADC y _AWD x _OUTLowHighLowHighLowHighLowHigh

Legend:

MS31025V1

Timing diagram showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals over a sequence of conversions. The diagram shows how the output signal toggles based on whether conversions are 'inside' or 'outside' thresholds, while the AWDx flag remains high as long as any conversion is outside.

Figure 92. ADC y _AWD x _OUT signal generation (AWD x flag not cleared by SW)

Timing diagram for Figure 92 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals for multiple regular channels (Conversion 1-7).

The diagram shows the following signal states over time:

  • - Converting regular channels 1,2,3,4,5,6,7
  • - Regular channels 1,2,3,4,5,6,7 are all guarded

MS31026V1

Timing diagram for Figure 92 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals for multiple regular channels (Conversion 1-7).

Figure 93. ADC y _AWD x _OUT signal generation (on a single regular channel)

Timing diagram for Figure 93 showing ADC STATE, EOC FLAG, EOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals for a single guarded regular channel (Conversion 1) among others (Conversion 2).

The diagram shows the following signal states over time:

  • - Converting regular channels 1 and 2
  • - Only channel 1 is guarded

MS31027V1

Timing diagram for Figure 93 showing ADC STATE, EOC FLAG, EOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals for a single guarded regular channel (Conversion 1) among others (Conversion 2).

Figure 94. ADC y _AWD x _OUT signal generation (on all injected channels)

Timing diagram for Figure 94 showing ADC STATE, JEOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals for all injected channels (Conversion 1-4) being guarded.

The diagram shows the following signal states over time:

  • - Converting the injected channels 1, 2, 3, 4
  • - All injected channels 1, 2, 3, 4 are guarded

MS31028V1

Timing diagram for Figure 94 showing ADC STATE, JEOS FLAG, AWDx FLAG, and ADCy_AWDx_OUT signals for all injected channels (Conversion 1-4) being guarded.

15.3.29 Dual ADC modes (STM32F302xB/C/D/E only)

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

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 bits DUAL[4:0] in the ADCx_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 ADCx_CCR register are not equal to zero), the bits CONT, AUTDLY, DISCEN, DISCNUM[2:0], JDISCEN, JQM, JAUTO of the ADCx_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, EXTSEL, JEXTEN, 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 (ADCx_CDR). The status bits can be also read in parallel by reading the dual-mode status register (ADCx_CSR).

Figure 95. Dual ADC block diagram (1)

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

The diagram illustrates the internal architecture of a Dual ADC system. On the left, input sources include ADCx_IN1 through ADCx_IN15 connected to GPIO ports, and internal sources: Temp. sensor, V BAT /2, and V REFINT . These inputs are multiplexed and fed into both the Master ADC and Slave ADC. The Master ADC (bottom) contains two start trigger multiplexers (one for regular groups, one for injected groups), a dual mode control block, and internal triggers. It has its own 'Regular channels' and 'Injected channels' blocks, which connect to a 'Regular data register (16-bits)' and four 'Injected data registers (4 x16-bits)'. The Slave ADC (top) similarly has 'Regular channels' and 'Injected channels' blocks connected to its own 'Regular data register (16-bits)' and four 'Injected data registers (4 x16-bits)'. All data registers from both ADCs are connected to a common 'Address/data bus' on the right. The diagram is labeled MSv31029V1.

Dual ADC block diagram showing Master ADC and Slave ADC components, data 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[3:0] bits in the ADCx_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 or ensure that the interval between triggers is longer than the longer of the 2 sequences. Otherwise, the ADC with the shortest sequence may restart while the ADC with the longest sequence is completing the previous conversions.

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 96. Injected simultaneous mode on 4 channels: dual ADC mode

Timing diagram for Injected simultaneous mode on 4 channels: dual ADC mode. The diagram shows two horizontal timelines for MASTER ADC and SLAVE ADC. The MASTER ADC timeline has four channels: CH1, CH2, CH3, CH4. The SLAVE ADC timeline has four channels: CH15, CH14, CH13, CH12. A 'Trigger' event is shown as a vertical line. Following the trigger, there are 'Sampling' (light gray) and 'Conversion' (white) phases for each channel. Arrows indicate the 'End of injected sequence on MASTER and SLAVE ADC' at the end of the conversion phases for all channels. The diagram is labeled MS31900V1.
Timing diagram for Injected simultaneous mode on 4 channels: dual ADC mode. The diagram shows two horizontal timelines for MASTER ADC and SLAVE ADC. The MASTER ADC timeline has four channels: CH1, CH2, CH3, CH4. The SLAVE ADC timeline has four channels: CH15, CH14, CH13, CH12. A 'Trigger' event is shown as a vertical line. Following the trigger, there are 'Sampling' (light gray) and 'Conversion' (white) phases for each channel. Arrows indicate the 'End of injected sequence on MASTER and SLAVE ADC' at the end of the conversion phases for all channels. 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:

ongoing regular sequence and the associated delay phases are ignored.
There is the same behavior for regular sequences occurring on the slave ADC.

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[3:0] bits in the ADCx_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) will abort the current simultaneous conversions, which are re-started 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 or ensure that the interval between triggers is longer than the longer conversion time of the 2 sequences. Otherwise, the ADC with the shortest sequence may restart while the ADC with the longest sequence is completing the previous conversions.

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: In MDMA mode (MDMA[1:0]=0b10 or 0b11), the user must program the same number of conversions in the master's sequence as in the slave's sequence. Otherwise, the remaining conversions will not generate a DMA request.

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

Diagram illustrating Regular simultaneous mode on 16 channels: dual ADC mode. It shows two parallel sequences of 16 channels. The Master ADC sequence consists of CH1, CH2, CH3, CH4, ..., CH16. The Slave ADC sequence consists of CH16, CH14, CH13, CH12, ..., CH1. A 'Trigger' arrow points to the start of the Master ADC sequence. A legend indicates that a light gray box represents 'Sampling' and a white box represents 'Conversion'. An arrow points to the end of the Slave ADC sequence with the text '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: dual ADC mode. It shows two parallel sequences of 16 channels. The Master ADC sequence consists of CH1, CH2, CH3, CH4, ..., CH16. The Slave ADC sequence consists of CH16, CH14, CH13, CH12, ..., CH1. A 'Trigger' arrow points to the start of the Master ADC sequence. A legend indicates that a light gray box represents 'Sampling' and a white box represents 'Conversion'. An arrow points to the end of the Slave ADC sequence with the text '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: bits MDMA must be set to 0b10 or 0b11.

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 2 conversions in interleaved mode is configured in the DELAY bits in the ADCx_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.

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

Note: It is possible to enable only the EOC interrupt of the slave and read the common data register (ADCx_CDR). 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 also possible to read the regular data using the DMA. Two methods are possible:

Figure 98. Interleaved mode on 1 channel in continuous conversion mode: dual ADC mode

Timing diagram for Figure 98 showing interleaved mode on 1 channel in continuous conversion mode for dual ADC. The diagram illustrates the timing of sampling and conversion for a Master ADC and a Slave ADC. The Master ADC starts with a sampling phase, followed by a conversion phase for CH1. The Slave ADC is triggered by the Master ADC's conversion. The Slave ADC also has a sampling phase, followed by a conversion phase for CH1. The Master ADC's conversion ends 8 ADCCCLK cycles after the Slave ADC's conversion ends. The Slave ADC's conversion ends 8 ADCCCLK cycles after the Master ADC's conversion ends. The diagram includes a legend for Sampling (grey box) and Conversion (white box).

The diagram shows the timing of sampling and conversion for a Master ADC and a Slave ADC in continuous conversion mode. The Master ADC starts with a sampling phase, followed by a conversion phase for CH1. The Slave ADC is triggered by the Master ADC's conversion. The Slave ADC also has a sampling phase, followed by a conversion phase for CH1. The Master ADC's conversion ends 8 ADCCCLK cycles after the Slave ADC's conversion ends. The Slave ADC's conversion ends 8 ADCCCLK cycles after the Master ADC's conversion ends. The diagram includes a legend for Sampling (grey box) and Conversion (white box).

MS31030V1

Timing diagram for Figure 98 showing interleaved mode on 1 channel in continuous conversion mode for dual ADC. The diagram illustrates the timing of sampling and conversion for a Master ADC and a Slave ADC. The Master ADC starts with a sampling phase, followed by a conversion phase for CH1. The Slave ADC is triggered by the Master ADC's conversion. The Slave ADC also has a sampling phase, followed by a conversion phase for CH1. The Master ADC's conversion ends 8 ADCCCLK cycles after the Slave ADC's conversion ends. The Slave ADC's conversion ends 8 ADCCCLK cycles after the Master ADC's conversion ends. The diagram includes a legend for Sampling (grey box) and Conversion (white box).

Figure 99. Interleaved mode on 1 channel in single conversion mode: dual ADC mode

Timing diagram for Figure 99 showing interleaved mode on 1 channel in single conversion mode for dual ADC. The diagram illustrates the timing of sampling and conversion for a Master ADC and a Slave ADC. The Master ADC starts with a sampling phase, followed by a conversion phase for CH1. The Slave ADC is triggered by the Master ADC's conversion. The Slave ADC also has a sampling phase, followed by a conversion phase for CH1. The Master ADC's conversion ends 8 ADCCCLK cycles after the Slave ADC's conversion ends. The Slave ADC's conversion ends 8 ADCCCLK cycles after the Master ADC's conversion ends. The diagram includes a legend for Sampling (grey box) and Conversion (white box).

The diagram shows the timing of sampling and conversion for a Master ADC and a Slave ADC in single conversion mode. The Master ADC starts with a sampling phase, followed by a conversion phase for CH1. The Slave ADC is triggered by the Master ADC's conversion. The Slave ADC also has a sampling phase, followed by a conversion phase for CH1. The Master ADC's conversion ends 8 ADCCCLK cycles after the Slave ADC's conversion ends. The Slave ADC's conversion ends 8 ADCCCLK cycles after the Master ADC's conversion ends. The diagram includes a legend for Sampling (grey box) and Conversion (white box).

MS31031V1

Timing diagram for Figure 99 showing interleaved mode on 1 channel in single conversion mode for dual ADC. The diagram illustrates the timing of sampling and conversion for a Master ADC and a Slave ADC. The Master ADC starts with a sampling phase, followed by a conversion phase for CH1. The Slave ADC is triggered by the Master ADC's conversion. The Slave ADC also has a sampling phase, followed by a conversion phase for CH1. The Master ADC's conversion ends 8 ADCCCLK cycles after the Slave ADC's conversion ends. The Slave ADC's conversion ends 8 ADCCCLK cycles after the Master ADC's conversion ends. The diagram includes a legend for Sampling (grey box) and Conversion (white box).

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 re-started from the master (see Figure 100 below).

Figure 100. 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. A 'Resume (always on master)' signal is shown. The diagram includes a legend for Sampling and Conversion, and labels for 'read CDR' and 'conversions aborted'.

The diagram illustrates the timing of interleaved conversion with injection for two ADCs, ADC1 (master) and ADC2 (slave). The master ADC (ADC1) has a sequence of channels CH1, CH1, CH1. The slave ADC (ADC2) has a sequence of channels CH2, CH2, CH2. An 'Injected trigger' occurs, causing the master ADC to convert channel CH11. A 'Resume (always on master)' signal is shown. The diagram includes a legend for Sampling and Conversion, and labels for 'read CDR' and 'conversions aborted'.

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. A 'Resume (always on master)' signal is shown. The diagram includes a legend for Sampling and Conversion, and labels for 'read CDR' and 'conversions aborted'.

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 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 101. Alternate trigger: injected group of each ADC

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

The diagram illustrates the timing of injected conversions for a Master ADC and a Slave ADC triggered by four external events (1st, 2nd, 3rd, and 4th triggers). Each ADC has a sequence of three injected channels. The first channel of each sequence consists of a sampling phase followed by a conversion phase. Subsequent channels consist only of a conversion phase. Interrupts are generated as follows:

Legend:

ai16059-m

Timing diagram showing the sequence of injected conversions for Master and Slave ADCs triggered by four external events. The diagram illustrates the flow of data through sampling and conversion stages, 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 2 trigger events must be greater than or equal to 1 ADC clock period. The minimum time interval between 2 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 102. Alternate trigger: 4 injected channels (each ADC) in discontinuous mode

Timing diagram for Figure 102 showing MASTER ADC and SLAVE ADC conversion sequences. The diagram illustrates four injected channels in discontinuous mode. Triggers 1, 3, 5, and 7 are shown for the MASTER ADC, while triggers 2, 4, 6, and 8 are shown for the SLAVE ADC. Each trigger initiates a conversion sequence. The diagram shows the sequence of sampling and conversion for each ADC. JEOC (End of Injected Conversion) flags are generated by the MASTER ADC after each injected channel conversion. JEOS (End of Injected Sequence) flags are generated by the MASTER ADC after the last injected channel conversion. The legend indicates that a shaded rectangle represents 'Sampling' and a white rectangle represents 'Conversion'.

The diagram illustrates the timing of 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 conversion sequence. The diagram shows the sequence of sampling and conversion for each ADC. JEOC (End of Injected Conversion) flags are generated by the MASTER ADC after each injected channel conversion. JEOS (End of Injected Sequence) flags are generated by the MASTER ADC after the last injected channel conversion. The legend indicates that a shaded rectangle represents 'Sampling' and a white rectangle represents 'Conversion'.

Timing diagram for Figure 102 showing MASTER ADC and SLAVE ADC conversion sequences. The diagram illustrates four injected channels in discontinuous mode. Triggers 1, 3, 5, and 7 are shown for the MASTER ADC, while triggers 2, 4, 6, and 8 are shown for the SLAVE ADC. Each trigger initiates a conversion sequence. The diagram shows the sequence of sampling and conversion for each ADC. JEOC (End of Injected Conversion) flags are generated by the MASTER ADC after each injected channel conversion. JEOS (End of Injected Sequence) flags are generated by the MASTER ADC after the last injected channel conversion. The legend indicates that a shaded rectangle represents 'Sampling' and a white rectangle represents '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: In combined regular/injected simultaneous mode, one must convert sequences with the same length or ensure that the interval between triggers is longer than the long conversion time of the 2 sequences. Otherwise, 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 103 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: In combined regular simultaneous + alternate trigger mode, one must convert sequences with the same length or ensure that the interval between triggers is longer than the long conversion time of the 2 sequences. Otherwise, the ADC with the shortest sequence may restart while the ADC with the longest sequence is completing the previous conversions.

Figure 103. Alternate + regular simultaneous

Timing diagram for Figure 103 showing simultaneous alternate and regular conversions. The diagram shows four rows of conversion slots: ADC MASTER reg (CH1, CH2, CH3, CH3, CH4, CH4, CH5), ADC MASTER inj (CH1), ADC SLAVE reg (CH4, CH6, CH7, CH7, CH8, CH8, CH9), and ADC SLAVE inj (CH1). Triggers are indicated by arrows: '1st trigger' points to the start of CH3 in the master regular sequence, and '2nd trigger' points to the start of CH1 in the slave injected sequence. A note 'synchronization not lost' is present near the slave injected sequence. The diagram is labeled ai16062V2-m.
Timing diagram for Figure 103 showing simultaneous alternate and regular conversions. The diagram shows four rows of conversion slots: ADC MASTER reg (CH1, CH2, CH3, CH3, CH4, CH4, CH5), ADC MASTER inj (CH1), ADC SLAVE reg (CH4, CH6, CH7, CH7, CH8, CH8, CH9), and ADC SLAVE inj (CH1). Triggers are indicated by arrows: '1st trigger' points to the start of CH3 in the master regular sequence, and '2nd trigger' points to the start of CH1 in the slave injected sequence. A note 'synchronization not lost' is present near the slave injected sequence. The diagram is labeled ai16062V2-m.

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

Figure 104. Case of trigger occurring during injected conversion

Timing diagram for Figure 104 showing a trigger occurring during an injected conversion. The diagram shows four rows of conversion slots: ADC MASTER reg (CH1, CH2, CH3, CH3, CH4, CH4, CH5, CH5, CH6), ADC MASTER inj (CH14), ADC SLAVE reg (CH7, CH8, CH9, CH9, CH10, CH10, CH11, CH11, CH12), and ADC SLAVE inj (CH15). Triggers are indicated by arrows: '1st trigger' points to the start of CH3 in the master regular sequence, '2nd trigger' points to the start of CH15 in the slave injected sequence, '3rd trigger' points to the start of CH4 in the master regular sequence, '4th trigger' points to the start of CH15 in the slave injected sequence, '5th trigger' points to the start of CH5 in the master regular sequence, and '6th trigger (ignored)' points to the start of CH15 in the slave injected sequence. The diagram is labeled ai16063V2.
Timing diagram for Figure 104 showing a trigger occurring during an injected conversion. The diagram shows four rows of conversion slots: ADC MASTER reg (CH1, CH2, CH3, CH3, CH4, CH4, CH5, CH5, CH6), ADC MASTER inj (CH14), ADC SLAVE reg (CH7, CH8, CH9, CH9, CH10, CH10, CH11, CH11, CH12), and ADC SLAVE inj (CH15). Triggers are indicated by arrows: '1st trigger' points to the start of CH3 in the master regular sequence, '2nd trigger' points to the start of CH15 in the slave injected sequence, '3rd trigger' points to the start of CH4 in the master regular sequence, '4th trigger' points to the start of CH15 in the slave injected sequence, '5th trigger' points to the start of CH5 in the master regular sequence, and '6th trigger (ignored)' points to the start of CH15 in the slave injected sequence. The diagram is labeled ai16063V2.

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 105: DMA Requests in regular simultaneous mode when MDMA=0b00 ).

Figure 105. DMA Requests in regular simultaneous mode when MDMA=0b00

Timing diagram showing DMA requests in regular simultaneous mode when MDMA=0b00. The diagram illustrates the sequence of events for two ADCs (Master and Slave) triggered by external signals. The Master ADC (CH1) and Slave ADC (CH2) both receive triggers. The Master ADC generates an EOC signal, which triggers a DMA request. The Slave ADC generates an EOC signal, which triggers a DMA request. The DMA controller then reads the data from the Master ADC's DR register and the Slave ADC's DR register. The diagram shows two consecutive conversions. The first conversion starts with a trigger for CH1, followed by the Master EOC signal, then the Slave EOC signal, then the DMA request from the Master, then the DMA read of the Master DR, then the DMA request from the Slave, and finally the DMA read of the Slave DR. The second conversion follows the same sequence. The diagram is labeled 'Configuration where each sequence contains only one conversion' and 'MSV31032V2'.

Configuration where each sequence contains only one conversion

MSV31032V2

Timing diagram showing DMA requests in regular simultaneous mode when MDMA=0b00. The diagram illustrates the sequence of events for two ADCs (Master and Slave) triggered by external signals. The Master ADC (CH1) and Slave ADC (CH2) both receive triggers. The Master ADC generates an EOC signal, which triggers a DMA request. The Slave ADC generates an EOC signal, which triggers a DMA request. The DMA controller then reads the data from the Master ADC's DR register and the Slave ADC's DR register. The diagram shows two consecutive conversions. The first conversion starts with a trigger for CH1, followed by the Master EOC signal, then the Slave EOC signal, then the DMA request from the Master, then the DMA read of the Master DR, then the DMA request from the Slave, and finally the DMA read of the Slave DR. The second conversion follows the same sequence. The diagram is labeled 'Configuration where each sequence contains only one conversion' and 'MSV31032V2'.

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 MDMA bits must be configured in the ADCx_CCR register:

Example:

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

1st DMA request: ADCx_CDR[31:0] = SLV_ADCx_DR[15:0] |
MST_ADCx_DR[15:0]

2nd DMA request: ADCx_CDR[31:0] = SLV_ADCx_DR[15:0] |
MST_ADCx_DR[15:0]

Figure 106. DMA requests in regular simultaneous mode when MDMA=0b10

Timing diagram for Figure 106 showing DMA requests in regular simultaneous mode. It displays two sequences of conversions for CH1 and CH2. Triggers start each sequence. ADC Master regular and ADC Slave regular show the conversion periods for CH1 and CH2 respectively. ADC Master EOC and ADC Slave EOC signals go high at the end of each conversion. DMA request from ADC Master pulses high when the master EOC goes high. DMA request from ADC Slave remains low throughout. A vertical line separates the two sequences. Text at the bottom indicates 'Configuration where each sequence contains only one conversion'. MSV31033V2 is noted in the bottom right.

Configuration where each sequence contains only one conversion

MSV31033V2

Timing diagram for Figure 106 showing DMA requests in regular simultaneous mode. It displays two sequences of conversions for CH1 and CH2. Triggers start each sequence. ADC Master regular and ADC Slave regular show the conversion periods for CH1 and CH2 respectively. ADC Master EOC and ADC Slave EOC signals go high at the end of each conversion. DMA request from ADC Master pulses high when the master EOC goes high. DMA request from ADC Slave remains low throughout. A vertical line separates the two sequences. Text at the bottom indicates 'Configuration where each sequence contains only one conversion'. MSV31033V2 is noted in the bottom right.

Figure 107. DMA requests in interleaved mode when MDMA=0b10

Timing diagram for Figure 107 showing DMA requests in interleaved mode. It displays two sequences. The first sequence shows three triggers, each starting a CH1 conversion followed by a 'Delay' period and then a CH2 conversion. ADC Master regular and ADC Slave regular show these alternating conversions. ADC Master EOC pulses high after each CH1 conversion. DMA request from ADC Master pulses high when the master EOC goes high. DMA request from ADC Slave remains low. The second sequence shows two triggers, each starting a CH1 conversion followed by a 'Delay' period and then a CH2 conversion. Text at the bottom indicates 'Configuration where each sequence contains only one conversion'. MSV31034V2 is noted in the bottom right.

Configuration where each sequence contains only one conversion

MSV31034V2

Timing diagram for Figure 107 showing DMA requests in interleaved mode. It displays two sequences. The first sequence shows three triggers, each starting a CH1 conversion followed by a 'Delay' period and then a CH2 conversion. ADC Master regular and ADC Slave regular show these alternating conversions. ADC Master EOC pulses high after each CH1 conversion. DMA request from ADC Master pulses high when the master EOC goes high. DMA request from ADC Slave remains low. The second sequence shows two triggers, each starting a CH1 conversion followed by a 'Delay' period and then a CH2 conversion. Text at the bottom indicates 'Configuration where each sequence contains only one conversion'. MSV31034V2 is noted in the bottom right.

Note: When using MDMA 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 resolution is 6-bit or when resolution is 8-bit and data is not signed (offsets must be disabled for all the involved channels).

Example:

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

1st DMA request: ADCx_CDR[15:0] = SLV_ADCx_DR[7:0] | MST_ADCx_DR[7:0]

2nd DMA request: ADCx_CDR[15:0] = SLV_ADCx_DR[7:0] | MST_ADCx_DR[7:0]

Overrun detection

In dual ADC mode (when DUAL[4:0] is not equal to b00000), 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 MDMA 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 MDMA mode is selected

When MDMA mode is selected (0b10 or 0b11), bit DMACFG of the ADCx_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 (bits DMACFG of master and slave ADCx_CFGR are not relevant).

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 ADC are effectively stopped, the bits ADSTART/JADSTART of the master and slave ADCs are both cleared by hardware.

15.3.30 Temperature sensor

The temperature sensor can be used to measure the junction temperature (TJ) of the device. The temperature sensor is internally connected to the input channels which are used to convert the sensor output voltage to a digital value. When not in use, the sensor can be put in power down mode.

Figure 108 shows the block diagram of connections between the temperature sensor and the ADC.

The temperature sensor output voltage changes linearly with temperature. The offset of this line varies from chip to chip due to process variation (up to 45 °C from one chip to another).

The uncalibrated internal temperature sensor is more suited for applications that detect temperature variations instead of absolute temperatures. To improve the accuracy of the

temperature sensor measurement, calibration values are stored in system memory for each device by ST during production.

During the manufacturing process, the calibration data of the temperature sensor and the internal voltage reference are stored in the system memory area. The user application can then read them and use them to improve the accuracy of the temperature sensor or the internal reference. Refer to the STM32F302xx datasheet for additional information.

Main features

The temperature sensor is internally connected to the ADC1_IN16 input channel which is used to convert the sensor's output voltage to a digital value. Refer to the electrical characteristics section of STM32F302xx datasheet for the sampling time value to be applied when converting the internal temperature sensor.

When not in use, the sensor can be put in power-down mode.

Figure 108 shows the block diagram of the temperature sensor.

Figure 108. Temperature sensor channel block diagram

Block diagram of the temperature sensor channel. A 'Temperature sensor' block outputs a voltage V_TS to a multiplexer. The multiplexer is controlled by a 'TSEN control bit' and its output is connected to the 'ADC input' of an 'ADCx' block. The 'ADCx' block outputs 'converted data' to an 'Address/data bus' block. The diagram is labeled MSv31172V2 in the bottom right corner.
graph LR; TS[Temperature sensor] -- V_TS --> MUX; TSEN[TSEN control bit] --> MUX; MUX --> ADC[ADCx]; ADC -- converted data --> BUS[Address/data bus];
Block diagram of the temperature sensor channel. A 'Temperature sensor' block outputs a voltage V_TS to a multiplexer. The multiplexer is controlled by a 'TSEN control bit' and its output is connected to the 'ADC input' of an 'ADCx' block. The 'ADCx' block outputs 'converted data' to an 'Address/data bus' block. The diagram is labeled MSv31172V2 in the bottom right corner.

Note: The TSEN bit must be set to enable the conversion of the temperature sensor voltage \( V_{\text{TS}} \) .

Reading the temperature

To use the sensor:

  1. 1. Select the ADC1_IN16 input channel (with the appropriate sampling time).
  2. 2. Program with the appropriate sampling time (refer to electrical characteristics section of the STM32F302xx datasheet).
  3. 3. Set the TSEN bit in the ADC1_CCR register to wake up the temperature sensor from power-down mode.
  4. 4. Start the ADC conversion.
  5. 5. Read the resulting \( V_{TS} \) data in the ADC data register.
  6. 6. Calculate the actual temperature using the following formula:

\[ \text{Temperature (in } ^\circ\text{C)} = \{(V_{25} - V_{TS}) / \text{Avg\_Slope}\} + 25 \]

Where:

Refer to the datasheet electrical characteristics section for the actual values of \( V_{25} \) and Avg_Slope.

Note: The sensor has a startup time after waking from power-down mode before it can output \( V_{TS} \) at the correct level. The ADC also has a startup time after power-on, so to minimize the delay, the ADEN and TSEN bits should be set at the same time.

15.3.31 \( 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 could be higher than \( V_{DDA} \) , to ensure the correct operation of the ADC, the \( V_{BAT} \) pin is internally connected to a bridge divider by 2. This bridge is automatically enabled when VBATEN is set, to connect \( V_{BAT}/2 \) to the ADC1_IN17 input channel. As a consequence, the converted digital value is half 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 STM32F302xx datasheet for the sampling time value to be applied when converting the \( V_{BAT}/2 \) voltage.

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

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

The diagram shows the internal circuitry for the \( V_{BAT} \) channel. A switch controlled by the \( V_{BATEN} \) control bit connects the \( V_{BAT} \) supply to a voltage divider consisting of two resistors. The midpoint of the divider, labeled \( V_{BAT}/2 \) , is connected to a multiplexer. The output of the multiplexer is connected to the \( ADC \) input of an \( ADCx \) block. The \( ADCx \) block is connected to an \( Address/data bus \) . The bottom of the voltage divider is connected to ground. The identifier MSv31035V2 is shown in the bottom right corner.

Figure 109. VBAT channel block diagram

Note: The \( V_{BATEN} \) bit must be set to enable the conversion of internal channel \( ADC1\_IN17 \) ( \( V_{BATEN} \) ).

15.3.32 Monitoring the internal voltage reference

It is possible to monitor the internal voltage reference ( \( V_{REFINT} \) ) to have a reference point for evaluating the \( ADC V_{REF+} \) voltage level.

The internal voltage reference is internally connected to the input channel 18 of the two ADCs ( \( ADCx\_IN18 \) ).

Refer to the electrical characteristics section of the STM32F302xx datasheet for the sampling time value to be applied when converting the internal voltage reference voltage.

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

Figure 110.\( V_{REFINT} \) channel block diagram Figure 110. VREFINT channel block diagram

The diagram illustrates the internal voltage reference sensing feature. An \( Internal power block \) provides the \( V_{REFINT} \) signal, which is connected to a multiplexer. The multiplexer is controlled by the \( ADC12\_VREFEN \) control bit. The output of the multiplexer is connected to the \( ADC1\_IN18 \) input of \( ADC1 \) and the \( ADC2\_IN18 \) input of \( ADC2 \) . The identifier MSv31036V2 is shown in the bottom right corner.

Figure 110. VREFINT channel block diagram

Note: The \( VREFEN \) bit into \( ADC12\_CCR \) register must be set to enable the conversion of internal channels \( ADC1\_IN18 \) or \( ADC2\_IN18 \) ( \( V_{REFINT} \) ).

Calculating the actual \( V_{DDA} \) 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_{DDA} = 3.3\text{ V} \) can be used to evaluate the actual \( V_{DDA} \) voltage level.

The following formula gives the actual \( V_{DDA} \) voltage supplying the device:

\[ V_{DDA} = 3.3\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 analog power supply 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 user can use the following formula to get this absolute value:

\[ V_{CHANNELx} = \frac{V_{DDA}}{FULL\_SCALE} \times ADCx\_DATA \]

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

\[ V_{CHANNELx} = \frac{3.3\text{ V} \times VREFINT\_CAL \times ADCx\_DATA}{VREFINT\_DATA \times FULL\_SCALE} \]

Where:

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

15.4 ADC interrupts

For each ADC, an interrupt can be generated:

Separate interrupt enable bits are available for flexibility.

Table 94. ADC interrupts per each ADC

Interrupt eventEvent flagEnable control bit
ADC readyADRDYADRDYIE
End of conversion of a regular groupEOCEOCIE
End of sequence of conversions of a regular groupEOSEOSIE
End of conversion of a injected groupJEOCJEOCIE
End of sequence of conversions 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
Injected context queue overflowsJQOVFJQOVFIE

15.5 ADC registers (for each ADC)

Refer to Section 2.2 on page 45 for a list of abbreviations used in register descriptions.

15.5.1 ADC interrupt and status register (ADCx_ISR, x=1..2)

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.Res.Res.JQOVFAWD3AWD2AWD1JEOSJEOCOVREOSEOCEOSMPADRDY
rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1

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

Bit 10 JQOVF : Injected context queue overflow

This bit is set by hardware when an Overflow of the Injected Queue of Context occurs. It is cleared by software writing 1 to it. Refer to Section 15.3.21: Queue of context for injected conversions for more information.

0: No injected context queue overflow occurred (or the flag event was already acknowledged and cleared by software)

1: Injected context queue overflow has occurred

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 ADCx_TR3 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 ADCx_TR2 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 ADCx_TR1 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 ADCx_JDRy register. It is cleared by software writing 1 to it or by reading the corresponding ADCx_JDRy register

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.

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.

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 ADCx_DR register. It is cleared by software writing 1 to it or by reading the ADCx_DR register

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.

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.

15.5.2 ADC interrupt enable register (ADCx_IER, x=1..2)

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.JQ
OVFIE
AWD3
IE
AWD2
IE
AWD1
IE
JEOSIEJEOCIEOVRIEEOSIEEOCIEEOSMP
IE
ADRDY
IE
rwrwrwrwrwrwrwrwrwrwrw

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

Bit 10 JQOVFIE: Injected context queue overflow interrupt enable

This bit is set and cleared by software to enable/disable the Injected Context Queue Overflow interrupt.

0: Injected Context Queue Overflow interrupt disabled

1: Injected Context Queue Overflow interrupt enabled. An interrupt is generated when the JQOVF bit is set.

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

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

15.5.3 ADC control register (ADCx_CR, x=1..2)

Address offset: 0x08

Reset value: 0x2000 0000

31302928272625242322212019181716
AD CALADCA LDIFADVREGEN[1:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rsrWrWrW

1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JAD STPAD STPJAD STARTAD STARTAD DISAD EN
rsrsrsrsrsrs

Bit 31 ADCAL: ADC calibration

This bit is set by software to start the calibration of the ADC. Program first the bit ADCALDIF to determine if this calibration applies for single-ended or differential inputs mode.

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: Software is allowed to launch a calibration by setting ADCAL only when ADEN=0.

Note: Software is allowed to update the calibration factor by writing ADCx_CALFACT only when ADEN=1 and ADSTART=0 and JADSTART=0 (ADC enabled and no conversion is ongoing)

Bit 30 ADCALDIF: Differential mode for calibration

This bit is set and cleared by software to configure the single-ended or differential inputs mode for the calibration.

0: Writing ADCAL will launch a calibration in Single-ended inputs Mode.

1: Writing ADCAL will launch a calibration in Differential inputs Mode.

Note: 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 29:28 ADVREGEN[1:0]: ADC voltage regulator enable

These bits are 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.

00: Intermediate state required when moving the ADC voltage regulator from the enabled to the disabled state or from the disabled to the enabled state.

01: ADC Voltage regulator enabled.

10: ADC Voltage regulator disabled (Reset state)

11: reserved

For more details about the ADC voltage regulator enable and disable sequences, refer to Section 15.3.6: ADC voltage regulator (ADVREGEN) .

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

Bits 27: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: 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)

Note: 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: 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)

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

Note: In dual ADC regular simultaneous mode and interleaved mode, the bit ADSTP of the master ADC must be used to stop regular conversions. The other ADSTP bit is inactive.

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, a conversion will start 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: 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)

Note: 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, a conversion will start 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: 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)

Note: 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: 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 will be 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: Software is allowed to set ADEN only when all bits of ADCx_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)

15.5.4 ADC configuration register (ADCx_CFGR, x=1..2)

Address offset: 0x0C

Reset value: 0x0000 00000

31302928272625242322212019181716
Res.AWD1CH[4:0]JAUTOJAWD1ENAWD1ENAWD1SGLJQMJDISCENDISCNUM[2:0]DISCEN
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
Res.AUT DLYCONTOVR MODEXTEN[1:0]EXTSEL[3:0]ALIGNRES[1:0]Res.DMA CFGDMA EN
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: reserved (analog input channel 0 is not mapped)

00001: ADC analog input channel-1 monitored by AWD1

.....

10010: ADC analog input channel-18 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.

Note: 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: Software is allowed to write this bit only when ADSTART=0 and JADSTART=0 (which ensures that no regular nor injected conversion is ongoing).

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bit JAUTO of the slave ADC is no more writable and its content is equal to the bit JAUTO of the master ADC.

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: 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: 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: Software is allowed to write these bits only when ADSTART=0 and JADSTART=0 (which ensures that no conversion is ongoing).

Bit 21 JQM : JSQR queue mode

This bit is set and cleared by software.

It defines how an empty Queue is managed.

0: JSQR Mode 0: The Queue is never empty and maintains the last written configuration into JSQR.

1: JSQR Mode 1: The Queue can be empty and when this occurs, the software and hardware triggers of the injected sequence are both internally disabled just after the completion of the last valid injected sequence.

Refer to Section 15.3.21: Queue of context for injected conversions for more information.

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

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bit JQM of the slave ADC is no more writable and its content is equal to the bit JQM of the master ADC.

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: Software is allowed to write this bit only when JADSTART=0 (which ensures that no injected conversion is ongoing).

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

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bit JDISCEN of the slave ADC is no more writable and its content is equal to the bit JDISCEN of the master ADC.

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: Software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bits DISCNUM[2:0] of the slave ADC are no more writable and their content is equal to the bits DISCNUM[2:0] of the master ADC.

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.

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

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

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bit DISCEN of the slave ADC is no more writable and its content is equal to the bit DISCEN of the master ADC.

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: Software is allowed to write this bit only when ADSTART=0 and JADSTART=0 (which ensures that no conversion is ongoing).

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bit AUTDLY of the slave ADC is no more writable and its content is equal to the bit AUTDLY of the master ADC.

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.

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

Note: When dual mode is enabled (bits DUAL of ADCx_CCR register are not equal to zero), the bit CONT of the slave ADC is no more writable and its content is equal to the bit CONT of the master ADC.

Bit 12 OVRMOD: Overrun Mode

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

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

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

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

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

Bits 9:6 EXTSSEL[3:0]: External trigger selection for regular group

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

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

Bit 5 ALIGN: Data alignment

This bit is set and cleared by software to select right or left alignment. Refer to Figure : Data register, data alignment and offset (ADCx_DR, OFFSETy, OFFSETy_CH, ALIGN)

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

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

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

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

Bit 2 Reserved, must be kept at reset value.

Bit 1 DMACFG : Direct memory access configuration

This bit is set and cleared by software to select between two DMA modes of operation and is effective only when DMAEN=1.

For more details, refer to Section : Managing conversions using the DMA

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

Note: In dual-ADC modes, this bit is not relevant and replaced by control bit DMACFG of the ADCx_CCR register.

Bit 0 DMAEN : Direct memory access enable

This bit is set and cleared by software to enable the generation of DMA requests. This allows to use the GP-DMA to manage automatically the converted data. For more details, refer to Section : Managing conversions using the DMA .

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

Note: In dual-ADC modes, this bit is not relevant and replaced by control bits MDMA[1:0] of the ADCx_CCR register.

15.5.5 ADC sample time register 1 (ADCx_SMPR1, x=1..2)

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_0SMP4[2:0]SMP3[2:0]SMP2[2:0]SMP1[2:0]Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 29:3 SMPx[2:0] : Channel x sampling time selection

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.

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

Bits 2:0 Reserved

15.5.6 ADC sample time register 2 (ADCx_SMPR2, x=1..2)

Address offset: 0x18

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.SMP18[2:0]SMP17[2:0]SMP16[2:0]SMP15[2:1]
rwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SMP15_0SMP14[2:0]SMP13[2:0]SMP12[2:0]SMP11[2:0]SMP10[2:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 26:0 SMPx[2:0] : Channel x sampling time selection

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.

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

15.5.7 ADC watchdog threshold register 1 (ADCx_TR1, x=1..2)

Address offset: 0x20

Reset value: 0x0FFF 0000

31302928272625242322212019181716
Res.Res.Res.Res.HT1[11:0]
1514131211109876543210
Res.Res.Res.Res.LT1[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 27:16 HT1[11: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 15.3.28: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)

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

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

Bits 11:0 LT1[11: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 15.3.28: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)

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

15.5.8 ADC watchdog threshold register 2 (ADCx_TR2, x = 1..2)

Address offset: 0x24

Reset value: 0x00FF 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.HT2[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.LT2[7:0]
rwrwrwrwrwrwrwrw

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

Bits 23:16 HT2[7: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 15.3.28: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)

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

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

Bits 7:0 LT2[7: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 15.3.28: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)

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

15.5.9 ADC watchdog threshold register 3 (ADCx_TR3, x=1..2)

Address offset: 0x28

Reset value: 0x00FF 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.HT3[7:0]
rwrwrwrwrwrwrwrw

1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.LT3[7:0]
rwrwrwrwrwrwrwrw

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

Bits 23:16 HT3[7: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 15.3.28: Analog window watchdog (AWD1EN, JAWD1EN, AWD1SGL, AWD1CH, AWD2CH, AWD3CH, AWD_HTx, AWD_LTx, AWDx)

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

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

Bits 7:0 LT3[7:0] : Analog watchdog 3 lower threshold

These bits are written by software to define the lower threshold for the analog watchdog 3.

This watchdog compares the 8-bit of LT3 with the 8 MSB of the converted data.

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

15.5.10 ADC regular sequence register 1 (ADCx_SQR1, x=1..2)

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 (1..18) assigned as the 4th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value "00000" should not be used

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 (1..18) assigned as the 3rd in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value "00000" should not be used

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 (1..18) assigned as the 2nd in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value "00000" should not be used

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 (1..18) assigned as the 1st in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value "00000" should not be used

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: Software is allowed to write these bits only when ADSTART=0 (which ensures that no regular conversion is ongoing).

15.5.11 ADC regular sequence register 2 (ADCx_SQR2, x=1..2)

Address offset: 0x34

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.SQ9[4:0]Res.SQ8[4:0]Res.SQ7[4]
rwrwrwrwrwrwrwrwrwrwrw
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 (1..18) assigned as the 9th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value "00000" should not be used

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 (1..18) assigned as the 8th in the regular conversion sequence

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

Note: Analog input channel 0 is not mapped: value "00000" should not be used

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 (1..18) assigned as the 7th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 6th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 5th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

15.5.12 ADC regular sequence register 3 (ADCx_SQR3, x=1..2)

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 (1..18) assigned as the 14th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 13th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 12th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 11th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 10th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

15.5.13 ADC regular sequence register 4 (ADCx_SQR4, x=1..2)

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 (1..18) assigned as the 16th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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 (1..18) assigned as the 15th in the regular conversion sequence.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

15.5.14 ADC regular Data Register (ADCx_DR, x=1..2)

Address offset: 0x40

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
RDATA[15:0]
rrrrrrrrrrrrrrrr

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

Bits 15:0 RDATA[15: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 15.3.26: Data management .

15.5.15 ADC injected sequence register (ADCx_JSQR, x=1..2)

Address offset: 0x4C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.JSQ4[4:0]Res.JSQ3[4:0]Res.JSQ2[4:2]
rwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
JSQ2[1:0]Res.JSQ1[4:0]JEXTEN[1:0]JEXTSEL[3:0]JL[1:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 Reserved, must be kept at reset value.

Bits 30:26 JSQ4[4:0] : 4th conversion in the injected sequence

These bits are written by software with the channel number (1..18) assigned as the 4th in the injected conversion sequence.

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

Note: Analog input channel 0 is not mapped: value “00000” should not be used

Bit 25 Reserved, must be kept at reset value.

Bits 24:20 JSQ3[4:0] : 3rd conversion in the injected sequence

These bits are written by software with the channel number (1..18) assigned as the 3rd in the injected conversion sequence.

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

Note: Analog input channel 0 is not mapped: value “00000” should not be used

Bit 19 Reserved, must be kept at reset value.

Bits 18:14 JSQ2[4:0] : 2nd conversion in the injected sequence

These bits are written by software with the channel number (1..18) assigned as the 2nd in the injected conversion sequence.

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

Note: Analog input channel 0 is not mapped: value “00000” should not be used

Bit 13 Reserved, must be kept at reset value.

Bits 12:8 JSQ1[4:0] : 1st conversion in the injected sequence

These bits are written by software with the channel number (1..18) assigned as the 1st in the injected conversion sequence.

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

Note: Analog input channel 0 is not mapped: value “00000” should not be used

Bits 7:6 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.

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

Note: If JQM=1 and if the Queue of Context becomes empty, the software and hardware triggers of the injected sequence are both internally disabled (refer to Section 15.3.21: Queue of context for injected conversions )

Bits 5:2 JEXTSEL[3:0]: External Trigger Selection for injected group

These bits select the external event used to trigger the start of conversion of an injected group:

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

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.

Note: Software is allowed to write these bits at any time, once the ADC is enabled (ADEN=1).

15.5.16 ADC offset register (ADCx_OFRy, x=1..2) (y=1..4)

Address offset: 0x60, 0x64, 0x68, 0x6C

Reset value: 0x0000 0000

31302928272625242322212019181716
OFFSETy_ENOFFSETy_CH[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.OFFSETy[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 OFFSETy_EN : Offset y Enable

This bit is written by software to enable or disable the offset programmed into bits OFFSETy[11:0].

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

Bits 30:26 OFFSETy_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 bits OFFSETy[11:0] will apply.

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

Note: Analog input channel 0 is not mapped: value “00000” should not be used

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

Bits 11:0 OFFSETy[11:0] : Data offset y for the channel programmed into bits OFFSETy_CH[4:0]

These bits are written by software to define the offset y to be subtracted from the raw converted data when converting a channel (can be regular or injected). The channel to which applies the data offset y must be programmed in the bits OFFSETy_CH[4:0]. The conversion result can be read from in the ADCx_DR (regular conversion) or from in the ADCx_JDRyi registers (injected conversion).

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

Note: If several offset (OFFSETy) point to the same channel, only the offset with the lowest x value is considered for the subtraction.

Ex: if OFFSET1_CH[4:0]=4 and OFFSET2_CH[4:0]=4, this is OFFSET1[11:0] which is subtracted when converting channel 4.

15.5.17 ADC injected data register (ADCx_JDRy, x=1..2, y= 1..4)

Address offset: 0x80 - 0x8C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
JDATA[15:0]
rrrrrrrrrrrrrrrr

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

Bits 15:0 JDATA[15: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 15.3.26: Data management .

15.5.18 ADC Analog Watchdog 2 Configuration Register (ADCx_AWD2CR, x=1..2)

Address offset: 0xA0

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD2CH[18:16]
rwrwrw
1514131211109876543210
AWD2CH[15:1]Res.
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 18:1 AWD2CH[18:1] : 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[18:1] = 000..0, the analog Watchdog 2 is disabled

Note: The channels selected by AWD2CH must be also selected into the SQRI or JSQRI registers.

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

Bit 0 Reserved, must be kept at reset value.

15.5.19 ADC Analog Watchdog 3 Configuration Register (ADCx_AWD3CR, x=1..2)

Address offset: 0xA4

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3CH[18:16]
1514131211109876543210
AWD3CH[15:1]Res.
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 18:1 AWD3CH[18:1] : 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[18:1] = 000..0, the analog Watchdog 3 is disabled

Note: The channels selected by AWD3CH must be also selected into the SQRi or JSQRI registers.

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

Bit 0 Reserved, must be kept at reset value.

15.5.20 ADC Differential Mode Selection Register (ADCx_DIFSEL, x=1..2)

Address offset: 0xB0

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DIFSEL[18:16]
rrr
1514131211109876543210
DIFSEL[15:1]Res.
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 18:16 DIFSEL[18:16] : Differential mode for channels 18 to 16.

These bits are read only. These channels are forced to single-ended input mode (either connected to a single-ended I/O port or to an internal channel).

Bits 15:1 DIFSEL[15:1] : Differential mode for channels 15 to 1

These bits are set and cleared by software. They allow to select 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: 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).

Note: It is mandatory to keep cleared ADC1_DIFSEL[15] (connected to an internal single ended channel)

Bit 0 Reserved, must be kept at reset value.

15.5.21 ADC Calibration Factors (ADCx_CALFACT, x=1..2)

Address offset: 0xB4

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.CALFACT_D[6:0]
rwrwrwrwrwrwrw

1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.CALFACT_S[6:0]
rwrwrwrwrwrwrw

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

Bits 22:16 CALFACT_D[6:0] : Calibration Factors in differential mode

These bits are written by hardware or by software.

Once a differential inputs calibration is complete, they are updated by hardware with the calibration factors.

Software can write these bits with a new calibration factor. If the new calibration factor is different from the current one stored into the analog ADC, it will then be applied once a new differential calibration is launched.

Note: 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).

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

Bits 6:0 CALFACT_S[6:0] : Calibration Factors In Single-Ended mode

These bits are written by hardware or by software.

Once a single-ended inputs calibration is complete, they are updated by hardware with the calibration factors.

Software can write these bits with a new calibration factor. If the new calibration factor is different from the current one stored into the analog ADC, it will then be applied once a new single-ended calibration is launched.

Note: 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).

15.6 ADC common registers

These registers define the control and status registers common to master and slave ADCs:

15.6.1 ADC Common status register (ADCx_CSR, x=12)

Address offset: 0x00 (this offset address is relative to the master ADC base address + 0x300)

Reset value: 0x0000 0000

This register provides an image of the status bits of the different ADCs. Nevertheless it is read-only and does not allow to clear the different status bits. Instead each status bit must be cleared by writing 0 to it in the corresponding ADCx_SR register.

31302928272625242322212019181716
Res.Res.Res.Res.Res.JQOVF_
SLV
AWD3_
SLV
AWD2_
SLV
AWD1_
SLV
JEOS_
SLV
JEOC_
SLV
OVR_
SLV
EOS_
SLV
EOC_
SLV
EOSMP_
SLV
ADRDY_
SLV
Slave ADC
rrrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.JQOVF_
MST
AWD3_
MST
AWD2_
MST
AWD1_
MST
JEOS_
MST
JEOC_
MST
OVR_
MST
EOS_
MST
EOC_
MST
EOSMP_
MST
ADRDY_
MST
Master ADC
rrrrrrrrrrr

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

Bit 26 JQOVF_ SLV : Injected Context Queue Overflow flag of the slave ADC

This bit is a copy of the JQOVF bit in the corresponding ADCx_ISR register.

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_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_ISR register.

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

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

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

Bit 20 OVR_ SLV : Overrun flag of the slave ADC

This bit is a copy of the OVR bit in the corresponding ADCx_ISR register.

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

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

  1. 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_ISR register.
  2. Bit 16 ADRDY_SLV : Slave ADC ready
    This bit is a copy of the ADRDY bit in the corresponding ADCx_ISR register.
  3. Bits 15:11 Reserved, must be kept at reset value.
  4. Bit 10 JQOVF_MST : Injected Context Queue Overflow flag of the master ADC
    This bit is a copy of the JQOVF bit in the corresponding ADCx_ISR register.
  5. Bit 9 AWD3_MST : Analog watchdog 3 flag of the master ADC
    This bit is a copy of the AWD3 bit in the corresponding ADCx_ISR register.
  6. Bit 8 AWD2_MST : Analog watchdog 2 flag of the master ADC
    This bit is a copy of the AWD2 bit in the corresponding ADCx_ISR register.
  7. Bit 7 AWD1_MST : Analog watchdog 1 flag of the master ADC
    This bit is a copy of the AWD1 bit in the corresponding ADCx_ISR register.
  8. 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 ADCx_ISR register.
  9. 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 ADCx_ISR register.
  10. Bit 4 OVR_MST : Overrun flag of the master ADC
    This bit is a copy of the OVR bit in the corresponding ADCx_ISR register.
  11. 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 ADCx_ISR register.
  12. Bit 2 EOC_MST : End of regular conversion of the master ADC
    This bit is a copy of the EOC bit in the corresponding ADCx_ISR register.
  13. 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 ADCx_ISR register.
  14. Bit 0 ADRDY_MST : Master ADC ready
    This bit is a copy of the ADRDY bit in the corresponding ADCx_ISR register.

15.6.2 ADC common control register (ADCx_CCR, x=12)

Address offset: 0x08 (this offset address is relative to the master ADC base address + 0x300)

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.VBAT
EN
TS
EN
VREF
EN
Res.Res.Res.Res.CKMODE[1:0]
rwrwrwrwrw

1514131211109876543210
MDMA[1:0]DMA
CFG
Res.DELAY[3:0]Res.Res.Res.DUAL[4:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bit 24 VBATEN : V BAT enable

This bit is set and cleared by software to enable/disable the V BAT channel.

0: V BAT channel disabled

1: V BAT channel enabled

Note: 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 TSEN : Temperature sensor enable

This bit is set and cleared by software to enable/disable the temperature sensor channel.

0: Temperature sensor channel disabled

1: Temperature sensor channel enabled

Note: 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 channel.

0: V REFINT channel disabled

1: V REFINT channel enabled

Note: 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 Reserved, must be kept at reset value.

Bits 17:16 CKMODE[1:0]: ADC clock mode

These bits are set and cleared by software to define the ADC clock scheme (which is common to both master and slave ADCs):

00: CK_ADCx (x=123) (Asynchronous clock mode), generated at product level (refer to Section 9: Reset and clock control (RCC) )

01: HCLK/1 (Synchronous clock mode). This configuration must be enabled only if the AHB clock prescaler is set to 1 (HPRE[3:0] = 0xxx in RCC_CFGR register) and if the system clock has a 50% duty cycle.

10: HCLK/2 (Synchronous clock mode)

11: HCLK/4 (Synchronous clock mode)

In all synchronous clock modes, there is no jitter in the delay from a timer trigger to the start of a conversion.

Note: 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 15:14 MDMA[1:0]: Direct memory access mode for dual ADC mode

This bit-field is set and cleared by software. Refer to the DMA controller section for more details.

00: MDMA mode disabled

01: reserved

10: MDMA mode enabled for 12 and 10-bit resolution

11: MDMA mode enabled for 8 and 6-bit resolution

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

Bit 13 DMACFG: DMA configuration (for dual ADC mode)

This bit is set and cleared by software to select between two DMA modes of operation and is effective only when DMAEN=1.

0: DMA One Shot Mode selected

1: DMA Circular Mode selected

For more details, refer to Section : Managing conversions using the DMA

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

Bit 12 Reserved, must be kept at reset value.

Bits 11:8 DELAY : Delay between 2 sampling phases

Set and cleared by software. These bits are used in dual interleaved modes. Refer to Table 95 for the value of ADC resolution versus DELAY bits values.

Note: 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 independent:

00000: Independent mode

00001 to 01001: 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: 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 95. DELAY bits versus ADC resolution

DELAY bits12-bit resolution10-bit resolution8-bit resolution6-bit resolution
0000\( 1 * T_{ADC\_CLK} \)\( 1 * T_{ADC\_CLK} \)\( 1 * T_{ADC\_CLK} \)\( 1 * T_{ADC\_CLK} \)
0001\( 2 * T_{ADC\_CLK} \)\( 2 * T_{ADC\_CLK} \)\( 2 * T_{ADC\_CLK} \)\( 2 * T_{ADC\_CLK} \)
0010\( 3 * T_{ADC\_CLK} \)\( 3 * T_{ADC\_CLK} \)\( 3 * T_{ADC\_CLK} \)\( 3 * T_{ADC\_CLK} \)
0011\( 4 * T_{ADC\_CLK} \)\( 4 * T_{ADC\_CLK} \)\( 4 * T_{ADC\_CLK} \)\( 4 * T_{ADC\_CLK} \)
0100\( 5 * T_{ADC\_CLK} \)\( 5 * T_{ADC\_CLK} \)\( 5 * T_{ADC\_CLK} \)\( 5 * T_{ADC\_CLK} \)
0101\( 6 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
0110\( 7 * T_{ADC\_CLK} \)\( 7 * T_{ADC\_CLK} \)\( 7 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
0111\( 8 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
1000\( 9 * T_{ADC\_CLK} \)\( 9 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
1001\( 10 * T_{ADC\_CLK} \)\( 10 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
1010\( 11 * T_{ADC\_CLK} \)\( 10 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
1011\( 12 * T_{ADC\_CLK} \)\( 10 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)
others\( 12 * T_{ADC\_CLK} \)\( 10 * T_{ADC\_CLK} \)\( 8 * T_{ADC\_CLK} \)\( 6 * T_{ADC\_CLK} \)

15.6.3 ADC common regular data register for dual mode (ADCx_CDR, x=12)

Address offset: 0x0C (this offset address is relative to the master ADC base address + 0x300)

Reset value: 0x0000 0000

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 15.3.29: Dual ADC modes (STM32F302xB/C/D/E only) .

The data alignment is applied as described in Section : Data register, data alignment and offset (ADCx_DR, OFFSETy, OFFSETy_CH, ALIGN)

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 15.3.29: Dual ADC modes (STM32F302xB/C/D/E only) .

The data alignment is applied as described in Section : Data register, data alignment and offset (ADCx_DR, OFFSETy, OFFSETy_CH, ALIGN)

In MDMA=0b11 mode, bits 15:8 contains SLV_ADC_DR[7:0], bits 7:0 contains MST_ADC_DR[7:0].

15.7 ADC register map

The following table summarizes the ADC registers.

Table 96. ADC global register map (1)

OffsetRegister
0x000 - 0x04CMaster ADC1
0x050 - 0x0FCReserved
0x100 - 0x14CSlave ADC2
0x118 - 0x1FCReserved
0x200 - 0x24CReserved
0x250 - 0x2FCReserved
0x300 - 0x308Master and slave ADCs common registers (ADC12)

1. The gray color is used for reserved memory addresses.

Table 97. ADC register map and reset values for each ADC (offset=0x000 for master ADC, 0x100 for slave ADC, x=1..2)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00ADCx_ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value00000000000
0x04ADCx_IERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value00000000000
0x08ADCx_CRADCALADCALDIFADVREGEN[1:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value001 000000
0x0CADCx_CFGRRes.AWD1CH[4:0]JAUTOJAWD1ENAWD1ENAWD1SGLJQMJDISCENDISCNUM [2:0]DISCENRes.AUTDLYCONTOVRMODEXTEN[1:0]EXTSEL [3:0]ALIGNRes [1:0]Res.DMACFGDMAEN
Reset value000000000000000000000000000000
0x10ReservedRes.
0x14ADCx_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]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 0
0x18ADCx_SMPR2Res.Res.Res.Res.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]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 00 0 0
0x1CReservedRes.
0x20ADCx_TR1Res.Res.Res.Res.HT1[11:0]LT1[11:0]
Reset value1 1 1 1 1 1 1 1 1 10000000000000
0x24ADCx_TR2Res.Res.Res.Res.Res.Res.Res.Res.HT2[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.LT2[7:0]
Reset value1 1 1 1 1 1 1 100000000
0x28ADCx_TR3Res.Res.Res.Res.Res.Res.Res.Res.HT3[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.LT3[7:0]
Reset value1 1 1 1 1 1 1 100000000
0x2CReservedRes.
0x30ADCx_SQR1Res.Res.Res.SQ4[4:0]Res.SQ3[4:0]Res.SQ2[4:0]Res.SQ1[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.L[3:0]
Reset value0 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0
0x34ADCx_SQR2Res.Res.Res.SQ9[4:0]Res.SQ8[4:0]Res.SQ7[4:0]Res.SQ6[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 0
0x38ADCx_SQR3Res.Res.Res.SQ14[4:0]Res.SQ13[4:0]Res.SQ12[4:0]Res.SQ11[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 0
0x3CADCx_SQR4Res.Res.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]Res.Res.
Reset value0 0 0 0 00 0 0 0 0
0x40ADCx_DRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.regular RDATA[15:0]
Reset value0000000000
0x44-0x48ReservedRes.
0x4CADCx_JSQRRes.JSQ4[4:0]Res.JSQ3[4:0]Res.JSQ2[4:0]Res.JSQ1[4:0]Res.JEXTEN[1:0]JEXTSEL [3:0]JL[1:0]
Reset value0 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 00 00 0 0 00 0
0x50-0x5CReservedRes.

Table 97. ADC register map and reset values for each ADC (offset=0x000 for master ADC, 0x100 for slave ADC, x=1..2) (continued)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x60ADCx_OFR1OFFSET1_ENOFFSET1_CH[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OFFSET1[11:0]
Reset value000000000000000000
0x64ADCx_OFR2OFFSET2_ENOFFSET2_CH[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OFFSET2[11:0]
Reset value000000000000000000
0x68ADCx_OFR3OFFSET3_ENOFFSET3_CH[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OFFSET3[11:0]
Reset value000000000000000000
0x6CADCx_OFR4OFFSET4_ENOFFSET4_CH[4:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OFFSET4[11:0]
Reset value000000000000000000
0x70-0x7CReservedRes.
0x80ADCx_JDR1Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JDATA1[15:0]
Reset value0000000000000000
0x84ADCx_JDR2Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JDATA2[15:0]
Reset value0000000000000000
0x88ADCx_JDR3Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JDATA3[15:0]
Reset value0000000000000000
0x8CADCx_JDR4Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JDATA4[15:0]
Reset value0000000000000000
0x8C-0x9CReservedRes.
0xA0ADCx_AWD2CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD2CH[18:1]Res.
Reset value000000000000000000
0xA4ADCx_AWD3CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3CH[18:1]Res.
Reset value000000000000000000
0xA8-0xACReservedRes.
0xB0ADCx_DIFSELRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DIFSEL[18:1]Res.
Reset value000000000000000000
0xB4ADCx_CALFACTRes.CALFACT_D[6:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CALFACT_S[6:0]Res.
Reset value00000000000000

Table 98. ADC register map and reset values (master and slave ADC common registers) offset =0x300, x=1 or 34)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00ADCx_CSRRes.Res.Res.Res.Res.JQOVF_SLVAWD3_SLVAWD2_SLVAWD1_SLVJEOS_SLVJEOC_SLVOVR_SLVEOS_SLVEOC_SLVEOSMP_SLVADRDY_SLVRes.Res.Res.Res.Res.JQOVF_MSTAWD3_MSTAWD2_MSTAWD1_MSTJEOS_MSTJEOC_MSTOVR_MSTEOS_MSTEOC_MSTEOSMP_MSTADRDY_MST
Reset value0000000000
0x04ReservedRes.
0x08ADCx_CCRRes.Res.Res.Res.Res.Res.Res.VBATENTSENVREFENRes.Res.Res.Res.CKMODE[1:0]MDMA[1:0]DMACFGRes.DELAY[3:0]Res.Res.Res.DUAL[4:0]
Reset value000000000000000000000
0x0CADCx_CDRRDATA_SLV[15:0]
Reset value00000000000000000000000000000000

Refer to Section 3.2 on page 51 for the register boundary addresses.