14. Analog-to-digital converter (ADC)

14.1 Introduction

The 12-bit ADC is a successive approximation analog-to-digital converter. It has up to 20 multiplexed channels allowing it to measure signals from 16 external and 4 internal sources. 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 analog watchdog feature allows the application to detect if the input voltage goes outside the user-defined higher or lower thresholds.

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

A built-in hardware oversampler allows analog performances to be improved while off-loading the related computational burden from the CPU.

14.2 ADC main features

14.3 ADC implementation

Table 65. ADC main features
ADC modes/featuresSTM32U0xx
Resolution12 bits
Maximum sampling speed2.5 Msps
Hardware offset calibrationX
Single-ended inputsX
Differential inputs-
Oversampling modeX
Data register16 bits
DMA supportX
Number of analog watchdogs3
Number of external channels16
Number of internal channels4

14.4 ADC functional description

Figure 31 shows the ADC block diagram and Table 66 gives the ADC pin description.

Figure 31. ADC block diagram

ADC block diagram showing internal components like SAR ADC, Input selection & scan control, Start & Stop control, and various external connections for triggers, calibration, and data output.

The block diagram illustrates the internal architecture of the ADC. At the core is the SAR ADC block, which receives CONVERTED DATA from an Over-sampler and is controlled by a start signal. The start signal is generated by a Start & Stop control block, which in turn is triggered by ADSTART (SW trigger) or HW trigger signals. The HW trigger signals are derived from external TRG0 through TRG7 pins through a series of flip-flops and an AND gate, with configuration from EXTEN[1:0] (trigger enable and edge selection) and EXTSEL[2:0] (trigger selection). The Start & Stop control also includes AUTDLY (Auto-delayed conversion) and ADSTP (stop conversion) features. The Input selection & scan control block manages ADC_IN[18:14, 10:0] channels and is configured by SCANDIR (up/down), CHSEL[19:0] , and CONT (single/continuous) signals. It also provides V IN [X] to the SAR ADC and is influenced by SMP[2:0] (sampling time). The SAR ADC is supported by a Supply and reference block connected to Analog supply VREF+ (VDDA) . This block also handles ADEN/ADDIS (Auto-off mode) and AUTOFF . Calibration is performed via LFTRIG and ADCAL (self-calibration). The ADC output DATA[15:0] is sent to an APB interface , which generates ADC interrupt (via ADREADY , EOSMP , EOS , EOC , OVR , AWDx flags) and DMA request signals. The APB interface is also configured by DMAEN and DMACFG . An ADC_AWDx_OUT signal is generated by a comparator that compares the DATA[15:0] with AWDx thresholds ( AWDxEN , AWDxSGL , AWDCHx[4:0] , LTx[11:0] , HTx[11:0] ). The ADC also features OVRMOD (overrun mode), ALIGN (left/right), and RES[1:0] (12, 10, 8 bits) settings. Other pins include TOVS , OVSS[3:0] , OVS[2:0] , and OVSE . A DISCEN (Discontinuous mode enable) pin is also shown.

ADC block diagram showing internal components like SAR ADC, Input selection & scan control, Start & Stop control, and various external connections for triggers, calibration, and data output.

MSV71275V1

14.4.1 ADC pins and internal signals

Table 66. ADC input/output pins

NameSignal typeRemarks
VDDAInput, analog power supplyAnalog power supply and positive reference voltage for the ADC
VSSAInput, analog supply groundGround for analog power supply
VREF+Input, analog reference positiveThe higher/positive reference voltage for the ADC.
ADC_INxAnalog input signals16 external analog input channels

Table 67. ADC internal input/output signals

Internal signal nameSignal typeDescription
V IN [x]Analog input channelsConnected either to internal channels or to ADC_INi external channels
TRGxInputADC conversion triggers
V SENSEInputInternal temperature sensor output voltage
V REFINTInputInternal voltage reference output voltage
V BAT/3InputVBAT pin input voltage divided by 3
dac_out1InputDAC internal channel1 input
ADC_AWDx_OUTOutputInternal analog watchdog output signal connected to on-chip timers (x = Analog watchdog number = 1,2,3)

Table 68. External triggers

NameSourceEXTSEL[2:0]
TRG0TIM1_TRGO2000
TRG1TIM1_CC4001
TRG2TIM2_TRGO010
TRG3TIM3_TRGO011
TRG4TIM15_TRGO100
TRG5TIM6_TRGO101
TRG6Reserved110
TRG7EXTI11111

14.4.2 ADC voltage regulator (ADVREGEN)

The ADC has a specific internal voltage regulator which must be enabled and stable before using the ADC.

The ADC internal voltage regulator can be enabled by setting ADVREGEN bit to 1 in the ADC_CR register. The software must wait for the ADC voltage regulator startup time ( \( t_{ADCVREG\_STUP} \) ) before launching a calibration or enabling the ADC. This delay must be managed by software (for details on \( t_{ADCVREG\_STUP} \) , refer to the device datasheet).

After ADC operations are complete, the ADC is disabled (ADEN = 0). To keep power consumption low, it is important to disable the ADC voltage regulator before entering low-power mode (LPRun, LPSleep or Stop mode). Refer to Section : ADC voltage regulator disable sequence .

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

Analog reference from the power control unit

The internal ADC voltage regulator internally uses an analog reference delivered by the power control unit through a buffer. This buffer is always enabled when the main voltage regulator of the power control unit operates in normal Run mode (refer to Reset and clock control and power control sections).

If the main voltage regulator enters low-power mode (such as Low-power run mode), this buffer is disabled and the ADC cannot be used.

ADC Voltage regulator enable sequence

To enable the ADC voltage regulator, set ADVREGEN bit to 1 in ADC_CR register.

ADC voltage regulator disable sequence

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

  1. 1. Make sure that the ADC is disabled (ADEN = 0).
  2. 2. Clear ADVREGEN bit in ADC_CR register.

14.4.3 Calibration (ADCAL)

The ADC has a calibration feature. During the procedure, the ADC calculates a calibration factor which is internally applied to the ADC until the next ADC power-off. The application must not use the ADC during calibration and must wait until it is complete.

Calibration should be performed before starting A/D conversion. It removes the offset error which may vary from chip to chip due to process variation.

The calibration is initiated by software by setting bit ADCAL to 1. It can be initiated only when all the following conditions are met:

ADCAL bit stays at 1 during all the calibration sequence. It is then cleared by hardware as soon the calibration completes. After this, the calibration factor can be read from the ADC_DR register (from bits 6 to 0).

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 and temperature change to a lesser extend), it is recommended to re-run a calibration cycle.

The calibration factor is lost in the following cases:

The calibration factor is lost each time power is removed from the ADC (for example when the product enters Standby or VBAT mode). Still, it is possible to save and restore the calibration factor by software to save time when re-starting the ADC (as long as temperature and voltage are stable during the ADC power-down).

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

Software calibration procedure

  1. 1. Ensure that ADEN = 0, AUTOFF = 0, ADVREGEN = 1, and DMAEN = 0.
  2. 2. Set ADCAL = 1.
  3. 3. Wait until ADCAL = 0 (or until EOCAL = 1). This can be handled by interrupt if the interrupt is enabled by setting the EOCALIE bit in the ADC_IER register.
  4. 4. The calibration factor minus one can then be read from bits 6:0 of the ADC_DR or ADC_CALFACT registers. The resulting calibration factor must be incremented by one and written back to the ADC_CALFACT register.
  5. 5. To reduce the noise effect of the calibration factor extraction, the software can make the average of eight calibration factor values. This step is optional but recommended for better accuracy.

The averaging procedure is as follows

  1. a) Obtain eight incremented calibration factor values (perform eight times step 2 to step 4).
  2. b) Calculate the average of these eight values and round it up to the nearest integer.
  3. c) Write the result to the ADC_CALFACT register.

Note: If the resulting calibration factor is higher than 0x7F, write 0x7F to the ADC_CALFACT register to avoid overflow.

Figure 32. ADC calibration

Timing diagram for ADC calibration showing ADCAL signal, ADC State (OFF, Startup, CALIBRATE, OFF), and ADC_DR[6:0]/ADC_CALFACT[6:0] register value (0x00) over time tCAB. The diagram shows the sequence of events for calibration: software write to start calibration, hardware startup, calibration execution, and hardware completion.

The diagram illustrates the timing for ADC calibration. The ADCAL signal is set by software (SW) to start calibration. The ADC State transitions from OFF to Startup, then to CALIBRATE, and finally back to OFF upon hardware completion (HW). During the CALIBRATE state, the ADC_DR[6:0] or ADC_CALFACT[6:0] register is set to 0x00. The total duration of the calibration process is labeled as \( t_{CAB} \) .

Timing diagram for ADC calibration showing ADCAL signal, ADC State (OFF, Startup, CALIBRATE, OFF), and ADC_DR[6:0]/ADC_CALFACT[6:0] register value (0x00) over time tCAB. The diagram shows the sequence of events for calibration: software write to start calibration, hardware startup, calibration execution, and hardware completion.

Calibration factor forcing software procedure

  1. 1. Ensure that ADEN = 1 and ADSTART = 0 (ADC started with no conversion ongoing)
  2. 2. Write ADC_CALFACT with the saved calibration factor
  3. 3. The calibration factor is used as soon as a new conversion is launched.

Figure 33. Calibration factor forcing

Timing diagram for calibration factor forcing showing ADC state transitions (Ready, Converting channel) and the update of the internal calibration factor from F1 to F2 upon a new conversion start.

This diagram shows the procedure for forcing a calibration factor. The ADC starts in a 'Ready (not converting)' state with an internal calibration factor of F1. A 'WRITE ADC_CALFACT' is performed by software to update the factor to F2. When a new conversion is started (either by hardware or software), the ADC enters a 'Converting channel (Single ended)' state, and the internal calibration factor is updated to F2. Once the conversion is complete, the ADC returns to the 'Ready' state with the new calibration factor F2.

Timing diagram for calibration factor forcing showing ADC state transitions (Ready, Converting channel) and the update of the internal calibration factor from F1 to F2 upon a new conversion start.

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

At power-up, the ADC is disabled and put in power-down mode (ADEN = 0).

As shown in Figure 34, the ADC needs a stabilization time of \( t_{STAB} \) before it starts converting accurately.

Two control bits are used to enable or disable the ADC:

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

Follow this procedure to enable the ADC:

  1. 1. Clear the ADRDY bit in ADC_ISR register by programming this bit to 1.
  2. 2. Set ADEN = 1 in the ADC_CR register.
  3. 3. Wait until ADRDY = 1 in the ADC_ISR register (ADRDY is set after the ADC startup time). This can be handled by interrupt if the interrupt is enabled by setting the ADRDYIE bit in the ADC_IER register.

Follow this procedure to disable the ADC:

  1. 1. Check that ADSTART = 0 in the ADC_CR register to ensure that no conversion is ongoing. If required, stop any ongoing conversion by writing 1 to the ADSTP bit in the ADC_CR register and waiting until this bit is read at 0.
  2. 2. Set ADDIS = 1 in the ADC_CR register.
  3. 3. If required by the application, wait until ADEN = 0 in the ADC_CR register, indicating that the ADC is fully disabled (ADDIS is automatically reset once ADEN = 0).
  4. 4. Clear the ADRDY bit in ADC_ISR register by programming this bit to 1 (optional).

Figure 34. Enabling/disabling the ADC

Timing diagram for enabling and disabling the ADC. It shows four signal lines: ADEN, ADRDY, ADDIS, and ADC state. 1. ADEN is set by S/W (rising edge), transitioning ADC state from OFF to Startup. 2. After a startup time tSTAB, ADRDY is set by H/W (rising edge), transitioning ADC state to RDY. 3. ADRDY is then cleared by S/W (falling edge). 4. ADC state transitions to Converting CH (indicated by dashed lines). 5. After conversion, ADC state returns to RDY. 6. ADDIS is set by S/W (rising edge), transitioning ADC state to REQ-OFF. 7. ADEN is cleared by H/W (falling edge) and ADDIS is cleared by H/W (falling edge), transitioning ADC state back to OFF. A legend shows an upward arrow for 'by S/W' and a downward arrow for 'by H/W'. Reference MSv62472V1.
Timing diagram for enabling and disabling the ADC. It shows four signal lines: ADEN, ADRDY, ADDIS, and ADC state. 1. ADEN is set by S/W (rising edge), transitioning ADC state from OFF to Startup. 2. After a startup time tSTAB, ADRDY is set by H/W (rising edge), transitioning ADC state to RDY. 3. ADRDY is then cleared by S/W (falling edge). 4. ADC state transitions to Converting CH (indicated by dashed lines). 5. After conversion, ADC state returns to RDY. 6. ADDIS is set by S/W (rising edge), transitioning ADC state to REQ-OFF. 7. ADEN is cleared by H/W (falling edge) and ADDIS is cleared by H/W (falling edge), transitioning ADC state back to OFF. A legend shows an upward arrow for 'by S/W' and a downward arrow for 'by H/W'. Reference MSv62472V1.

Note: In Auto-off mode (AUTOFF = 1) the power-on/off phases are performed automatically, by hardware and the ADRDY flag is not set.

When the bus clock is much faster than the analog ADC clock ( \( f_{ADC} \) ), a minimum delay of ten \( f_{ADC} \) clock cycles must be respected between ADEN and ADDIS bit settings.

14.4.5 ADC clock (CKMODE, PRESC[3:0])

The ADC has a dual clock-domain architecture, so that the ADC can be fed with a clock (ADC asynchronous clock) independent from the APB clock (PCLK).

Figure 35. ADC clock scheme

Figure 35. ADC clock scheme diagram showing the internal clock architecture of the ADC. The RCC (Reset & Clock Controller) provides the PCLK clock to the ADITF block. The ADITF block contains an APB interface and two clock paths. The first path takes the PCLK clock and divides it by 1, 2, or 4 based on the CKMODE[1:0] bits of the ADC_CFGR2 register. The second path takes the ADC asynchronous clock and divides it by a programmable factor (1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256) based on the PRESC[3:0] bits of the ADC_CCR register. Both paths lead to a multiplexer (Others) which selects the clock source for the Analog ADC. The output of the multiplexer is the Analog ADC clock (fADC). The diagram is labeled MSV31926V5.
Figure 35. ADC clock scheme diagram showing the internal clock architecture of the ADC. The RCC (Reset & Clock Controller) provides the PCLK clock to the ADITF block. The ADITF block contains an APB interface and two clock paths. The first path takes the PCLK clock and divides it by 1, 2, or 4 based on the CKMODE[1:0] bits of the ADC_CFGR2 register. The second path takes the ADC asynchronous clock and divides it by a programmable factor (1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256) based on the PRESC[3:0] bits of the ADC_CCR register. Both paths lead to a multiplexer (Others) which selects the clock source for the Analog ADC. The output of the multiplexer is the Analog ADC clock (fADC). The diagram is labeled MSV31926V5.
  1. 1. Refer to Section Reset and clock control (RCC) for how the PCLK clock and ADC asynchronous clock are enabled.

The input clock of the analog ADC can be selected between two different clock sources (see Figure 35: ADC clock scheme to see how the PCLK clock and the ADC asynchronous clock are enabled):

  1. a) The ADC clock can be a specific clock source, named “ADC asynchronous clock” which is independent and asynchronous with the APB clock.

Refer to RCC Section for more information on generating this clock source.

To select this scheme, bits CKMODE[1:0] of the ADC_CFGR2 register must be reset.

  1. b) The ADC clock can be derived from the APB clock of the ADC bus interface, divided by a programmable factor (1, 2 or 4) according to bits CKMODE[1:0].

To select this scheme, bits CKMODE[1:0] of the ADC_CFGR2 register must be different from “00”.

In option a), the generated ADC clock can eventually be divided by a prescaler (1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256) when programming the bits PRESC[3:0] in the ADC_CCR register).

Option a) has the advantage of reaching the maximum ADC clock frequency whatever the APB clock scheme selected.

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

Table 69. Latency between trigger and start of conversion (1)
ADC clock sourceCKMODE[1:0]Latency between the trigger event and the start of conversion
SYSCLK, PLLPCLK, or HSI16 clock (2)00Latency is not deterministic (jitter)
PCLK divided by 201Latency is deterministic (no jitter) and equal to 3.25 \( f_{ADC} \) cycles
PCLK divided by 410Latency is deterministic (no jitter) and equal to 3.125 \( f_{ADC} \) cycles
PCLK divided by 111Latency is deterministic (no jitter) and equal to 3 \( f_{ADC} \) cycles

1. Refer to the device datasheet for the maximum \( f_{ADC} \) frequency.

2. Selected with ADCSEL bitfield of the RCC_CCIPR register.

  1. Caution: For correct operation of the ADC analog block, the analog ADC clock ( \( f_{ADC} \) ) must have a duty cycle ranging from 45% to 55%. This is granted when the incoming clock (PCLK or ADC asynchronous clock) is divided by a factor of two or higher, using one of the scaler blocks inside the ADC. If it is not the case, some additional rules must be followed:
    • • When CKMODE[1:0] = 11 (PCLK divided by one), the AHB and APB prescalers in the RCC must be configured in bypass mode.
    • • When the analog ADC clock is derived from the HSE or LSE bypass clock, this bypass clock must have a 45-to-55% duty cycle unless this clock is routed to the ADC through the PLL.

14.4.6 ADC connectivity

ADC inputs are connected to the external channels as well as internal sources as described in Figure 36.

Figure 36. ADC connectivity

Schematic diagram of ADC connectivity for SRTM32U0xx showing 20 channels (VIN[0] to VIN[19]) connected to a SAR ADC1. Channels include external pins ADC_IN0 to ADC_IN18, and internal sources VSENSE, VREFINT, VBAT/3, and dac_out1. A 'Channel selection' switch matrix is shown between the channels and the ADC input VIN.

The diagram illustrates the internal architecture of the ADC for the SRTM32U0xx microcontroller. It features a SAR ADC1 block connected to a common input line labeled \( V_{IN} \) . This input line is connected to a 'Channel selection' switch matrix. The matrix allows for the selection of various analog sources as input channels \( V_{IN}[0] \) through \( V_{IN}[19] \) . The sources include external pins \( ADC\_IN0 \) through \( ADC\_IN18 \) , and internal reference and output sources: \( V_{SENSE} \) , \( V_{REFINT} \) , \( V_{BAT/3} \) , and \( dac\_out1 \) . The SAR ADC1 is shown with its power supply pins \( V_{DDA} \) and \( V_{SSA} \) . The diagram is labeled with 'SRTM32U0xx' at the top and 'MSV71276V1' at the bottom right.

Schematic diagram of ADC connectivity for SRTM32U0xx showing 20 channels (VIN[0] to VIN[19]) connected to a SAR ADC1. Channels include external pins ADC_IN0 to ADC_IN18, and internal sources VSENSE, VREFINT, VBAT/3, and dac_out1. A 'Channel selection' switch matrix is shown between the channels and the ADC input VIN.

14.4.7 Configuring the ADC

The software must write the ADCAL and ADEN bits in the ADC_CR register and configure the ADC_CFGR1 and ADC_CFGR2 registers only when the ADC is disabled (ADEN must be cleared).

The software must only write to the ADSTART and ADDIS bits in the ADC_CR register only if the ADC is enabled and there is no pending request to disable the ADC (ADEN = 1 and ADDIS = 0).

For all the other control bits in the ADC_IER, ADC_SMPR, ADC_CHSELR and ADC_CCR registers, refer to the description of the corresponding control bit in Section 14.13: ADC registers .

ADC_AWDTRx registers can be modified when conversion is ongoing.

The software must only write to the ADSTP bit in the ADC_CR register if the ADC is enabled (and possibly converting) and there is no pending request to disable the ADC (ADSTART = 1 and ADDIS = 0).

Note: There is no hardware protection preventing software from making write operations forbidden by the above rules. If such a forbidden write access occurs, the ADC may enter an undefined state. To recover correct operation in this case, the ADC must be disabled (clear ADEN = 0 and all the bits in the ADC_CR register).

14.4.8 Channel selection (CHSEL, SCANDIR, CHSELROMOD)

There are up to 20 multiplexed channels:

It is possible to convert a single channel or a sequence of channels.

The sequence of the channels to be converted can be programmed in the ADC_CHSELR channel selection register: each analog input channel has a dedicated selection bit (CHSELx).

The ADC scan sequencer can be used in two different modes:

The order in which the channels are scanned is defined by the channel number (CHSELROMOD bit must be cleared in ADC_CFGR1 register):

The CHSELROMOD bit is set in ADC_CFGR1 register.

After programming ADC CHSELR, SCANDIR and CHSELROMOD bits, it is mandatory to wait for CCRDY flag before starting conversions. It indicates that the new channel setting has

been applied. If a new configuration is required, the CCRDY flag must be cleared prior to starting the conversion.

The software is allowed to program the CHSEL, SCANDIR, CHSELROMOD bits only when ADSTART bit is cleared (which ensures that no conversion is ongoing).

Temperature sensor, DAC output, V REFINT and V BAT internal channels

The temperature sensor is connected to channel ADC V IN [11].

The internal voltage reference V REFINT is connected to channel ADC V IN [12].

V BAT channel is connected to ADC V IN [13] channel.

The internal dac_out1 output voltage is connected to ADC V IN [19] channel.

When V REF+ is lower than V DDA , this channel is not converted.

14.4.9 Programmable sampling time (SMPx[2:0])

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

Having a programmable sampling time allows the conversion speed to be trimmed according to the input resistance of the input voltage source.

The ADC samples the input voltage for a number of ADC clock cycles that can be modified using the SMP1[2:0] and SMP2[2:0] bits in the ADC_SMPR register.

Each channel can choose one out of two sampling times configured in SMP1[2:0] and SMP2[2:0] bitfields, through SMPSELx bits in ADC_SMPR register.

The total conversion time is calculated as follows:

\[ t_{\text{CONV}} = \text{Sampling time} + 12.5 \times \text{ADC clock cycles} \]

Example:

With \( f_{\text{ADC}} = 16 \text{ MHz} \) and a sampling time of 1.5 ADC clock cycles:

\[ t_{\text{CONV}} = 1.5 + 12.5 = 14 \text{ ADC clock cycles} = 0.875 \text{ } \mu\text{s} \]

The ADC indicates the end of the sampling phase by setting the EOSMP flag.

14.4.10 Single conversion mode (CONT = 0)

In Single conversion mode, the ADC performs a single sequence of conversions, converting all the channels once. This mode is selected when CONT = 0 in the ADC_CFGR1 register. Conversion is started by either:

Inside the sequence, after each conversion is complete:

After the sequence of conversions is complete:

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

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

14.4.11 Continuous conversion mode (CONT = 1)

In continuous conversion mode, when a software or hardware trigger event occurs, the ADC performs a sequence of conversions, converting all the channels once and then automatically re-starts and continuously performs the same sequence of conversions. This mode is selected when CONT = 1 in the ADC_CFGR1 register. Conversion is started by either:

Inside the 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 bits DISCEN = 1 and CONT = 1.

14.4.12 Starting conversions (ADSTART)

Software starts ADC conversions by setting ADSTART = 1.

When ADSTART is set, the conversion:

The ADSTART bit is also used to indicate whether an ADC operation is currently ongoing. It is possible to re-configure the ADC while ADSTART = 0, indicating that the ADC is idle.

The ADSTART bit is cleared by hardware:

Note: In continuous mode (CONT = 1), the ADSTART bit is not cleared by hardware when the EOS flag is set because the sequence is automatically relaunched.

When hardware trigger is selected in single mode (CONT = 0 and EXTEN = 01), ADSTART is not cleared by hardware when the EOS flag is set (except if DMAEN = 1 and DMACFG = 0 in which case ADSTART is cleared at end of the DMA transfer). This avoids the need for software having to set the ADSTART bit again and ensures the next trigger event is not missed.

After changing channel selection configuration (by programming ADC_CHSELR register or changing CHSELRMOD or SCANDIR), it is mandatory to wait until CCRDY flag is asserted before asserting ADSTART, otherwise the value written to ADSTART is ignored.

14.4.13 Timings

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_{\text{CONV}} = t_{\text{SAMPL}} + t_{\text{SAR}} = [1.5 \text{ } t_{\text{min}} + 12.5 \text{ } t_{\text{12bit}}] \times 1/f_{\text{ADC}} \]

\[ t_{\text{CONV}} = t_{\text{SAMPL}} + t_{\text{SAR}} = 42.9 \text{ ns } t_{\text{min}} + 357.1 \text{ ns } t_{\text{12bit}} = 0.400 \text{ } \mu\text{s } t_{\text{min}} \text{ (for } f_{\text{ADC}} = 35 \text{ MHz)} \]

Figure 37. Analog-to-digital conversion time

Timing diagram for Figure 37 showing ADC state, Analog channel, Internal S/H, ADSTART, EOSMP, EOC, and ADC_DR signals over time. It illustrates the sequence from RDY to Sampling Ch(N), then Converting Ch(N), and finally Sampling Ch(N+1). Key timing parameters t_SAMPL and t_SAR are indicated.

The diagram shows the timing sequence for an ADC conversion. The ADC state transitions from RDY to Sampling Ch(N), then to Converting Ch(N), and finally to Sampling Ch(N+1). The Analog channel is active during the sampling phases. The Internal S/H signal shows the sample and hold phases for AIN(N) and AIN(N+1). ADSTART is set by software (SW) to begin the conversion. EOSMP is set by hardware (HW) at the end of sampling and cleared by SW. EOC is set by HW at the end of conversion and cleared by HW/SW. ADC_DR contains Data N-1 and Data N. Indicative timings \( t_{\text{SAMPL}}^{(1)} \) and \( t_{\text{SAR}}^{(2)} \) are shown. MSV30532V2

Timing diagram for Figure 37 showing ADC state, Analog channel, Internal S/H, ADSTART, EOSMP, EOC, and ADC_DR signals over time. It illustrates the sequence from RDY to Sampling Ch(N), then Converting Ch(N), and finally Sampling Ch(N+1). Key timing parameters t_SAMPL and t_SAR are indicated.
  1. 1. \( t_{\text{SAMPL}} \) depends on SMP[2:0].
  2. 2. \( t_{\text{SAR}} \) depends on RES[2:0].
  3. 3. The synchronization between the analog clock and the digital clock domains is not described in the above figure.

Figure 38. ADC conversion timings

Timing diagram for Figure 38 showing ADSTART, ADC state, and ADC_DR signals. It illustrates the sequence from Ready to Conversion 0, 1, 2, and 3, with trigger latency t_LATR and write latency W_LATENCY indicated.

The diagram shows the timing sequence for ADC conversions. ADSTART is triggered, and the ADC state transitions from Ready to S0, then Conversion 0, S1, Conversion 1, S2, Conversion 2, S3, and Conversion 3. The ADC_DR register contains Data 0, Data 1, and Data 2. The trigger latency \( t_{\text{LATR}}^{(2)} \) and write latency \( W_{\text{LATENCY}}^{(3)} \) are indicated. MSV33174V2

Timing diagram for Figure 38 showing ADSTART, ADC state, and ADC_DR signals. It illustrates the sequence from Ready to Conversion 0, 1, 2, and 3, with trigger latency t_LATR and write latency W_LATENCY indicated.
  1. 1. EXTEN = 00 or EXTEN ≠ 00.
  2. 2. Trigger latency (refer to datasheet for more details).
  3. 3. ADC_DR register write latency (refer to datasheet for more details).

14.4.14 Stopping an ongoing conversion (ADSTP)

The software can decide to stop any ongoing conversions by setting ADSTP = 1 in the ADC_CR register.

This resets the ADC operation and the ADC is idle, ready for a new operation.

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

The scan sequence is also aborted and reset (meaning that restarting the ADC would restart a new sequence).

Once this procedure is complete, the ADSTP and ADSTART bits are both cleared by hardware and the software must wait until ADSTART=0 before starting new conversions.

Figure 39. Stopping an ongoing conversion

Timing diagram showing ADC state, ADSTART, ADSTOP, and ADC_DR signals over time. The ADC state transitions from RDY to SAMPLING CH(N) to CONVERTING CH(N) and back to RDY. ADSTART is set by software at the start of conversion and cleared by hardware when the conversion ends. ADSTOP is set by software while the conversion is ongoing and cleared by hardware when the conversion ends. ADC_DR contains DATA N-1 during the conversion.

The diagram illustrates the timing of ADC signals when stopping an ongoing conversion. The top row shows the ADC state: RDY → SAMPLING CH(N) → CONVERTING CH(N) → RDY. The second row shows the ADSTART signal: it is set by software (SW) at the start of the conversion and cleared by hardware (HW) when the conversion ends. The third row shows the ADSTOP signal: it is set by software (SW) while the conversion is ongoing and cleared by hardware (HW) when the conversion ends. The bottom row shows the ADC_DR register: it contains DATA N-1 during the conversion. A vertical dashed line marks the point where the conversion ends and the ADC returns to the RDY state.

Timing diagram showing ADC state, ADSTART, ADSTOP, and ADC_DR signals over time. The ADC state transitions from RDY to SAMPLING CH(N) to CONVERTING CH(N) and back to RDY. ADSTART is set by software at the start of conversion and cleared by hardware when the conversion ends. ADSTOP is set by software while the conversion is ongoing and cleared by hardware when the conversion ends. ADC_DR contains DATA N-1 during the conversion.

14.5 Conversion on external trigger and trigger polarity (EXTSEL, EXTEN)

A conversion or a sequence of conversion can be triggered either by software or by an external event (for example timer capture). If the EXTEN[1:0] control bits are not equal to “0b00”, then external events are able to trigger a conversion with the selected polarity. The trigger selection is effective once software has set bit ADSTART = 1.

Any hardware triggers which occur while a conversion is ongoing are ignored.

If bit ADSTART = 0, any hardware triggers which occur are ignored.

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

Table 70. Configuring the trigger polarity

SourceEXTEN[1:0]
Trigger detection disabled00
Detection on rising edge01
Detection on falling edge10
Detection on both rising and falling edges11

Note: The polarity of the external trigger can be changed only when the ADC is not converting ( \( ADSTART = 0 \) ).

The EXTSEL[2:0] control bits are used to select which of 8 possible events can trigger conversions.

Refer to Table 68: External triggers in Section 14.4.1: ADC pins and internal signals for the list of all the external triggers that can be used for regular conversion.

The software source trigger events can be generated by setting the ADSTART bit in the ADC_CR register.

Note: The trigger selection can be changed only when the ADC is not converting ( \( ADSTART = 0 \) ).

14.5.1 Discontinuous mode (DISCEN)

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

In this mode ( \( DISCEN = 1 \) ), a hardware or software trigger event is required to start each conversion defined in the sequence. On the contrary, if \( DISCEN = 0 \) , a single hardware or software trigger event successively starts all the conversions defined in the sequence.

Example:

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

14.5.2 Programmable resolution (RES) - Fast conversion mode

It is possible to obtain faster conversion times ( \( t_{SAR} \) ) by reducing the ADC resolution.

The resolution can be configured to be either 12, 10, 8, or 6 bits by programming the RES[1:0] bits in the ADC_CFGR1 register. Lower resolution allows faster conversion times for applications where high data precision is not required.

Note: The RES[1:0] bit must only be changed when the ADEN bit is reset.

The result of the conversion is always 12 bits wide and any unused LSB bits are read as zeros.

Lower resolution reduces the conversion time needed for the successive approximation steps as shown in Table 71 .

Table 71. \( t_{SAR} \) timings depending on resolution

RES[1:0]
(bits)
\( t_{SAR} \)
( \( f_{ADC} \) cycles)
\( t_{SAR} \) at
\( f_{ADC} = 35 \) MHz
(ns)
\( t_{SMPL(min)} \)
( \( f_{ADC} \) cycles)
\( t_{CONV} \) with min. \( t_{SMPL} \)
( \( f_{ADC} \) cycles)
\( t_{CONV(min)} \) at
\( f_{ADC} = 35 \) MHz
(ns)
1212.53571.514400
1010.53001.512343
88.52431.510286
66.51861.58229

14.5.3 End of conversion, end of sampling phase (EOC, EOSMP flags)

The ADC indicates each end of conversion (EOC) event.

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

The ADC also indicates the end of sampling phase by setting the EOSMP flag in the ADC_ISR register. The EOSMP flag is cleared by software by writing 1 to it. An interrupt can be generated if the EOSMPIE bit is set in the ADC_IER register.

The aim of this interrupt is to allow the processing to be synchronized with the conversions. Typically, an analog multiplexer can be accessed in hidden time during the conversion phase, so that the multiplexer is positioned when the next sampling starts.

Note: As there is only a very short time left between the end of the sampling and the end of the conversion, it is recommenced to use polling or a WFE instruction rather than an interrupt and a WFI instruction.

14.5.4 End of conversion sequence (EOS flag)

The ADC notifies the application of each end of sequence (EOS) event.

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

14.5.5 Example timing diagrams (single/continuous modes hardware/software triggers)

Figure 40. Single conversions of a sequence, software trigger

Timing diagram for Figure 40: Single conversions of a sequence, software trigger. The diagram shows several signal lines: ADSTART(1), EOC, EOS, SCANDIR, ADC state(2), and ADC_DR. ADSTART(1) shows two rising edges triggered by software (S/W) and falling edges. EOC (End of Conversion) shows pulses for each channel conversion. EOS (End of Sequence) shows a pulse after the last channel in a sequence. SCANDIR indicates the scan direction. ADC state(2) transitions from RDY to CH0, CH9, CH10, CH17, and back to RDY, then reverses order in the second sequence. ADC_DR shows data values D0, D9, D10, D17 corresponding to the conversions. A legend indicates 'by S/W' with a rising arrow and 'by H/W' with a filled rising arrow. MSv30338V3 is the reference number.
Timing diagram for Figure 40: Single conversions of a sequence, software trigger. The diagram shows several signal lines: ADSTART(1), EOC, EOS, SCANDIR, ADC state(2), and ADC_DR. ADSTART(1) shows two rising edges triggered by software (S/W) and falling edges. EOC (End of Conversion) shows pulses for each channel conversion. EOS (End of Sequence) shows a pulse after the last channel in a sequence. SCANDIR indicates the scan direction. ADC state(2) transitions from RDY to CH0, CH9, CH10, CH17, and back to RDY, then reverses order in the second sequence. ADC_DR shows data values D0, D9, D10, D17 corresponding to the conversions. A legend indicates 'by S/W' with a rising arrow and 'by H/W' with a filled rising arrow. MSv30338V3 is the reference number.

Figure 41. Continuous conversion of a sequence, software trigger

Timing diagram for Figure 41: Continuous conversion of a sequence, software trigger. Signal lines include ADSTART(1), EOC, EOS, ADSTP, SCANDIR, ADC state(2), and ADC_DR. ADSTART(1) starts the continuous conversion. EOC pulses for each channel. EOS pulses at the end of each sequence. ADSTP (ADC Stop) is used to halt the continuous process. SCANDIR shows the scan direction. ADC state(2) cycles through CH0, CH9, CH10, CH17 repeatedly until ADSTP is asserted, transitioning to STP and then RDY. ADC_DR captures data D0, D9, D10, D17 for each cycle. Legend: 'by S/W' (rising arrow), 'by H/W' (filled rising arrow). MSv30339V2 is the reference number.
Timing diagram for Figure 41: Continuous conversion of a sequence, software trigger. Signal lines include ADSTART(1), EOC, EOS, ADSTP, SCANDIR, ADC state(2), and ADC_DR. ADSTART(1) starts the continuous conversion. EOC pulses for each channel. EOS pulses at the end of each sequence. ADSTP (ADC Stop) is used to halt the continuous process. SCANDIR shows the scan direction. ADC state(2) cycles through CH0, CH9, CH10, CH17 repeatedly until ADSTP is asserted, transitioning to STP and then RDY. ADC_DR captures data D0, D9, D10, D17 for each cycle. Legend: 'by S/W' (rising arrow), 'by H/W' (filled rising arrow). MSv30339V2 is the reference number.

Figure 42. 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 start of conversion, the sequence of channels (CH0, CH1, CH2, CH3), and the resulting data (D0, D1, D2, D3).

The timing diagram shows the following signals and their states over time:

Legend:

MSv30340V2

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 start of conversion, the sequence of channels (CH0, CH1, CH2, CH3), and the resulting data (D0, D1, D2, D3).
  1. 1. EXTSEL = TRGx (over-frequency), EXTEN = 01 (rising edge), CONT = 0
  2. 2. CHSEL = 0xF, SCANDIR = 0, WAIT = 0, AUTOFF = 0

Figure 43. 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 over time. The diagram illustrates the start of conversion, the sequence of channels (CH0, CH1, CH2, CH3), and the resulting data (D0, D1, D2, D3).

The timing diagram shows the following signals and their states over time:

Legend:

MSv30341V2

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 over time. The diagram illustrates the start of conversion, the sequence of channels (CH0, CH1, CH2, CH3), and the resulting data (D0, D1, D2, D3).
  1. 1. EXTSEL = TRGx, EXTEN = 10 (falling edge), CONT = 1
  2. 2. CHSEL = 0xF, SCANDIR = 0, WAIT = 0, AUTOFF = 0

14.5.6 Low frequency trigger mode

Once the ADC is enabled or the last ADC conversion is complete, the ADC is ready to start a new conversion. The ADC needs to be started at a predefined time ( \( t_{idle} \) ) otherwise ADC converted data might be corrupted due to the transistor leakage (refer to the device datasheet for the maximum value of \( t_{idle} \) ).

If the application has to support a time longer than the maximum \( t_{idle} \) value (between one trigger to another for single conversion mode or between the ADC enable and the first ADC conversion), then the ADC internal state needs to be rearmed. This mechanism can be enabled by setting LFTRIG bit to 1 in ADC_CFGR2 register. By setting this bit, any trigger (software or hardware) sends a rearm command to ADC. The conversion starts after a one ADC clock cycle delay compared to LFTRIG cleared.

It is not necessary to use this mode when AUTOFF bit is set. For Wait mode, only the first trigger generates an internal rearm command.

14.6 Data management

14.6.1 Data register and data alignment (ADC_DR, ALIGN)

At the end of each conversion (when an EOC event occurs), the result of the converted data is stored in the ADC_DR data register which is 16-bit wide.

The format of the ADC_DR depends on the configured data alignment and resolution.

The ALIGN bit in the ADC_CFGR1 register selects the alignment of the data stored after conversion. Data can be right-aligned (ALIGN = 0) or left-aligned (ALIGN = 1) as shown in Figure 44.

Figure 44. Data alignment and resolution (oversampling disabled: OVSE = 0)

ALIGNRES1514131211109876543210
00x00x0DR[11:0]
0x10x00DR[9:0]
0x20x00DR[7:0]
0x30x00DR[5:0]
10x0DR[11:0]0x0
0x1DR[9:0]0x00
0x2DR[7:0]0x00
0x30x00DR[5:0]0x0

MS30342V1

14.6.2 ADC overrun (OVR, OVRMOD)

The overrun flag (OVR) indicates a data overrun event, when the converted data was not read in time by the CPU or the DMA, before the data from a new conversion is available.

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

When an overrun condition occurs, the ADC keeps operating and can continue to convert unless the software decides to stop and reset the sequence by setting the ADSTP bit in the ADC_CR register.

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

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

Figure 45. Example of overrun (OVR)

Timing diagram showing ADC signals (ADSTART, EOC, EOS, OVR, ADSTP, TRGx) and data states (RDY, CH0, CH1, CH2, STOP) over time. It illustrates an overrun condition where a new conversion starts before the previous data is read. Two scenarios for OVRMOD=0 and OVRMOD=1 are shown for the ADC_DR register values.

The diagram illustrates the timing of an ADC overrun. The top section shows signal transitions for ADSTART (1) , EOC, EOS, OVR, ADSTP, and TRGx (1) . Below this, the 'ADC state (2) ' shows a sequence of states: RDY, CH0, CH1, CH2, CH0, CH1, CH2, CH0, STOP, RDY. The 'ADC_DR read access' line shows when the data register is read. In the 'ADC_DR (OVRMOD=0)' row, the data sequence is D0, D1, D2, D0, where the second D0 is maintained despite a new conversion (CH1) starting because the previous D0 was not read (indicated by the OVERRUN label). In the 'ADC_DR (OVRMOD=1)' row, the data sequence is D0, D1, D2, D0, D1, D2, where the data is overwritten by subsequent conversions. A legend at the bottom left defines the trigger types: 'by S/W' (software trigger indicated by an upward arrow), 'by H/W' (hardware trigger indicated by a filled upward arrow), and 'triggered' (indicated by a step pulse).

Timing diagram showing ADC signals (ADSTART, EOC, EOS, OVR, ADSTP, TRGx) and data states (RDY, CH0, CH1, CH2, STOP) over time. It illustrates an overrun condition where a new conversion starts before the previous data is read. Two scenarios for OVRMOD=0 and OVRMOD=1 are shown for the ADC_DR register values.

MSV30343V3

14.6.3 Managing a sequence of data converted without using the DMA

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

14.6.4 Managing converted data without using the DMA without overrun

It may be useful to let the ADC convert one or more channels without reading the data after each conversion. In this case, the OVRMOD bit must be configured at 1 and the OVR flag should be ignored by the software. When OVRMOD = 1, an overrun event does not prevent the ADC from continuing to convert and the ADC_DR register always contains the latest conversion data.

14.6.5 Managing converted data using the DMA

Since all converted channel values are stored in a single data register, it is efficient to use DMA when converting more than one channel. This avoids losing the conversion data results stored in the ADC_DR register.

When DMA mode is enabled (DMAEN bit set in the ADC_CFGR1 register), a DMA request is generated after the conversion of each channel. This allows the transfer of the converted data from the ADC_DR register to the destination location selected by the software.

Note: The DMAEN bit in the ADC_CFGR1 register must be set after the ADC calibration phase.

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 14.6.2: ADC overrun (OVR, OVRMOD) on page 349 ).

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 in the ADC_CFGR1 register:

DMA one shot mode (DMACFG = 0)

In this mode, the ADC generates a DMA transfer request each time a new conversion data word is available and stops generating DMA requests once the DMA has reached the last DMA transfer (when a transfer complete interrupt occurs, see Section 9: Direct memory access controller (DMA) on page 265 ) 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 word is available in the data register, even if the DMA has reached the last DMA transfer. This allows the DMA to be configured in circular mode to handle a continuous analog input data stream.

14.7 Low-power features

14.7.1 Wait mode conversion

Wait mode conversion can be used to simplify the software as well as optimizing the performance of applications clocked at low frequency where there might be a risk of ADC overrun occurring.

When the WAIT bit is set in the ADC_CFGR1 register, a new conversion can start only if the previous data has been treated, once the ADC_DR register has been read or if the EOC bit has been cleared.

This is a way to automatically adapt the speed of the ADC to the speed of the system that reads the data.

Note: Any hardware triggers which occur while a conversion is ongoing or during the wait time preceding the read access are ignored.

Figure 46. Wait mode conversion (continuous mode, software trigger) Timing diagram for Figure 46 showing ADC signals over time. The diagram includes ADSTART, EOC, EOS, ADSTP, ADC_DR Read access, ADC state, and ADC_DR. It shows a sequence of conversions for CH1, CH2, and CH3, with delays (DLY) between them, triggered by software and stopped by hardware. upward arrow symbol for software trigger downward arrow symbol for hardware trigger

The diagram illustrates the timing of an ADC in continuous mode with a software trigger. The signals shown are:

Legend:
by S/W by H/W

MSv30344V2

Timing diagram for Figure 46 showing ADC signals over time. The diagram includes ADSTART, EOC, EOS, ADSTP, ADC_DR Read access, ADC state, and ADC_DR. It shows a sequence of conversions for CH1, CH2, and CH3, with delays (DLY) between them, triggered by software and stopped by hardware. upward arrow symbol for software trigger downward arrow symbol for hardware trigger
  1. 1. EXTEN = 00, CONT = 1
  2. 2. CHSEL = 0x3, SCANDIR = 0, WAIT = 1, AUTOFF = 0

14.7.2 Auto-off mode (AUTOFF)

The ADC has an automatic power management feature which is called auto-off mode, and is enabled by setting AUTOFF = 1 in the ADC_CFGR1 register.

When AUTOFF = 1 , the ADC is always powered off when not converting and automatically wakes-up when a conversion is started (by software or hardware trigger). A startup-time is automatically inserted between the trigger event which starts the conversion and the sampling time of the ADC. The ADC is then automatically disabled once the sequence of conversions is complete.

Auto-off mode can cause a dramatic reduction in the power consumption of applications which need relatively few conversions or when conversion requests are timed far enough apart (for example with a low frequency hardware trigger) to justify the extra power and extra time used for switching the ADC on and off.

Auto-off mode can be combined with the wait mode conversion (WAIT = 1) for applications clocked at low frequency. This combination can provide significant power savings if the ADC is automatically powered-off during the wait phase and restarted as soon as the ADC_DR register is read by the application (see Figure 48: Behavior with WAIT = 1, AUTOFF = 1 ).

Figure 47. Behavior with WAIT = 0, AUTOFF = 1

Timing diagram for Figure 47 showing ADC behavior with WAIT = 0, AUTOFF = 1. The diagram includes signals TRGx, EOC, EOS, ADC_DR Read access, ADC state, and ADC_DR. TRGx is triggered by software (S/W) and hardware (H/W). EOC pulses occur for each channel conversion. EOS goes high after the last channel (CH4) and returns low when the ADC_DR register is read. The ADC state transitions from RDY to Startup, then through CH1, CH2, CH3, and CH4, then to OFF, and back to Startup when the register is read. Data D1, D2, D3, and D4 are shown in the ADC_DR register.

Legend: by S/W (software triggered), by H/W (hardware triggered), triggered (rising edge).

MSv30345V2

Timing diagram for Figure 47 showing ADC behavior with WAIT = 0, AUTOFF = 1. The diagram includes signals TRGx, EOC, EOS, ADC_DR Read access, ADC state, and ADC_DR. TRGx is triggered by software (S/W) and hardware (H/W). EOC pulses occur for each channel conversion. EOS goes high after the last channel (CH4) and returns low when the ADC_DR register is read. The ADC state transitions from RDY to Startup, then through CH1, CH2, CH3, and CH4, then to OFF, and back to Startup when the register is read. Data D1, D2, D3, and D4 are shown in the ADC_DR register.
  1. 1. EXTSEL = TRGx, EXTEN = 01 (rising edge), CONT = x, ADSTART = 1, CHSEL = 0xF, SCANDIR = 0, WAIT = 1, AUTOFF = 1

Figure 48. Behavior with WAIT = 1, AUTOFF = 1

Timing diagram for Figure 48 showing ADC behavior with WAIT = 1, AUTOFF = 1. The diagram includes signals TRGx, EOC, EOS, ADC_DR Read access, ADC state, and ADC_DR. TRGx is triggered by software (S/W) and hardware (H/W). EOC pulses occur for each channel conversion. EOS goes high after the last channel (CH3) and returns low when the ADC_DR register is read. The ADC state transitions from RDY to Startup, then through CH1, OFF, Startup, CH2, OFF, Startup, CH3, OFF, Startup, CH1, CH2. Data D1, D2, D3, and D4 are shown in the ADC_DR register. A 'DLY' (delay) is indicated between the EOC pulse and the state transition to OFF.

Legend: by S/W (software triggered), by H/W (hardware triggered), triggered (rising edge).

MSv30346V2

Timing diagram for Figure 48 showing ADC behavior with WAIT = 1, AUTOFF = 1. The diagram includes signals TRGx, EOC, EOS, ADC_DR Read access, ADC state, and ADC_DR. TRGx is triggered by software (S/W) and hardware (H/W). EOC pulses occur for each channel conversion. EOS goes high after the last channel (CH3) and returns low when the ADC_DR register is read. The ADC state transitions from RDY to Startup, then through CH1, OFF, Startup, CH2, OFF, Startup, CH3, OFF, Startup, CH1, CH2. Data D1, D2, D3, and D4 are shown in the ADC_DR register. A 'DLY' (delay) is indicated between the EOC pulse and the state transition to OFF.
  1. 1. EXTSEL = TRGx, EXTEN = 01 (rising edge), CONT = x, ADSTART = 1, CHSEL = 0xF, SCANDIR = 0, WAIT = 1, AUTOFF = 1

14.8 Analog window watchdogs

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

14.8.1 Description of analog watchdog 1

AWD1 analog watchdog is enabled by setting the AWD1EN bit in the ADC_CFGR1 register. It is used to monitor that either one selected channel or all enabled channels (see Table 73: Analog watchdog 1 channel selection ) remain within a configured voltage range (window) as shown in Figure 49 .

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 HT1[11:0] and LT1[11:0] bits of ADC_AWD1TR register. An interrupt can be enabled by setting the AWD1IE bit in the ADC_IER register.

The AWD1 flag is cleared by software by programming it to 1.

When converting data with a resolution of less than 12-bit (according to bits DRES[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 72 describes how the comparison is performed for all the possible resolutions.

Table 72. Analog watchdog comparison

Resolution bits RES[1:0]Analog Watchdog comparison between:Comments
Raw converted data, left aligned (1)Thresholds
00: 12-bitDATA[11:0]LTx[11:0] and HTx[11:0]-
01: 10-bitDATA[11:2],00LTx[11:0] and HTx[11:0]The user must configure LTx[1:0] and HTx[1:0] to “00”
10: 8-bitDATA[11:4],0000LTx[11:0] and HTx[11:0]The user must configure LTx[3:0] and HTx[3:0] to “0000”
11: 6-bitDATA[11:6],000000LTx[11:0] and HTx[11:0]The user must configure LTx[5:0] and HTx[5:0] to “000000”

1. The watchdog comparison is performed on the raw converted data before any alignment calculation.

Table 73 shows how to configure the AWD1SGL and AWD1EN bits in the ADC_CFGR1 register to enable the analog watchdog on one or more channels.

Figure 49. Analog watchdog guarded area

Figure 49: Analog watchdog guarded area diagram. A vertical axis represents 'Analog voltage'. Two horizontal lines represent the 'Higher threshold' (HTx) and 'Lower threshold' (LTx). The region between these two thresholds is shaded and labeled 'Guarded area'. The diagram shows that the guarded area is the range between HTx and LTx.

The diagram illustrates the 'Guarded area' for an analog watchdog. A vertical axis represents 'Analog voltage'. Two horizontal lines represent the 'Higher threshold' (HTx) and the 'Lower threshold' (LTx). The region between these two thresholds is shaded and labeled 'Guarded area'. The diagram shows that the guarded area is the range between HTx and LTx.

Figure 49: Analog watchdog guarded area diagram. A vertical axis represents 'Analog voltage'. Two horizontal lines represent the 'Higher threshold' (HTx) and 'Lower threshold' (LTx). The region between these two thresholds is shaded and labeled 'Guarded area'. The diagram shows that the guarded area is the range between HTx and LTx.
Table 73. Analog watchdog 1 channel selection
Channels guarded by the analog watchdogAWD1SGL bitAWD1EN bit
Nonex0
All channels01
Single (1) channel11

1. Selected by the AWD1CH[4:0] bits

14.8.2 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 AWDxCHy in ADC_AWDxCR (x = 2, 3).

The corresponding watchdog is enabled when any AWDxCHy bit (x = 2,3) is set in ADC_AWDxCR register.

When converting data with a resolution of less than 12 bits (configured through DRES[1:0] bits), 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 72 describes how the comparison is performed for all the possible resolutions.

The AWD2/3 analog watchdog status bit is set if the analog voltage converted by the ADC is below a low threshold or above a high threshold. These thresholds are programmed in HTx[11:0] and LTx[11:0] of ADC_AWDxTR registers (x = 2 or 3). An interrupt can be enabled by setting the AWDxIE bit in the ADC_IER register.

The AWD2 and ADW3 flags are cleared by software by programming them to 1.

14.8.3 ADC_AWDx_OUT output signal generation

Each analog watchdog is associated to an internal hardware signal, ADC_AWDx_OUT (x being the watchdog number) that is directly connected to the ETR input (external trigger) of some on-chip timers (refer to the timers section for details on how to select the ADC_AWDx_OUT signal as ETR).

ADC_AWDx_OUT is activated when the associated analog watchdog is enabled:

AWDx flag is set by hardware and reset by software: AWDx flag has no influence on the generation of ADC_AWDx_OUT (as an example, ADC_AWDx_OUT can toggle while AWDx flag remains at 1 if the software has not cleared the flag).

The ADC_AWDx_OUT signal is generated by the f ADC clock domain. This signal can be generated even the APB clock is stopped.

The AWD comparison is performed at the end of each ADC conversion. The ADC_AWDx_OUT rising edge and falling edge occurs two \( f_{ADC} \) clock cycles after the comparison.

As ADC_AWDx_OUT is generated by the \( f_{ADC} \) clock domain and AWD flag is generated by the APB clock domain, the rising edges of these signals are not synchronized.

Figure 50. ADC_AWDx_OUT signal generation

Timing diagram for Figure 50 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADC_AWDx_OUT signals over seven conversions. The AWDx FLAG is cleared by software for conversions 3, 4, 5, and 6.

This timing diagram illustrates the relationship between the ADC STATE, EOC FLAG, AWDx FLAG, and ADC_AWDx_OUT signals during a sequence of seven conversions. The ADC STATE starts in the RDY state and transitions through Conversion1 to Conversion7. Below each conversion state, it is marked as either 'inside' or 'outside' the watchdog threshold. The EOC FLAG pulses high at the end of each conversion. The AWDx FLAG is set high when a conversion is 'outside' (Conversion2, Conversion4, Conversion5, Conversion6) and is cleared by software (marked 'Cleared by SW') shortly after being set. The ADC_AWDx_OUT signal goes high when a conversion is 'outside' and low when it is 'inside', with a delay of two \( f_{ADC} \) cycles. A legend box indicates: Converted channels: 1,2,3,4,5,6,7; Guarded converted channels: 1,2,3,4,5,6,7. The diagram is labeled MSv45362V1.

Timing diagram for Figure 50 showing ADC STATE, EOC FLAG, AWDx FLAG, and ADC_AWDx_OUT signals over seven conversions. The AWDx FLAG is cleared by software for conversions 3, 4, 5, and 6.

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

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

This timing diagram shows the signal generation when the AWDx FLAG is not cleared by software. The sequence of conversions (1-7) and their 'inside'/'outside' status are identical to Figure 50. However, once the AWDx FLAG is set high by Conversion2 (the first 'outside' result), it remains high for the remainder of the sequence (marked 'not cleared by SW'). The ADC_AWDx_OUT signal still transitions based on the individual conversion results (high for 'outside', low for 'inside') regardless of the state of the AWDx FLAG. A legend box indicates: Converted channels: 1,2,3,4,5,6,7; Guarded converted channels: 1,2,3,4,5,6,7. The diagram is labeled MSv45363V1.

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

Figure 52. ADC_AWDx_OUT signal generation (on a single channel)

Timing diagram for ADC_AWDx_OUT signal generation. It shows four signals over time: ADC STATE (Conversions 1 and 2), EOC FLAG, EOS FLAG, and AWDx FLAG. The ADC_AWDx_OUT signal is shown as being asserted when a conversion is 'outside' the threshold and deasserted when 'inside'. The EOS FLAG is cleared by software. A legend indicates: - Converted channels: 1 and 2, - Only channel 1 is guarded. MSV45364V2
Timing diagram for ADC_AWDx_OUT signal generation. It shows four signals over time: ADC STATE (Conversions 1 and 2), EOC FLAG, EOS FLAG, and AWDx FLAG. The ADC_AWDx_OUT signal is shown as being asserted when a conversion is 'outside' the threshold and deasserted when 'inside'. The EOS FLAG is cleared by software. A legend indicates: - Converted channels: 1 and 2, - Only channel 1 is guarded. MSV45364V2

14.8.4 Analog watchdog threshold control

LTx[11:0] and HTx[11:0] can be changed during an analog-to-digital conversion (that is between the start of the conversion and the end of conversion of the ADC internal state). If HTx and LTx bits are programmed during the ADC guarded channel conversion, the watchdog function is masked for this conversion. This mask is cleared when starting a new conversion, and the resulting new AWD threshold is applied starting the next ADC conversion result. AWD comparison is performed at each end of conversion. If the current ADC data are out of the new threshold interval, this does not generate any interrupt or an ADC_AWDx_OUT signal. The Interrupt and the ADC_AWDx_OUT generation only occurs at the end of the ADC conversion that started after the threshold update. If ADC_AWDx_OUT is already asserted, programming the new threshold does not deactivate the ADC_AWDx_OUT signal.

Figure 53. Analog watchdog threshold update

Timing diagram for analog watchdog threshold update. It shows the ADC state with four conversions. The threshold (LTx, HTx) is updated between the second and third conversions. The comparison status is shown as Active, Masked, and Active. MSV45365V1
Timing diagram for analog watchdog threshold update. It shows the ADC state with four conversions. The threshold (LTx, HTx) is updated between the second and third conversions. The comparison status is shown as Active, Masked, and Active. MSV45365V1

14.9 Oversampler

The oversampling unit performs data preprocessing to offload the CPU. It can handle multiple conversions and average them into a single data with increased data width, up to 16-bit.

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

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

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

The oversampling ratio N is defined using the OVSR[2:0] bits in the ADC_CFGR2 register. It can range from 2x to 256x. The division coefficient M consists of a right bit shift up to 8 bits. It is configured through the OVSS[3:0] bits in the ADC_CFGR2 register.

The summation unit can yield a result up to 20 bits (256 x 12-bit), which is first shifted right. The upper bits of the result are then truncated, keeping only the 16 least significant bits rounded to the nearest value using the least significant bits left apart by the shifting, before being finally transferred into the ADC_DR data register.

Note: If the intermediate result after the shifting exceeds 16 bits, the upper bits of the result are simply truncated.

Figure 54. 20-bit to 16-bit result truncation

Diagram illustrating the 20-bit to 16-bit result truncation process. It shows three rows: 'Raw 20-bit data' (bits 19 to 0), 'Shifting' (indicated by a right arrow), and 'Truncation and rounding' (bits 15 to 0). The raw data is shifted right by 4 bits, and the resulting 16 least significant bits are truncated and rounded.

The diagram shows the truncation process. The 'Raw 20-bit data' row has bit positions 19, 15, 11, 7, 3, and 0 marked. An arrow labeled 'Shifting' points to the right, indicating a right shift. The 'Truncation and rounding' row shows the final 16-bit result with bit positions 15 and 0 marked. The raw data is shifted right by 4 bits, and the upper 4 bits are truncated, keeping the 16 least significant bits.

Diagram illustrating the 20-bit to 16-bit result truncation process. It shows three rows: 'Raw 20-bit data' (bits 19 to 0), 'Shifting' (indicated by a right arrow), and 'Truncation and rounding' (bits 15 to 0). The raw data is shifted right by 4 bits, and the resulting 16 least significant bits are truncated and rounded.

Figure 55 gives a numerical example of the processing, from a raw 20-bit accumulated data to the final 16-bit result.

Figure 55. Numerical example with 5-bits shift and rounding

Numerical example of the processing with a 5-bit shift and rounding. It shows two rows of data: 'Raw 20-bit data' and 'Final result after 5-bits shift and rounding to nearest'. The raw data is shifted right by 5 bits, and the resulting 16 least significant bits are rounded to the nearest value.

The diagram shows a numerical example. The 'Raw 20-bit data' row has bit positions 19, 15, 11, 7, 3, and 0 marked, with values 3, B, 7, D, and 7 respectively. The 'Final result after 5-bits shift and rounding to nearest' row has bit positions 15 and 0 marked, with values 1, D, B, and F respectively. The raw data is shifted right by 5 bits, and the resulting 16 least significant bits are rounded to the nearest value.

Numerical example of the processing with a 5-bit shift and rounding. It shows two rows of data: 'Raw 20-bit data' and 'Final result after 5-bits shift and rounding to nearest'. The raw data is shifted right by 5 bits, and the resulting 16 least significant bits are rounded to the nearest value.

Table 74 gives the data format for the various N and M combination, for a raw conversion data equal to 0xFFF.

Table 74. Maximum output results vs N and M. Grayed values indicates truncation

Oversampling ratioMax Raw dataNo-shift OVSS = 00001-bit shift OVSS = 00012-bit shift OVSS = 00103-bit shift OVSS = 00114-bit shift OVSS = 01005-bit shift OVSS = 01016-bit shift OVSS = 01107-bit shift OVSS = 01118-bit shift OVSS = 1000
2x0x1FFE0x1FFE0x0FFF0x08000x04000x02000x01000x00800x00400x0020
4x0x3FFC0x3FFC0x1FFE0x0FFF0x08000x04000x02000x01000x00800x0040
8x0x7FF80x7FF80x3FFC0x1FFE0x0FFF0x08000x04000x02000x01000x0080
16x0xFFF00xFFF00x7FF80x3FFC0x1FFE0x0FFF0x08000x04000x02000x0100
32x0x1FFE00xFFE00xFFF00x7FF80x3FFC0x1FFE0x0FFF0x08000x04000x0200
64x0x3FFC00xFFC00xFFE00xFFF00x7FF80x3FFC0x1FFE0x0FFF0x08000x0400
128x0x7FF800xFF800xFFC00xFFE00xFFF00x7FF80x3FFC0x1FFE0x0FFF0x0800
256x0xFFF000xFF000xFF800xFFC00xFFE00xFFF00x7FF80x3FFC0x1FFE0x0FFF

The conversion timings in oversampled mode do not change compared to standard conversion mode: the sample time is maintained equal during the whole oversampling sequence. New data are provided every N conversion, with an equivalent delay equal to \( N \times t_{CONV} = N \times (t_{SAMPL} + t_{SAR}) \) . The flags features are raised as following:

14.9.1 ADC operating modes supported when oversampling

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

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

14.9.2 Analog watchdog

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

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

14.9.3 Triggered mode

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

Figure 56 below shows how conversions are started in response to triggers in discontinuous mode.

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

Figure 56. Triggered oversampling mode (TOVS bit = 1)

Diagram of Triggered oversampling mode. Top part shows TOVS=0 where one trigger starts a burst of 4 conversions (Ch(N) 0, 1, 2, 3) followed by an EOC flag. Bottom part shows TOVS=1 where each individual conversion (Ch(N) 0, 1, 2, 3, then 0, 1, 2...) is started by its own trigger. EOC flag is set after the full oversampling ratio is reached (after 4 conversions).
CONT = 0
(DISCEN = 1)*
TOVS = 0
CONT = 0
(DISCEN = 1)*
TOVS = 1
(DISCEN = 1)*: DISCEN bit is forced to 1 by software when TOVS bit is set
MS33700V1
Diagram of Triggered oversampling mode. Top part shows TOVS=0 where one trigger starts a burst of 4 conversions (Ch(N) 0, 1, 2, 3) followed by an EOC flag. Bottom part shows TOVS=1 where each individual conversion (Ch(N) 0, 1, 2, 3, then 0, 1, 2...) is started by its own trigger. EOC flag is set after the full oversampling ratio is reached (after 4 conversions).

14.10 Temperature sensor and internal reference voltage

The temperature sensor can be used to measure the junction temperature ( \( T_J \) ) of the device. The temperature sensor is internally connected to the ADC \( V_{IN}[11] \) input channel which is used to convert the sensor's output voltage to a digital value. The sampling time for the temperature sensor analog pin must be greater than the minimum \( T_{S\_temp} \) value specified in the datasheet. When not in use, the sensor can be put in power down mode.

The internal voltage reference ( \( V_{REFINT} \) ) provides a stable (bandgap) voltage output for the ADC. \( V_{REFINT} \) is internally connected to the ADC \( V_{IN}[12] \) input channel. The precise voltage of \( V_{REFINT} \) is individually measured for each part by ST during production test and stored in the system memory area.

Figure 57 shows the block diagram of connections between the temperature sensor, the internal voltage reference and the ADC.

The TSEN bit must be set to enable the conversion of ADC \( V_{IN}[11] \) (temperature sensor) and the VREFEN bit must be set to enable the conversion of ADC \( V_{IN}[12] \) ( \( V_{REFINT} \) ).

Note: Before entering any Stop mode, the temperature sensor and the internal reference voltage must be disabled by clearing TSEN and VREFEN, respectively.

Figure 57. Temperature sensor and \( V_{REFINT} \) channel block diagram

Block diagram showing the connections between a Temperature sensor, an Internal power block, and an ADC. The Temperature sensor output is connected to an operational amplifier (op-amp) whose non-inverting input is controlled by the TSEN bit. The op-amp output is labeled V_SENSE and is connected to the ADC V_IN[11] input. The Internal power block output is connected to another op-amp whose non-inverting input is controlled by the VREFEN bit. The op-amp output is labeled V_REFINT and is connected to the ADC V_IN[12] input. The ADC block has a 'converted data' output connected to an 'Address/data bus'. The diagram is labeled MSV71290V1 in the bottom right corner.
Block diagram showing the connections between a Temperature sensor, an Internal power block, and an ADC. The Temperature sensor output is connected to an operational amplifier (op-amp) whose non-inverting input is controlled by the TSEN bit. The op-amp output is labeled V_SENSE and is connected to the ADC V_IN[11] input. The Internal power block output is connected to another op-amp whose non-inverting input is controlled by the VREFEN bit. The op-amp output is labeled V_REFINT and is connected to the ADC V_IN[12] input. The ADC block has a 'converted data' output connected to an 'Address/data bus'. The diagram is labeled MSV71290V1 in the bottom right corner.

Reading the temperature

  1. 1. Select the ADC \( V_{IN}[11] \) input channel.
  2. 2. Select an appropriate sampling time specified in the device datasheet ( \( T_{S\_temp} \) ).
  3. 3. Set the TSEN bit in the ADC_CCR register to wake up the temperature sensor from power down mode and wait for its stabilization time ( \( t_{START} \) ).
  4. 4. Start the ADC conversion by setting the ADSTART bit in the ADC_CR register (or by external trigger).
  5. 5. Read the resulting \( V_{SENSE} \) data in the ADC_DR register.
  6. 6. Calculate the temperature using the following formula

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

Where:

Note: The sensor has a startup time after waking from power down mode before it can output V SENSE 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.

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

V REF+ voltage may be subject to variation or not precisely known. The embedded internal reference voltage (V REFINT ) and its calibration data acquired by the ADC during the manufacturing process at V REF+_charac can be used to evaluate the actual V REF+ voltage level.

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

\[ V_{REF+} = V_{REF+\_Charac} \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 REF+ . For applications where V REF+ is known and ADC converted values are right-aligned you can use the following formula to get this absolute value:

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

For applications where V REF+ value is not known, you must use the internal voltage reference and V REF+ can be replaced by the expression provided in Calculating the actual V REF+ voltage using the internal reference voltage , resulting in the following formula:

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

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.

14.11 Battery voltage monitoring

The VBATEN bit in the ADC_CCR register allows the application to measure the backup battery voltage on the VBAT pin. As the \( V_{BAT} \) voltage can be higher than \( V_{REF+} \) , to ensure the correct operation of the ADC, the VBAT pin is internally connected to a bridge divider. This bridge is automatically enabled when VBATEN is set, to connect \( V_{BAT} \) to the ADC \( V_{IN}[13] \) input channel. As a consequence, the converted digital value is \( V_{BAT}/3 \) . To prevent any unwanted consumption on the battery, it is recommended to enable the bridge divider only when needed for ADC conversion.

14.12 ADC interrupts

An interrupt can be generated by any of the following events:

Separate interrupt enable bits are available for flexibility.

Table 75. ADC interrupts

Interrupt eventEvent flagEnable control bit
End Of CalibrationEOCALEOCALIE
ADC readyADRDYADRDYIE
End of conversionEOCEOCIE
End of sequence of conversionsEOSEOSIE
Analog watchdog 1 status bit is setAWD1AWD1IE
Analog watchdog 2 status bit is setAWD2AWD2IE

Table 75. ADC interrupts (continued)

Interrupt eventEvent flagEnable control bit
Analog watchdog 3 status bit is setAWD3AWD3IE
Channel Configuration ReadyCCRDYCCRDYIE
End of sampling phaseEOSMPEOSMPIE
OverrunOVROVRIE

14.13 ADC registers

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

14.13.1 ADC interrupt and status register (ADC_ISR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.CCRDYRes.EOCALRes.AWD3AWD2AWD1Res.Res.OVREOSEOCEOSMPADRDY
rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1

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

Bit 13 CCRDY : Channel Configuration Ready flag

This flag bit is set by hardware when the channel configuration is applied after programming to ADC_CHSELR register or changing CHSELRMOD or SCANDIR. It is cleared by software by programming it to it.

0: Channel configuration update not applied.

1: Channel configuration update is applied.

Note: When the software configures the channels (by programming ADC_CHSELR or changing CHSELRMOD or SCANDIR), it must wait until the CCRDY flag rises before configuring again or starting conversions, otherwise the new configuration (or the START bit) is ignored. Once the flag is asserted, if the software needs to configure again the channels, it must clear the CCRDY flag before proceeding with a new configuration.

Bit 12 Reserved, must be kept at reset value.

Bit 11 EOCAL : End Of Calibration flag

This bit is set by hardware when calibration is complete. It is cleared by software writing 1 to it.

0: Calibration is not complete

1: Calibration is complete

Bit 10 Reserved, must be kept at reset value.

Bit 9 AWD3 : Analog watchdog 3 flag

This bit is set by hardware when the converted voltage crosses the values programmed in ADC_AWD3TR and ADC_AWD3TR registers. It is cleared by software by programming it to 1.

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

1: Analog watchdog event occurred

Bit 8 AWD2 : Analog watchdog 2 flag

This bit is set by hardware when the converted voltage crosses the values programmed in ADC_AWD2TR and ADC_AWD2TR registers. It is cleared by software programming it to 1.

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

1: Analog watchdog event occurred

Bit 7 AWD1: Analog watchdog 1 flag

This bit is set by hardware when the converted voltage crosses the values programmed in ADC_TR1 and ADC_HR1 registers. It is cleared by software by programming it to 1.

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

1: Analog watchdog event occurred

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

Bit 4 OVR: ADC overrun

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

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

1: Overrun has occurred

Bit 3 EOS: End of sequence flag

This bit is set by hardware at the end of the conversion of a sequence of channels selected by the CHSEL bits. It is cleared by software writing 1 to it.

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

1: Conversion sequence complete

Bit 2 EOC: End of conversion flag

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

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

1: Channel conversion complete

Bit 1 EOSMP: End of sampling flag

This bit is set by hardware during the conversion, at the end of the sampling phase. It is cleared by software by programming it to '1'.

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

1: End of sampling phase reached

Bit 0 ADRDY: ADC ready

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

It is cleared by software writing 1 to it.

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

1: ADC is ready to start conversion

14.13.2 ADC interrupt enable register (ADC_IER)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.CCRDYIERes.EOCALIERes.AWD3IEAWD2IEAWD1IERes.Res.OVRIEEOSIEEOCIEEOSMPIEADRDYIE
rwrwrwrwrwrwrwrwrwrw

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

Bit 13 CCRDYIE : Channel Configuration Ready Interrupt enable

This bit is set and cleared by software to enable/disable the channel configuration ready interrupt.

0: Channel configuration ready interrupt disabled

1: Channel configuration ready interrupt enabled

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

Bit 12 Reserved, must be kept at reset value.

Bit 11 EOCALIE : End of calibration interrupt enable

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

0: End of calibration interrupt disabled

1: End of calibration interrupt enabled

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

Bit 10 Reserved, must be kept at reset value.

Bit 9 AWD3IE : Analog watchdog 3 interrupt enable

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

0: Analog watchdog interrupt disabled

1: Analog watchdog interrupt enabled

Note: The Software is allowed to write this bit only when ADSTART bit is cleared (this 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 interrupt.

0: Analog watchdog interrupt disabled

1: Analog watchdog interrupt enabled

Note: The Software is allowed to write this bit only when ADSTART bit is cleared (this 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 interrupt.

0: Analog watchdog interrupt disabled

1: Analog watchdog interrupt enabled

Note: The Software is allowed to write this bit only when ADSTART bit is cleared (this ensures that no conversion is ongoing).

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

Bit 4 OVRIE : Overrun interrupt enable

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

0: Overrun interrupt disabled

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

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

Bit 3 EOSIE : End of conversion sequence interrupt enable

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

0: EOS interrupt disabled

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

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

Bit 2 EOCIE : End of conversion interrupt enable

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

0: EOC interrupt disabled

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

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

Bit 1 EOSMPIE : End of sampling flag interrupt enable

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

0: EOSMP interrupt disabled.

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

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

Bit 0 ADDRYIE : 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: The software is allowed to write this bit only when ADSTART bit is cleared (this ensures that no conversion is ongoing).

14.13.3 ADC control register (ADC_CR)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
ADCALRes.Res.ADVREGENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rsnw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ADSTPRes.ADSTARTADDISADEN
rsrsrsrs
Bit 31 ADCAL : ADC calibration

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

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 is in progress.

Note: The software is allowed to set ADCAL only when the ADC is disabled (ADCAL = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0, AUTOFF = 0, and ADEN = 0).

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

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

Bit 28 ADVREGEN : ADC Voltage Regulator Enable

This bit is set by software, to enable the ADC internal voltage regulator. The voltage regulator output is available after \( t_{ADCVREG\_STUP} \) .

It is cleared by software to disable the voltage regulator. It can be cleared only if ADEN is cleared.

0: ADC voltage regulator disabled

1: ADC voltage regulator enabled

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

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

Bit 4 ADSTP : ADC stop conversion command

This bit is set by software to stop and discard an ongoing conversion (ADSTP Command).

It is cleared by hardware when the conversion is effectively discarded and the ADC is ready to accept a new start conversion command.

0: No ADC stop conversion command ongoing

1: Write 1 to stop the ADC. Read 1 means that an ADSTP command is in progress.

Note: Setting ADSTP to '1' is only effective when ADSTART = 1 and ADDIS = 0 (ADC is enabled and may be converting and there is no pending request to disable the ADC)

Bit 3 Reserved, must be kept at reset value.

Bit 2 ADSTART : ADC start conversion command

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

It is cleared by hardware:

0: No ADC conversion is ongoing.

1: Write 1 to start the ADC. Read 1 means that the ADC is operating and may be converting.

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

After writing to ADC_CHSELR register or changing CHSELRMOD or SCANDIRW, it is mandatory to wait until CCRDY flag is asserted before setting ADSTART, otherwise, the value written to ADSTART is ignored.

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: Setting ADDIS to '1' is only effective when ADEN = 1 and ADSTART = 0 (which ensures that no conversion is ongoing)

Bit 0 ADEN : ADC enable command

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

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

0: ADC is disabled (OFF state)

1: Write 1 to enable the ADC.

Note: The software is allowed to set ADEN only when ADCAL = 0, ADSTP = 0, ADSTART = 0, ADDIS = 0, ADEN = 0, and ADVREGEN = 1.

14.13.4 ADC configuration register 1 (ADC_CFGR1)

Address offset: 0x0C

Reset value: 0x0000 0000

The software is allowed to program ADC_CFGR1 only when ADEN is cleared in ADC_CR.

31302928272625242322212019181716
Res.AWD1CH[4:0]Res.Res.AWD1ENAWD1GLCHSEL
RMOD
Res.Res.Res.Res.DISCE
N
rwrwrwrwrwrwrwrwrw
1514131211109876543210
AUTOF
F
WAITCONTOVRM
OD
EXTEN[1:0]Res.EXTSEL[2:0]ALIGNRES[1:0]SCAND
IR
DMAC
FG
DMAE
N
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 Reserved, must be kept at reset value.

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

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

00000: ADC analog input Channel 0 monitored by AWD

00001: ADC analog input Channel 1 monitored by AWD

.....

10011: ADC analog input Channel 19 monitored by AWD

Others: Reserved

Note: The channel selected by the AWDCH[4:0] bits must be also set into the CHSELR register.

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

Bit 23 AWD1EN : Analog watchdog enable

This bit is set and cleared by software.

0: Analog watchdog 1 disabled

1: Analog watchdog 1 enabled

Bit 22 AWD1SGL : Enable the watchdog 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 AWDCH[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

Bit 21 CHSELRMOD : Mode selection of the ADC_CHSELR register

This bit is set and cleared by software to control the ADC_CHSELR feature:

0: Each bit of the ADC_CHSELR register enables an input

1: ADC_CHSELR register is able to sequence up to 8 channels

Note: If CCRDY is not yet asserted after channel configuration (writing ADC_CHSELR register or changing CHSELRMOD or SCANDIR), the value written to this bit is ignored.

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

Bit 16 DISCEN : Discontinuous mode

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

0: Discontinuous mode disabled

1: Discontinuous mode enabled

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

Bit 15 AUTOFF : Auto-off mode

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

0: Auto-off mode disabled

1: Auto-off mode enabled

Bit 14 WAIT : Wait conversion mode

This bit is set and cleared by software to enable/disable wait conversion mode.

0: Wait conversion mode off

1: Wait conversion mode on

Bit 13 CONT : Single / continuous conversion mode

This bit is set and cleared by software. If it is set, 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 bits DISCEN = 1 and CONT = 1.

Bit 12 OVRMOD : Overrun management mode

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

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

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

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

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

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

01: Hardware trigger detection on the rising edge

10: Hardware trigger detection on the falling edge

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

Bit 9 Reserved, must be kept at reset value.

Bits 8:6 EXTSEL[2:0] : External trigger selection

These bits select the external event used to trigger the start of conversion (refer to Table 68: External triggers for details):

000: TRG0

001: TRG1

010: TRG2

011: TRG3

100: TRG4

101: TRG5

110: TRG6

111: TRG7

Bit 5 ALIGN : Data alignment

This bit is set and cleared by software to select right or left alignment. Refer to Figure 44: Data alignment and resolution (oversampling disabled: OVSE = 0) on page 349

0: Right alignment

1: Left alignment

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

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

00: 12 bits

01: 10 bits

10: 8 bits

11: 6 bits

Bit 2 SCANDIR : Scan sequence direction

This bit is set and cleared by software to select the direction in which the channels is scanned in the sequence. It is effective only if CHSELMOD bit is cleared.

0: Upward scan (from CHSEL0 to CHSEL)

1: Backward scan (from CHSEL to CHSEL0)

Note: If CCRDY is not yet asserted after channel configuration (writing ADC_CHSELR register or changing CHSELRMOD or SCANDIR), the value written to this bit is ignored.

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.

0: DMA one shot mode selected

1: DMA circular mode selected

For more details, refer to Section 14.6.5: Managing converted data using the DMA on page 351 .

Bit 0 DMAEN : Direct memory access enable

This bit is set and cleared by software to enable the generation of DMA requests. This allows the DMA controller to be used to manage automatically the converted data. For more details, refer to Section 14.6.5: Managing converted data using the DMA on page 351 .

0: DMA disabled

1: DMA enabled

14.13.5 ADC configuration register 2 (ADC_CFGR2)

Address offset: 0x10

Reset value: 0x0000 0000

The software is allowed to program ADC_CFGR2 only when ADEN is cleared in ADC_CR.

31302928272625242322212019181716
CKMODE[1:0]LFTRIGRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
rwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.TOVSOVSS[3:0]OVSR[2:0]Res.OVSE
rwrwrwrwrwrwrwrwrw

Bits 31:30 CKMODE[1:0] : ADC clock mode

These bits are set and cleared by software to define how the analog ADC is clocked:

00: ADCCLK (Asynchronous clock mode), generated at product level (refer to RCC section)

01: PCLK/2 (Synchronous clock mode)

10: PCLK/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: The software is allowed to write these bits only when the ADC is disabled (ADCAL = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

Bit 29 LFTRIG : Low frequency trigger mode enable

This bit is set and cleared by software.

0: Low Frequency Trigger Mode disabled

1: Low Frequency Trigger Mode enabled

Note: The software is allowed to write this bit only when ADEN bit is cleared.

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

Bit 9 TOVS : Triggered Oversampling

This bit is set and cleared by software.

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

1: Each oversampled conversion for a channel needs a trigger

Note: The software is allowed to write this bit only when ADEN bit is cleared.

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

This bit is set and cleared by software.

0000: No shift

0001: Shift 1-bit

0010: Shift 2-bits

0011: Shift 3-bits

0100: Shift 4-bits

0101: Shift 5-bits

0110: Shift 6-bits

0111: Shift 7-bits

1000: Shift 8-bits

Others: Reserved

Note: The software is allowed to write this bit only when ADEN bit is cleared.

Bits 4:2 OVSR[2:0] : Oversampling ratio

This bit field defines the number of oversampling ratio.

000: 2x

001: 4x

010: 8x

011: 16x

100: 32x

101: 64x

110: 128x

111: 256x

Starting from 32x, it is mandatory to use OVSS[3:0] to reduce the data size to less than 16 bits to fit to the ADC_DR register. For example, if OVSR[2:0] is configured to 32x, the data width is 17 bits, and OVSS[3:0] must be set to 1-bit shift.

Note: The software is allowed to write this bit only when ADEN bit is cleared.

Bit 1 Reserved, must be kept at reset value.

Bit 0 OVSE : Oversampler Enable

This bit is set and cleared by software.

0: Oversampler disabled

1: Oversampler enabled

Note: The software is allowed to write this bit only when ADEN bit is cleared.

14.13.6 ADC sampling time register (ADC_SMPR)

Address offset: 0x14

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.SMPSE L19SMPSE L18SMPSE L17SMPSE L16SMPSE L15SMPSE L14SMPSE L13SMPSE L12SMPSE L11SMPSE L10SMPSE L9SMPSE L8
rwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
SMPSE L7SMPSE L6SMPSE L5SMPSE L4SMPSE L3SMPSE L2SMPSE L1SMPSE L0Res.SMP2[2:0]Res.SMP1[2:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 27:8 SMPSELx : Channel-x sampling time selection (x = 19 to 0)

These bits are written by software to define which sampling time is used.

0: Sampling time of CHANNELx use the setting of SMP1[2:0] register.

1: Sampling time of CHANNELx use the setting of SMP2[2:0] register.

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

Bit 7 Reserved, must be kept at reset value.

Bits 6:4 SMP2[2:0] : Sampling time selection 2

These bits are written by software to select the sampling time that applies to all channels.

000: 1.5 ADC clock cycles

001: 3.5 ADC clock cycles

010: 7.5 ADC clock cycles

011: 12.5 ADC clock cycles

100: 19.5 ADC clock cycles

101: 39.5 ADC clock cycles

110: 79.5 ADC clock cycles

111: 160.5 ADC clock cycles

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

Bit 3 Reserved, must be kept at reset value.

Bits 2:0 SMP1[2:0] : Sampling time selection 1

These bits are written by software to select the sampling time that applies to all channels.

000: 1.5 ADC clock cycles

001: 3.5 ADC clock cycles

010: 7.5 ADC clock cycles

011: 12.5 ADC clock cycles

100: 19.5 ADC clock cycles

101: 39.5 ADC clock cycles

110: 79.5 ADC clock cycles

111: 160.5 ADC clock cycles

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

14.13.7 ADC watchdog threshold register (ADC_AWD1TR)

Address offset: 0x20

Reset value: 0x0FFF 0000

31302928272625242322212019181716
Res.Res.Res.Res.HT1[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw
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.

Refer to Section 14.8: Analog window watchdogs on page 355 .

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.

Refer to Section 14.8: Analog window watchdogs on page 355 .

14.13.8 ADC watchdog threshold register (ADC_AWD2TR)

Address offset: 0x24

Reset value: 0x0FFF 0000

31302928272625242322212019181716
Res.Res.Res.Res.HT2[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.LT2[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 27:16 HT2[11:0] : Analog watchdog 2 higher threshold

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

Refer to Section 14.8: Analog window watchdogs on page 355 .

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

Bits 11:0 LT2[11:0] : Analog watchdog 2 lower threshold

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

Refer to Section 14.8: Analog window watchdogs on page 355 .

14.13.9 ADC channel selection register (ADC_CHSELR)

Address offset: 0x28

Reset value: 0x0000 0000

The same register can be used in two different modes:

CHSELRMOD = 0 in ADC_CFGR1

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CHSEL 19CHSEL 18CHSEL 17CHSEL 16
rwrwrwrw
1514131211109876543210
CHSEL 15CHSEL 14CHSEL 13CHSEL 12CHSEL 11CHSEL 10CHSEL 9CHSEL 8CHSEL 7CHSEL 6CHSEL 5CHSEL 4CHSEL 3CHSEL 2CHSEL 1CHSEL 0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 19:0 CHSEL[19:0] : Channel-x selection

These bits are written by software and define which channels are part of the sequence of channels to be converted.

0: Input Channel-x is not selected for conversion

1: Input Channel-x is selected for conversion

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

If CCRDY is not yet asserted after channel configuration (writing ADC_CHSELR register or changing CHSELRMOD or SCANDIR), the value written to this bit is ignored.

14.13.10 ADC channel selection register [alternate] (ADC_CHSELR)

Address offset: 0x28

Reset value: 0x0000 0000

The same register can be used in two different modes:

CHSELRMOD = 1 in ADC_CFGR1:

31302928272625242322212019181716
SQ8[3:0]SQ7[3:0]SQ6[3:0]SQ5[3:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SQ4[3:0]SQ3[3:0]SQ2[3:0]SQ1[3:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Bits 31:28 SQ8[3:0]: 8th conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates the end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

0000: CH0

0001: CH1

...

1100: CH12

1101: CH13

1110: CH14

1111: No channel selected (End of sequence)

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

Bits 27:24 SQ7[3:0]: 7th conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

Bits 23:20 SQ6[3:0]: 6th conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

Bits 19:16 SQ5[3:0]: 5th conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

Bits 15:12 SQ4[3:0]: 4th conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

Bits 11:8 SQ3[3:0] : 3rd conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

Bits 7:4 SQ2[3:0] : 2nd conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

Bits 3:0 SQ1[3:0] : 1st conversion of the sequence

These bits are programmed by software with the channel number (0...14) assigned to the 8th conversion of the sequence. 0b1111 indicates end of the sequence.

When 0b1111 (end of sequence) is programmed to the lower sequence channels, these bits are ignored.

Refer to SQ8[3:0] for a definition of channel selection.

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

14.13.11 ADC watchdog threshold register (ADC_AWD3TR)

Address offset: 0x2C

Reset value: 0x0FFF 0000

31302928272625242322212019181716
Res.Res.Res.Res.HT3[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.LT3[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 27:16 HT3[11:0] : Analog watchdog 3 higher threshold

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

Refer to Section 14.8: Analog window watchdogs on page 355 .

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

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

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

Refer to Section 14.8: Analog window watchdogs on page 355 .

14.13.12 ADC data register (ADC_DR)

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
DATA[15:0]
rrrrrrrrrrrrrrrr

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

Bits 15:0 DATA[15:0] : Converted data

These bits are read-only. They contain the conversion result from the last converted channel. The data are left- or right-aligned as shown in Figure 44 .

Just after a calibration is complete, DATA[6:0] contains the calibration factor.

14.13.13 ADC analog watchdog 2 configuration register (ADC_AWD2CR)

Address offset: 0xA0

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD2
CH19
AWD2
CH18
AWD2
CH17
AWD2
CH16
rwrwrwrw
1514131211109876543210
AWD2
CH15
AWD2
CH14
AWD2
CH13
AWD2
CH12
AWD2
CH11
AWD2
CH10
AWD2
CH9
AWD2
CH8
AWD2
CH7
AWD2
CH6
AWD2
CH5
AWD2
CH4
AWD2
CH3
AWD2
CH2
AWD2
CH1
AWD2
CH0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 19:0 AWD2CH[19:0] : Analog watchdog channel selection

These bits are set and cleared by software. They enable and select the input channels to be guarded by analog watchdog 2 (AWD2).

0: ADC analog channel-x is not monitored by AWD2

1: ADC analog channel-x is monitored by AWD2

Note: The channels selected through ADC_AWD2CR must be also configured into the ADC_CHSELR registers. The software is allowed to write this bit only when ADEN = 0.

14.13.14 ADC Analog Watchdog 3 Configuration register (ADC_AWD3CR)

Address offset: 0xA4

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3CH19AWD3CH18AWD3CH17AWD3CH16
rwrwrwrw
1514131211109876543210
AWD3CH15AWD3CH14AWD3CH13AWD3CH12AWD3CH11AWD3CH10AWD3CH9AWD3CH8AWD3CH7AWD3CH6AWD3CH5AWD3CH4AWD3CH3AWD3CH2AWD3CH1AWD3CH0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 19:0 AWD3CH[19:0] : Analog watchdog channel selection

These bits are set and cleared by software. They enable and select the input channels to be guarded by analog watchdog 3 (AWD3).

0: ADC analog channel-x is not monitored by AWD3

1: ADC analog channel-x is monitored by AWD3

Note: The channels selected through ADC_AWD3CR must be also configured into the ADC_CHSELR registers. The software is allowed to write this bit only when ADEN = 0.

14.13.15 ADC calibration factor (ADC_CALFACT)

Address offset: 0xB4

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.CALFACT[6:0]
rwrwrwrwrwrwrw

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

Bits 6:0 CALFACT[6:0] : Calibration factor

These bits are written by hardware or by software.

Note: Software can write these bits only when ADEN=1 (ADC is enabled and no calibration is ongoing and no conversion is ongoing).

14.13.16 ADC common configuration register (ADC_CCR)

Address offset: 0x308

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.VBATENTSENVREFENPRESC[3:0]Res.Res.
rwrwrwrwrwrwrw

1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

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

Bit 23 TSEN : Temperature sensor buffer enable

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

0: Temperature sensor buffer disabled

1: Temperature sensor buffer enabled

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

This bit must be cleared before entering low-power modes to avoid unwanted power consumption.

Bit 22 VREFEN : V REFINT buffer enable

This bit is set and cleared by software to enable/disable the V REFINT buffer.

0: V REFINT buffer disabled

1: V REFINT buffer enabled

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

This bit must be cleared before entering low-power modes to avoid unwanted power consumption.

Bits 21:18 PRESC[3:0] : ADC prescaler

Set and cleared by software to select the frequency of the clock to the ADC.

Note: Software is allowed to write these bits only when the ADC is disabled (ADCAL = 0, ADSTART = 0, ADSTP = 0, ADDIS = 0 and ADEN = 0).

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

14.14 ADC register map

The following table summarizes the ADC registers.

Table 76. ADC register map and reset values

OffsetRegister name
Reset value
313029282726252423222120191817161514131211109876543210
0x00ADC_ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CCRDYEOCALRes.Res.AWD3AWD2AWD1Res.Res.Res.OVREOSEOCEOSMP
Reset value000000000
0x04ADC_IERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CCRDYIEEOCALIERes.Res.AWD3IEAWD2IEAWD1IERes.Res.Res.OVRIEEOSIEEOCIEEOSMPIE
Reset value000000000
0x08ADC_CRADCALRes.Res.ADVERGENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ADSTPRes.ADSTARTADDIS
Reset value00000
0x0CADC_CFGR1Res.AWDCH[4:0]Res.Res.AWD1ENAWD1SGLCHSELROMODRes.Res.Res.Res.DISCENAUTOFFWAITCONTOVRMODEXTEN[1:0]Res.EXTSEL [2:0]ALIGNRES [1:0]SCANDIRDMACFGDMAEN
Reset value000000000000000000000
Table 76. ADC register map and reset values (continued)
OffsetRegister name
Reset value
313029282726252423222120191817161514131211109876543210
0x10ADC_CFGR2CKMODE[1:0]LFTRIGRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TOVSOVSS[3:0]OVSR[2:0]Res.OVSE
Reset value000000000000
0x14ADC_SMPRRes.Res.Res.Res.SMPSEL19SMPSEL18SMPSEL17SMPSEL16SMPSEL15SMPSEL14SMPSEL13SMPSEL12SMPSEL11SMPSEL10SMPSEL9SMPSEL8SMPSEL7SMPSEL6SMPSEL5SMPSEL4SMPSEL3SMPSEL2SMPSEL1SMPSEL0Res.SMP2[2:0]Res.SMP1[2:0]
Reset value00000000000000000000000000
0x18ReservedReserved
0x1CReservedReserved
0x20ADC_AWD1TRRes.Res.Res.Res.HT1[11:0]Res.Res.Res.Res.LT1[11:0]
Reset value111111111111000000000000
0x24ADC_AWD2TRRes.Res.Res.Res.HT2[11:0]Res.Res.Res.Res.LT2[11:0]
Reset value111111111111000000000000
0x28ADC_CHSELR
(CHSELRMOD=0)
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CHSEL19CHSEL18CHSEL17CHSEL16CHSEL15CHSEL14CHSEL13CHSEL12CHSEL11CHSEL10CHSEL9CHSEL8CHSEL7CHSEL6CHSEL5CHSEL4CHSEL3CHSEL2CHSEL1CHSEL0
Reset value00000000000000000000
0x28ADC_CHSELR
(CHSELRMOD=1)
SQ8[3:0]SQ7[3:0]SQ6[3:0]SQ5[3:0]SQ4[3:0]SQ3[3:0]SQ2[3:0]SQ1[3:0]
Reset value00000000000000000000000000000000
0x2CADC_AWD3TRRes.Res.Res.Res.HT3[11:0]Res.Res.Res.Res.LT3[11:0]
Reset value111111111111000000000000
0x30
0x34
0x38
0x3C
ReservedReserved
0x40ADC_DRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DATA[15:0]
Reset value0000000000000000
...ReservedReserved
0xA0ADC_AWD2CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD2CH19AWD2CH18AWD2CH17AWD2CH16AWD2CH15AWD2CH14AWD2CH13AWD2CH12AWD2CH11AWD2CH10AWD2CH9AWD2CH8AWD2CH7AWD2CH6AWD2CH5AWD2CH4AWD2CH3AWD2CH2AWD2CH1AWD2CH0
Reset value00000000000000000000
0xA4ADC_AWD3CRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.AWD3CH19AWD3CH18AWD3CH17AWD3CH16AWD3CH15AWD3CH14AWD3CH13AWD3CH12AWD3CH11AWD3CH10AWD3CH9AWD3CH8AWD3CH7AWD3CH6AWD3CH5AWD3CH4AWD3CH3AWD3CH2AWD3CH1AWD3CH0
Reset value00000000000000000000

Table 76. ADC register map and reset values (continued)

OffsetRegister name
Reset value
313029282726252423222120191817161514131211109876543210
...ReservedReserved
0xB4ADC_CALFACTRes.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.CALFACT[6:0]
Reset value00000000
...ReservedReserved
0x308ADC_CCRRes.Res.Res.Res.Res.Res.Res.VBATENTSENVREFENPRESC3PRESC2PRESC1PRESCORes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000

Refer to Section 2.2 for the register boundary addresses.