13. Analog-to-digital converter (ADC)

13.1 ADC introduction

The 12-bit ADC is a successive approximation analog-to-digital converter. It has up to 19 multiplexed channels allowing it to measure signals from 16 external sources, two internal sources, and the \( V_{BAT} \) channel. The A/D conversion of the channels can be performed in single, continuous, scan or discontinuous mode. The result of the ADC is stored into a left- or right-aligned 16-bit data register.

The analog watchdog feature allows the application to detect if the input voltage goes beyond the user-defined, higher or lower thresholds.

13.2 ADC main features

Figure 59 shows the block diagram of the ADC.

Note: \( V_{REF-} \) , if available (depending on package), must be tied to \( V_{SSA} \) .

13.3 ADC functional description

Figure 59 shows a single ADC block diagram and Table 74 gives the ADC pin description.

Figure 59. Single ADC block diagram

Single ADC block diagram showing internal components like GPIO Ports, Analog mux, Injected channels, Regular channels, Analog-to-digital converter, Injected data registers, Regular data register, and interrupt logic.

The diagram illustrates the internal architecture of a single ADC block. On the left, external pins include V VREF+ , V VREF- , V VDDA , V VSSA , ADCx_IN0 through ADCx_IN15, Temp. sensor, V REFINT , V BAT , EXT11_15, and EXT11_11. The ADCx_IN pins connect to an Analog mux, which is also controlled by GPIO Ports. The mux outputs are split: 'Up to 4' go to Injected channels and 'Up to 16' go to Regular channels. Both channel types feed into the Analog-to-digital converter. The converter's output goes to Injected data registers (4 x 16 bits) and a Regular data register (16 bits), which both connect to an Address/data bus. The converter also generates flags: DMA overrun, End of conversion (EOC), End of injected conversion (JEOC), and Analog watchdog event (AWD). These flags are compared against Interrupt enable bits (OVRIE, EOCIE, JEOCIE, AWDIE) in an interrupt logic block to generate an ADC interrupt to the NVIC. An Analog watchdog block contains a Compare result, Higher threshold (12 bits), and Lower threshold (12 bits). The ADC is triggered by signals from timers or external pins (EXT11_15, EXT11_11) through JEXTSEL [3:0] bits and JEXTEN [1:0] bits for injected groups, and EXTSEL [3:0] bits and EXTEN [1:0] bits for regular groups. A DMA request is also generated by the converter. The ADCCLK signal is derived from an ADC prescaler.

Single ADC block diagram showing internal components like GPIO Ports, Analog mux, Injected channels, Regular channels, Analog-to-digital converter, Injected data registers, Regular data register, and interrupt logic.

Table 74. ADC pins

NameSignal typeRemarks
V REF+Input, analog reference positiveThe higher/positive reference voltage for the ADC
V DDAInput, analog supplyAnalog power supply equal to V DD
V REF-Input, analog reference negativeThe lower/negative reference voltage for the ADC, V REF- = V SSA
V SSAInput, analog supply groundGround for analog power supply equal to V SS
ADCx_IN[15:0]Analog input signals16 analog input channels

13.3.1 ADC on-off control

The ADC is powered on by setting the ADON bit in the ADC_CR2 register. When the ADON bit is set for the first time, it wakes up the ADC from the Power-down mode.

The conversion starts when either the SWSTART or the JSWSTART bit is set.

The user can stop conversion and put the ADC in power down mode by clearing the ADON bit. In this mode the ADC consumes almost no power (only a few µA).

13.3.2 ADC clock

The ADC features two clock schemes:

This clock is generated from the APB2 clock divided by a programmable prescaler that allows the ADC to work at f PCLK2 /2, /4, /6 or /8. Refer to the datasheets for the maximum value of ADCCLK.

This clock is equal to the APB2 clock. The digital interface clock can be enabled/disabled individually for each ADC through the RCC APB2 peripheral clock enable register (RCC_APB2ENR).

13.3.3 Channel selection

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

If the ADC_SQRx or ADC_JSQR registers are modified during a conversion, the current conversion is reset and a new start pulse is sent to the ADC to convert the newly chosen group.

Temperature sensor, V REFINT and V BAT internal channels

The internal reference voltage VREFINT is connected to ADC1_IN17.

The V BAT channel is connected to ADC1_IN18 channel. It can also be converted as an injected or regular channel.

13.3.4 Single conversion mode

In Single conversion mode the ADC does one conversion. This mode is started with the CONT bit at 0 by either:

Once the conversion of the selected channel is complete:

Then the ADC stops.

13.3.5 Continuous conversion mode

In continuous conversion mode, the ADC starts a new conversion as soon as it finishes one. This mode is started with the CONT bit at 1 either by external trigger or by setting the SWSTART bit in the ADC_CR2 register (for regular channels only).

After each conversion:

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

13.3.6 Timing diagram

As shown in Figure 60, the ADC needs a stabilization time of \( t_{STAB} \) before it starts converting accurately. After the start of the ADC conversion and after 15 clock cycles, the EOC flag is set and the 16-bit ADC data register contains the result of the conversion.

Figure 60. Timing diagram

Timing diagram for the ADC showing signals ADC_CLK, ADON, SWSTART/JSWSTART, ADC, and EOC over time. It illustrates the stabilization time tSTAB, conversion time, and the sequence of starting and completing conversions.

The timing diagram shows the relationship between several signals during an ADC conversion sequence:

Key timing parameters shown:

Timing diagram for the ADC showing signals ADC_CLK, ADON, SWSTART/JSWSTART, ADC, and EOC over time. It illustrates the stabilization time tSTAB, conversion time, and the sequence of starting and completing conversions.

13.3.7 Analog watchdog

The AWD analog watchdog status bit is set if the analog voltage converted by the ADC is below a lower threshold or above a higher threshold. These thresholds are programmed in the 12 least significant bits of the ADC_HTR and ADC_LTR 16-bit registers. An interrupt can be enabled by using the AWDIE bit in the ADC_CR1 register.

The threshold value is independent of the alignment selected by the ALIGN bit in the ADC_CR2 register. The analog voltage is compared to the lower and higher thresholds before alignment.

Table 75 shows how the ADC_CR1 register should be configured to enable the analog watchdog on one or more channels.

Figure 61. Analog watchdog's guarded area

Diagram illustrating the guarded area for the analog watchdog, showing the analog voltage range between the Higher threshold (HTR) and Lower threshold (LTR).

The diagram shows a vertical axis for 'Analog voltage'. Two horizontal lines represent the 'Higher threshold' (labeled HTR) and the 'Lower threshold' (labeled LTR). The region between these two thresholds is shaded and labeled 'Guarded area', indicating the range of voltages that the watchdog monitors.

Diagram illustrating the guarded area for the analog watchdog, showing the analog voltage range between the Higher threshold (HTR) and Lower threshold (LTR).

Table 75. Analog watchdog channel selection

Channels guarded by the analog watchdogADC_CR1 register control bits (x = don't care)
AWDSGL bitAWDEN bitJAWDEN bit
Nonex00
All injected channels001
All regular channels010
All regular and injected channels011
Single (1) injected channel101
Single (1) regular channel110
Single (1) regular or injected channel111

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

13.3.8 Scan mode

This mode is used to scan a group of analog channels.

The Scan mode is selected by setting the SCAN bit in the ADC_CR1 register. Once this bit has been set, the ADC scans all the channels selected in the ADC_SQRx registers (for regular channels) or in the ADC_JSQR register (for injected channels). A single conversion is performed for each channel of the group. After each end of conversion, the next channel in the group is converted automatically. If the CONT bit is set, regular channel conversion does not stop at the last selected channel in the group but continues again from the first selected channel.

If the DMA bit is set, the direct memory access (DMA) controller is used to transfer the data converted from the regular group of channels (stored in the ADC_DR register) to SRAM after each regular channel conversion.

The EOC bit is set in the ADC_SR register:

The data converted from an injected channel are always stored into the ADC_JDRx registers.

13.3.9 Injected channel management

Triggered injection

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

  1. 1. Start the conversion of a group of regular channels either by external trigger or by setting the SWSTART bit in the ADC_CR2 register.
  2. 2. If an external injected trigger occurs or if the JSWSTART bit is set during the conversion of a regular group of channels, the current conversion is reset and the injected channel sequence switches to Scan-once mode.
  3. 3. Then, the regular conversion of the regular group of channels is resumed from the last interrupted regular conversion.
    If a regular event occurs during an injected conversion, the injected conversion is not

interrupted but the regular sequence is executed at the end of the injected sequence. Figure 62 shows the corresponding timing diagram.

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

Auto-injection

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

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

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

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

Figure 62. Injected conversion latency

Timing diagram for injected conversion latency. The diagram shows four waveforms: ADCCLK (a periodic square wave), Injection event (a single pulse), Reset ADC (a pulse that goes high after the injection event), and SOC (Start of Conversion). Vertical dashed lines mark key timing points. The first dashed line is at the rising edge of the first ADCCLK cycle after the injection event. The second dashed line is at the rising edge of the ADCCLK cycle when the SOC signal goes high. The time interval between these two rising edges is labeled 'max latency (1)'. The SOC signal goes high at the rising edge of the second dashed line and goes low at the rising edge of the third dashed line. The third dashed line is at the rising edge of the ADCCLK cycle after the Reset ADC pulse goes low.
Timing diagram for injected conversion latency. The diagram shows four waveforms: ADCCLK (a periodic square wave), Injection event (a single pulse), Reset ADC (a pulse that goes high after the injection event), and SOC (Start of Conversion). Vertical dashed lines mark key timing points. The first dashed line is at the rising edge of the first ADCCLK cycle after the injection event. The second dashed line is at the rising edge of the ADCCLK cycle when the SOC signal goes high. The time interval between these two rising edges is labeled 'max latency (1)'. The SOC signal goes high at the rising edge of the second dashed line and goes low at the rising edge of the third dashed line. The third dashed line is at the rising edge of the ADCCLK cycle after the Reset ADC pulse goes low.

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

13.3.10 Discontinuous mode

Regular group

This mode is enabled by setting the DISCEN bit in the ADC_CR1 register. It can be used to convert a short sequence of n conversions ( \( n \leq 8 \) ) that is part of the sequence of conversions selected in the ADC_SQRx registers. The value of n is specified by writing to the DISCNUM[2:0] bits in the ADC_CR1 register.

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

Example:

Note: When a regular group is converted in discontinuous mode, no rollover occurs.

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

Injected group

This mode is enabled by setting the JDISCEN bit in the ADC_CR1 register. It can be used to convert the sequence selected in the ADC_JSQR register, channel by channel, after an external trigger event.

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

Example:

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

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

Discontinuous mode must not be set for regular and injected groups at the same time.

Discontinuous mode must be enabled only for the conversion of one group.

13.4 Data alignment

The ALIGN bit in the ADC_CR2 register selects the alignment of the data stored after conversion. Data can be right- or left-aligned as shown in Figure 63 and Figure 64 .

The converted data value from the injected group of channels is decreased by the user-defined offset written in the ADC_JOFRx registers so the result can be a negative value. The SEXT bit represents the extended sign value.

For channels in a regular group, no offset is subtracted so only twelve bits are significant.

Figure 63. Right alignment of 12-bit data

Diagram showing right alignment of 12-bit data for injected and regular groups. Injected group: SEXT SEXT SEXT SEXT D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0. Regular group: 0 0 0 0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0.
Injected group
SEXTSEXTSEXTSEXTD11D10D9D8D7D6D5D4D3D2D1D0
Regular group
0000D11D10D9D8D7D6D5D4D3D2D1D0

ai16050

Diagram showing right alignment of 12-bit data for injected and regular groups. Injected group: SEXT SEXT SEXT SEXT D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0. Regular group: 0 0 0 0 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0.

Figure 64. Left alignment of 12-bit data

Diagram showing left alignment of 12-bit data for injected and regular groups. Injected group: SEXT D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 0 0. Regular group: D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0.
Injected group
SEXTD11D10D9D8D7D6D5D4D3D2D1D0000
Regular group
D11D10D9D8D7D6D5D4D3D2D1D00000

ai16051

Diagram showing left alignment of 12-bit data for injected and regular groups. Injected group: SEXT D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 0 0. Regular group: D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0 0 0 0.

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

Figure 65. Left alignment of 6-bit data

Diagram showing left alignment of 6-bit data for injected and regular groups. Injected group: SEXT SEXT SEXT SEXT SEXT SEXT SEXT SEXT D5 D4 D3 D2 D1 D0 0. Regular group: 0 0 0 0 0 0 0 0 D5 D4 D3 D2 D1 D0 0 0.
Injected group
SEXTSEXTSEXTSEXTSEXTSEXTSEXTSEXTD5D4D3D2D1D00
Regular group
00000000D5D4D3D2D1D000

ai16052

Diagram showing left alignment of 6-bit data for injected and regular groups. Injected group: SEXT SEXT SEXT SEXT SEXT SEXT SEXT SEXT D5 D4 D3 D2 D1 D0 0. Regular group: 0 0 0 0 0 0 0 0 D5 D4 D3 D2 D1 D0 0 0.

13.5 Channel-wise programmable sampling time

The ADC samples the input voltage for a number of ADCCLK cycles that can be modified using the SMP[2:0] bits in the ADC_SMPR1 and ADC_SMPR2 registers. Each channel can be sampled with a different sampling time.

The total conversion time is calculated as follows:

\[ T_{conv} = \text{Sampling time} + 12 \text{ cycles} \]

Example:

With ADCCLK = 30 MHz and sampling time = 3 cycles:

\[ T_{conv} = 3 + 12 = 15 \text{ cycles} = 0.5 \mu s \text{ with APB2 at 60 MHz} \]

13.6 Conversion on external trigger and trigger polarity

Conversion can be triggered by an external event (such as timer trigger/compare, EXTI line). If the EXTEN[1:0] control bits (for a regular conversion) or JEXTEN[1:0] bits (for an injected conversion) are different from “0b00”, then external events are able to trigger a conversion with the selected polarity. Table 76 provides the correspondence between the EXTEN[1:0] and JEXTEN[1:0] values and the trigger polarity.

Table 76. Configuring the trigger polarity

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

Note: The polarity of the external trigger can be changed on the fly.

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

Table 77 gives the possible external trigger for regular conversion.

Table 77. External trigger for regular channels

SourceTypeEXTSEL[3:0]
tim1_oc1 eventInternal signal from on-chip timers0000
tim1_oc2 event0001
tim1_oc3 event0010
tim2_oc2 event0011
tim1_oc3 event0100
tim1_oc4 event0101
tim2_trgo event0110
tim3_oc1 event0111
tim3_trgo event1000
tim4_oc4 event1001
tim5_oc1 event1010
tim5_oc2 event1011
tim5_oc3 event1100
tim8_oc1 event1101
tim8_trgo event1110
exti11External pin1111

Table 78 gives the possible external trigger for injected conversion.

Table 78. External trigger for injected channels

SourceConnection typeJEXTSEL[3:0]
tim1_oc4 eventInternal signal from on-chip timers0000
tim1_trgo event0001
tim2_oc1 event0010
tim2_trgo event0011
tim3_oc2 event0100
tim3_oc4 event0101
tim4_oc1 event0110
tim4_oc2 event0111
tim4_oc3 event1000
tim4_trgo event1001
tim5_oc4 event1010
tim5_trgo event1011
tim8_oc2 event1100
tim8_oc3 event1101
tim8_oc4 event1110
exti15External pin1111

Software source trigger events can be generated by setting SWSTART (for regular conversion) or JSWSTART (for injected conversion) in ADC_CR2.

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

Note: The trigger selection can be changed on the fly. However, when the selection changes, there is a time frame of 1 APB clock cycle during which the trigger detection is disabled. This is to avoid spurious detection during transitions.

13.7 Fast conversion mode

It is possible to perform faster conversion by reducing the ADC resolution. The RES bits are used to select the number of bits available in the data register. The minimum conversion time for each resolution is then as follows:

13.8 Data management

13.8.1 Using the DMA

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

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

Despite this, if data are lost (overrun), the OVR bit in the ADC_SR register is set and an interrupt is generated (if the OVRIE enable bit is set). DMA transfers are then disabled and DMA requests are no longer accepted. In this case, if a DMA request is made, the regular conversion in progress is aborted and further regular triggers are ignored. It is then necessary to clear the OVR flag and the DMAEN bit in the used DMA stream, and to re-initialize both the DMA and the ADC to have the wanted converted channel data transferred to the right memory location. Only then can the conversion be resumed and the data transfer, enabled again. Injected channel conversions are not impacted by overrun errors.

When OVR = 1 in DMA mode, the DMA requests are blocked after the last valid data have been transferred, which means that all the data transferred to the RAM can be considered as valid.

At the end of the last DMA transfer (number of transfers configured in the DMA controller's DMA_SxNDTR register):

To recover the ADC from OVR state when the DMA is used, follow the steps below:

  1. 1. Reinitialize the DMA (adjust destination address and NDTR counter)
  2. 2. Clear the ADC OVR bit in ADC_SR register
  3. 3. Trigger the ADC to start the conversion.

13.8.2 Managing a sequence of conversions without using the DMA

If the conversions are slow enough, the conversion sequence can be handled by the software. In this case the EOCS bit must be set in the ADC_CR2 register for the EOC status bit to be set at the end of each conversion, and not only at the end of the sequence. When EOCS = 1, overrun detection is automatically enabled. Thus, each time a conversion is complete, EOC is set and the ADC_DR register can be read. The overrun management is the same as when the DMA is used.

To recover the ADC from OVR state when the EOCS is set, follow the steps below:

  1. 1. Clear the ADC OVR bit in ADC_SR register
  2. 2. Trigger the ADC to start the conversion.

13.8.3 Conversions without DMA and without overrun detection

It may be useful to let the ADC convert one or more channels without reading the data each time (if there is an analog watchdog for instance). For that, the DMA must be disabled (DMA = 0) and the EOC bit must be set at the end of a sequence only (EOCS = 0). In this configuration, overrun detection is disabled.

13.9 Temperature sensor

The temperature sensor can be used to measure the junction temperature ( \( T_J \) ) of the device.

Figure 66 shows the block diagram of the temperature sensor.

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

Note: The TSVREFE bit must be set to enable the conversion of both internal channels: the ADC1_IN18 (temperature sensor) and the ADC1_IN17 (VREFINT).

Main features

Figure 66. Temperature sensor and V REFINT channel block diagram

Block diagram of the temperature sensor and VREFINT channel. A 'Temperature sensor' block and an 'Internal power block' block are connected to a multiplexer. The multiplexer is controlled by the 'TSVREFE control bit'. The output of the multiplexer for the temperature sensor is labeled 'VSENSE' and is connected to the 'ADC1_IN18' input of the 'ADC1' block. The output of the multiplexer for the internal power block is labeled 'VREFINT' and is connected to the 'ADC1_IN17' input of the 'ADC1' block. The 'ADC1' block outputs 'converted data' to an 'Address/data bus' block. The diagram is labeled 'MS35936V1' in the bottom right corner.
graph LR; TS[Temperature sensor] -- VSENSE --> ADC1_IN18[ADC1_IN18]; IPB[Internal power block] -- VREFINT --> ADC1_IN17[ADC1_IN17]; TSVREFE[TSVREFE control bit] --> MUX; MUX --> ADC1_IN18; MUX --> ADC1_IN17; ADC1[ADC1] -- converted data --> Bus[Address/data bus];
Block diagram of the temperature sensor and VREFINT channel. A 'Temperature sensor' block and an 'Internal power block' block are connected to a multiplexer. The multiplexer is controlled by the 'TSVREFE control bit'. The output of the multiplexer for the temperature sensor is labeled 'VSENSE' and is connected to the 'ADC1_IN18' input of the 'ADC1' block. The output of the multiplexer for the internal power block is labeled 'VREFINT' and is connected to the 'ADC1_IN17' input of the 'ADC1' block. The 'ADC1' block outputs 'converted data' to an 'Address/data bus' block. The diagram is labeled 'MS35936V1' in the bottom right corner.
  1. 1. V SENSE is input to ADC1_IN18.

Reading the temperature

To use the sensor:

  1. 3. Select ADC1_IN18 input channel.
  2. 4. Select a sampling time greater than the minimum sampling time specified in the datasheet.
  3. 5. Set the TSVREFE bit in the ADC_CCR register to wake up the temperature sensor from power down mode
  4. 6. Start the ADC conversion by setting the SWSTART bit (or by external trigger)
  5. 7. Read the resulting \( V_{\text{SENSE}} \) data in the ADC data register
  6. 8. Calculate the temperature using the following formula:

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

Where:

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

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

The temperature sensor output voltage changes linearly with temperature. The offset of this linear function depends on each chip due to process variation (up to \( 45^\circ\text{C} \) from one chip to another).

The internal temperature sensor is more suited for applications that detect temperature variations instead of absolute temperatures. If accurate temperature reading is required, an external temperature sensor should be used.

13.10 Battery charge monitoring

The VBATE bit in the ADC_CCR register is used to switch to the battery voltage. As the \( V_{\text{BAT}} \) voltage could be higher than \( V_{\text{DDA}} \) , to ensure the correct operation of the ADC, the \( V_{\text{BAT}} \) pin is internally connected to a bridge divider.

When the VBATE is set, the bridge is automatically enabled to connect:

Note: The VBAT and temperature sensor are connected to the same ADC internal channel (ADC1_IN18). Only one conversion, either temperature sensor or VBAT, must be selected at a time. When both conversion are enabled simultaneously, only the VBAT conversion is performed.

13.11 ADC interrupts

An interrupt can be produced on the end of conversion for regular and injected groups, when the analog watchdog status bit is set and when the overrun status bit is set. Separate interrupt enable bits are available for flexibility.

Two other flags are present in the ADC_SR register, but there is no interrupt associated with them:

Table 79. ADC interrupts

Interrupt eventEvent flagEnable control bit
End of conversion of a regular groupEOCEOCIE
End of conversion of an injected groupJEOCJEOCIE
Analog watchdog status bit is setAWDAWDIE
OverrunOVROVRIE

13.12 ADC registers

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

The peripheral registers must be written at word level (32 bits). Read accesses can be done by bytes (8 bits), half-words (16 bits) or words (32 bits).

13.12.1 ADC status register (ADC_SR)

Address offset: 0x00

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OVRSTRTJSTRTJEOCEOCAWD
rc_w0rc_w0rc_w0rc_w0rc_w0rc_w0

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

Bit 5 OVR : Overrun

This bit is set by hardware when data are lost (either in single mode or in dual/triple mode). It is cleared by software. Overrun detection is enabled only when DMA = 1 or EOCS = 1.

0: No overrun occurred

1: Overrun has occurred

Bit 4 STRT : Regular channel start flag

This bit is set by hardware when regular channel conversion starts. It is cleared by software.

0: No regular channel conversion started

1: Regular channel conversion has started

Bit 3 JSTRT : Injected channel start flag

This bit is set by hardware when injected group conversion starts. It is cleared by software.

0: No injected group conversion started

1: Injected group conversion has started

Bit 2 JEOC : Injected channel end of conversion

This bit is set by hardware at the end of the conversion of all injected channels in the group. It is cleared by software.

0: Conversion is not complete

1: Conversion complete

Bit 1 EOC : Regular channel end of conversion

This bit is set by hardware at the end of the conversion of a regular group of channels. It is cleared by software or by reading the ADC_DR register.

0: Conversion not complete (EOCS = 1), or sequence of conversions not complete (EOCS = 0)

1: Conversion complete (EOCS = 1), or sequence of conversions complete (EOCS = 0)

Bit 0 AWD : Analog watchdog flag

This bit is set by hardware when the converted voltage crosses the values programmed in the ADC_LTR and ADC_HTR registers. It is cleared by software.

0: No analog watchdog event occurred

1: Analog watchdog event occurred

13.12.2 ADC control register 1 (ADC_CR1)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.OVRIERES[1:0]AWDENJAWDENRes.Res.Res.Res.Res.Res.
rwrwrwrw

1514131211109876543210
DISCNUM[2:0]JDISCENDISCENJAUTOAWDSGLSCANJEOCIEAWDIEEOCIEAWDCH[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

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

Bits 25:24 RES[1:0] : Resolution

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

00: 12-bit (minimum 15 ADCCLK cycles)

01: 10-bit (minimum 13 ADCCLK cycles)

10: 8-bit (minimum 11 ADCCLK cycles)

11: 6-bit (minimum 9 ADCCLK cycles)

Bit 23 AWDEN : Analog watchdog enable on regular channels

This bit is set and cleared by software.

0: Analog watchdog disabled on regular channels

1: Analog watchdog enabled on regular channels

Bit 22 JAWDEN : Analog watchdog enable on injected channels

This bit is set and cleared by software.

0: Analog watchdog disabled on injected channels

1: Analog watchdog enabled on injected channels

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

Bits 15:13 DISCNUM[2:0] : Discontinuous mode channel count

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

000: 1 channel

001: 2 channels

...

111: 8 channels

Bit 12 JDISCEN : Discontinuous mode on injected channels

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

0: Discontinuous mode on injected channels disabled

1: Discontinuous mode on injected channels enabled

Bit 11 DISCEN : Discontinuous mode on regular channels

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

0: Discontinuous mode on regular channels disabled

1: Discontinuous mode on regular channels enabled

Bit 10 JAUTO : Automatic injected group conversion

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

0: Automatic injected group conversion disabled

1: Automatic injected group conversion enabled

Bit 9 AWDSGL : Enable the watchdog on a single channel in scan mode

This bit is set and cleared by software to enable/disable the analog watchdog on the channel identified by the AWDCH[4:0] bits.

0: Analog watchdog enabled on all channels

1: Analog watchdog enabled on a single channel

Bit 8 SCAN : Scan mode

This bit is set and cleared by software to enable/disable the Scan mode. In Scan mode, the inputs selected through the ADC_SQRx or ADC_JSQRx registers are converted.

0: Scan mode disabled

1: Scan mode enabled

Note: An EOC interrupt is generated if the EOCIE bit is set:

At the end of each regular group sequence if the EOCS bit is cleared to 0

At the end of each regular channel conversion if the EOCS bit is set to 1

Note: A JEOC interrupt is generated only on the end of conversion of the last channel if the JEOCIE bit is set.

Bit 7 JEOCIE : Interrupt enable for injected channels

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

0: JEOC interrupt disabled

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

Bit 6 AWDIE : Analog watchdog 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

Bit 5 EOCIE : Interrupt enable for EOC

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.

Bits 4:0 AWDCH[4:0] : Analog watchdog channel select bits

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

Note: 00000: ADC analog input Channel0

00001: ADC analog input Channel1

...

01111: ADC analog input Channel15

10000: ADC analog input Channel16

10001: ADC analog input Channel17

10010: ADC analog input Channel18

Other values reserved

13.12.3 ADC control register 2 (ADC_CR2)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.SWSTARTEXTEN[1:0]EXTSEL[3:0]Res.JSWSTARTJEXTEN[1:0]JEXTSEL[3:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.ALIGNEOCSDDSDMARes.Res.Res.Res.Res.Res.CONTADON
rwrwrwrwrwrw

Bit 31 Reserved, must be kept at reset value.

Bit 30 SWSTART : Start conversion of regular channels

This bit is set by software to start conversion and cleared by hardware as soon as the conversion starts.

0: Reset state

1: Starts conversion of regular channels

Note: This bit can be set only when ADON = 1 otherwise no conversion is launched.

Bits 29:28 EXTEN : External trigger enable for regular channels

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

00: Trigger detection disabled

01: Trigger detection on the rising edge

10: Trigger detection on the falling edge

11: Trigger detection on both the rising and falling edges

Bits 27:24 EXTSEL[3:0] : External event select for regular group

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

0000: Timer 1 CC1 event

0001: Timer 1 CC2 event

0010: Timer 1 CC3 event

0011: Timer 2 CC2 event

0100: Timer 2 CC3 event

0101: Timer 2 CC4 event

0110: Timer 2 TRGO event

0111: Timer 3 CC1 event

1000: Timer 3 TRGO event

1001: Timer 4 CC4 event

1010: Timer 5 CC1 event

1011: Timer 5 CC2 event

1100: Timer 5 CC3 event

1101: Timer 8 CC1 event

1110: Timer 8 TRGO event

1111: EXTI line 11

Bit 23 Reserved, must be kept at reset value.

Bit 22 JSWSTART : Start conversion of injected channels

This bit is set by software and cleared by hardware as soon as the conversion starts.

0: Reset state

1: Starts conversion of injected channels

This bit can be set only when ADON = 1 otherwise no conversion is launched.

Bits 21:20 JEXTEN : External trigger enable for injected channels

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

00: Trigger detection disabled

01: Trigger detection on the rising edge

10: Trigger detection on the falling edge

11: Trigger detection on both the rising and falling edges

Bits 19:16 JEXTSEL[3:0] : External event select for injected group

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

0000: Timer 1 CC4 event

0001: Timer 1 TRGO event

0010: Timer 2 CC1 event

0011: Timer 2 TRGO event

0100: Timer 3 CC2 event

0101: Timer 3 CC4 event

0110: Timer 4 CC1 event

0111: Timer 4 CC2 event

1000: Timer 4 CC3 event

1001: Timer 4 TRGO event

1010: Timer 5 CC4 event

1011: Timer 5 TRGO event

1100: Timer 8 CC2 event

1101: Timer 8 CC3 event

1110: Timer 8 CC4 event

1111: EXTI line15

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

Bit 11 ALIGN : Data alignment

This bit is set and cleared by software. Refer to Figure 63 and Figure 64 .

0: Right alignment

1: Left alignment

Bit 10 EOCS : End of conversion selection

This bit is set and cleared by software.

0: The EOC bit is set at the end of each sequence of regular conversions. Overrun detection is enabled only if DMA=1.

1: The EOC bit is set at the end of each regular conversion. Overrun detection is enabled.

Bit 9 DDS : DMA disable selection (for single ADC mode)

This bit is set and cleared by software.

0: No new DMA request is issued after the last transfer (as configured in the DMA controller)

1: DMA requests are issued as long as data are converted and DMA=1

Bit 8 DMA : Direct memory access mode (for single ADC mode)

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

0: DMA mode disabled

1: DMA mode enabled

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

Bit 1 CONT : Continuous conversion

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

Bit 0 ADON : A/D Converter ON / OFF

This bit is set and cleared by software.

0: Disable ADC conversion and go to power down mode

1: Enable ADC

13.12.4 ADC sample time register 1 (ADC_SMPR1)

Address offset: 0x0C

Reset value: 0x0000 0000

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

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

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

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

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

  1. Note:
    • 000: 3 cycles
    • 001: 15 cycles
    • 010: 28 cycles
    • 011: 56 cycles
    • 100: 84 cycles
    • 101: 112 cycles
    • 110: 144 cycles
    • 111: 480 cycles

13.12.5 ADC sample time register 2 (ADC_SMPR2)

Address offset: 0x10

Reset value: 0x0000 0000

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

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

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

These bits are written by software to select the sampling time individually for each channel. During sample cycles, the channel selection bits must remain unchanged.

Note: 000: 3 cycles
001: 15 cycles
010: 28 cycles
011: 56 cycles
100: 84 cycles
101: 112 cycles
110: 144 cycles
111: 480 cycles

13.12.6 ADC injected channel data offset register x (ADC_JOFRx) (x=1..4)

Address offset: 0x14-0x20

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.JOFFSETx[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 11:0 JOFFSETx[11:0] : Data offset for injected channel x

These bits are written by software to define the offset to be subtracted from the raw converted data when converting injected channels. The conversion result can be read from in the ADC_JDRx registers.

13.12.7 ADC watchdog higher threshold register (ADC_HTR)

Address offset: 0x24

Reset value: 0x0000 0FFF

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.HT[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 11:0 HT[11:0] : Analog watchdog higher threshold

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

Note: The software can write to these registers when an ADC conversion is ongoing. The programmed value will be effective when the next conversion is complete. Writing to this register is performed with a write delay that can create uncertainty on the effective time at which the new value is programmed.

13.12.8 ADC watchdog lower threshold register (ADC_LTR)

Address offset: 0x28

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.LT[11:0]
rwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 11:0 LT[11:0] : Analog watchdog lower threshold

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

Note: The software can write to these registers when an ADC conversion is ongoing. The programmed value will be effective when the next conversion is complete. Writing to this register is performed with a write delay that can create uncertainty on the effective time at which the new value is programmed.

13.12.9 ADC regular sequence register 1 (ADC_SQR1)

Address offset: 0x2C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.L[3:0]SQ16[4:1]
rwrwrwrwrwrwrwrw
1514131211109876543210
SQ16_0SQ15[4:0]SQ14[4:0]SQ13[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 23:20 L[3:0] : Regular channel sequence length

These bits are written by software to define the total number of conversions in the regular channel conversion sequence.

0000: 1 conversion

0001: 2 conversions

...

1111: 16 conversions

Bits 19:15 SQ16[4:0] : 16th conversion in regular sequence

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

Bits 14:10 SQ15[4:0] : 15th conversion in regular sequence

Bits 9:5 SQ14[4:0] : 14th conversion in regular sequence

Bits 4:0 SQ13[4:0] : 13th conversion in regular sequence

13.12.10 ADC regular sequence register 2 (ADC_SQR2)

Address offset: 0x30

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.SQ12[4:0]SQ11[4:0]SQ10[4:1]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SQ10_0SQ9[4:0]SQ8[4:0]SQ7[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 29:25 SQ12[4:0] : 12th conversion in regular sequence

These bits are written by software with the channel number (0..18) assigned as the 12th in the sequence to be converted.

Bits 24:20 SQ11[4:0] : 11th conversion in regular sequence

Bits 19:15 SQ10[4:0] : 10th conversion in regular sequence

Bits 14:10 SQ9[4:0] : 9th conversion in regular sequence

Bits 9:5 SQ8[4:0] : 8th conversion in regular sequence

Bits 4:0 SQ7[4:0] : 7th conversion in regular sequence

13.12.11 ADC regular sequence register 3 (ADC_SQR3)

Address offset: 0x34

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.SQ6[4:0]SQ5[4:0]SQ4[4:1]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SQ4_0SQ3[4:0]SQ2[4:0]SQ1[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 29:25 SQ6[4:0] : 6th conversion in regular sequence

These bits are written by software with the channel number (0..18) assigned as the 6th in the sequence to be converted.

Bits 24:20 SQ5[4:0] : 5th conversion in regular sequence

Bits 19:15 SQ4[4:0] : 4th conversion in regular sequence

Bits 14:10 SQ3[4:0] : 3rd conversion in regular sequence

Bits 9:5 SQ2[4:0] : 2nd conversion in regular sequence

Bits 4:0 SQ1[4:0] : 1st conversion in regular sequence

13.12.12 ADC injected sequence register (ADC_JSQR)

Address offset: 0x38

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.JL[1:0]JSQ4[4:1]
rwrwrwrwrwrw
1514131211109876543210
JSQ4[0]JSQ3[4:0]JSQ2[4:0]JSQ1[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 21:20 JL[1:0] : Injected sequence length

These bits are written by software to define the total number of conversions in the injected channel conversion sequence.

Bits 19:15 JSQ4[4:0] : 4th conversion in injected sequence (when JL[1:0]=3, see note below)

These bits are written by software with the channel number (0..18) assigned as the 4th in the sequence to be converted.

Bits 14:10 JSQ3[4:0] : 3rd conversion in injected sequence (when JL[1:0]=3, see note below)

Bits 9:5 JSQ2[4:0] : 2nd conversion in injected sequence (when JL[1:0]=3, see note below)

Bits 4:0 JSQ1[4:0] : 1st conversion in injected sequence (when JL[1:0]=3, see note below)

Note: When JL[1:0]=3 (4 injected conversions in the sequencer), the ADC converts the channels in the following order: JSQ1[4:0], JSQ2[4:0], JSQ3[4:0], and JSQ4[4:0].

When JL=2 (3 injected conversions in the sequencer), the ADC converts the channels in the following order: JSQ2[4:0], JSQ3[4:0], and JSQ4[4:0].

When JL=1 (2 injected conversions in the sequencer), the ADC converts the channels in starting from JSQ3[4:0], and then JSQ4[4:0].

When JL=0 (1 injected conversion in the sequencer), the ADC converts only JSQ4[4:0] channel.

13.12.13 ADC injected data register x (ADC_JDRx) (x= 1..4)

Address offset: 0x3C - 0x48

Reset value: 0x0000 0000

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

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

Bits 15:0 JDATA[15:0] : Injected data

These bits are read-only. They contain the conversion result from injected channel x. The data are left -or right-aligned as shown in Figure 63 and Figure 64 .

13.12.14 ADC regular data register (ADC_DR)

Address offset: 0x4C

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] : Regular data

These bits are read-only. They contain the conversion result from the regular channels. The data are left- or right-aligned as shown in Figure 63 and Figure 64 .

13.12.15 ADC Common status register (ADC_CSR)

Address offset: 0x00 (this offset address is relative to ADC1 base address + 0x300)

Reset value: 0x0000 0000

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

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.Res.OVR1STRT1JSTRT1JE0C 1EOC1AWD1
rrrrrr

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

Bit 5 OVR1 : Overrun flag of ADC1

This bit is a copy of the OVR bit in the ADC1_SR register.

Bit 4 STRT1 : Regular channel Start flag of ADC1

This bit is a copy of the STRT bit in the ADC1_SR register.

Bit 3 JSTRT1 : Injected channel Start flag of ADC1

This bit is a copy of the JSTRT bit in the ADC1_SR register.

  1. Bit 2 JEOC1 : Injected channel end of conversion of ADC1
    This bit is a copy of the JEOC bit in the ADC1_SR register.
  2. Bit 1 EOC1 : End of conversion of ADC1
    This bit is a copy of the EOC bit in the ADC1_SR register.
  3. Bit 0 AWD1 : Analog watchdog flag of ADC1
    This bit is a copy of the AWD bit in the ADC1_SR register.

13.12.16 ADC common control register (ADC_CCR)

Address offset: 0x04 (this offset address is relative to ADC1 base address + 0x300)

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.TSVREFEVBATERes.Res.Res.Res.ADCPRE
rwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

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

  1. Bit 23 TSVREFE : Temperature sensor and \( V_{REFINT} \) enable
    This bit is set and cleared by software to enable/disable the temperature sensor and the \( V_{REFINT} \) channel.
    0: Temperature sensor and \( V_{REFINT} \) channel disabled
    1: Temperature sensor and \( V_{REFINT} \) channel enabled
    Note: VBATE must be disabled when TSVREFE is set. If both bits are set, only the VBAT conversion is performed.
  1. Bit 22 VBATE : \( 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

Bits 21:18 Reserved, must be kept at reset value.

  1. Bits 17:16 ADCPRE : ADC prescaler
    Set and cleared by software to select the frequency of the clock to the ADC. The clock is common for all the ADCs.
    Note: 00: PCLK2 divided by 2
    01: PCLK2 divided by 4
    10: PCLK2 divided by 6
    11: PCLK2 divided by 8

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

13.12.17 ADC register map

The following table summarizes the ADC registers.

Table 80. ADC global register map

OffsetRegister
0x000 - 0x04CADC1
0x050 - 0x2FCReserved
0x300 - 0x308Common registers

Table 81. ADC register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00ADC_SRRes.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.OVRSTRTJSTRTJEOCEOCAWD
Reset value000000
0x04ADC_CR1Res.Res.Res.Res.Res.OVRIERES[1:0]AWDENJAWDENRes.Res.Res.Res.Res.Res.DISC NUM [2:0]JDISCENDISCENJAUTOAWD SGLSCANJEOCIEAWDIEEOCIEAWDCH[4:0]
Reset value000000000000000000000
0x08ADC_CR2Res.SWSTARTEXTEN[1:0]EXTSEL [3:0]Res.JSWSTARTJEXTEN[1:0]JEXTSEL [3:0]Res.Res.Res.ALIGNEOCSDDSDMARes.Res.Res.Res.Res.Res.CONTADON
Reset value0000000000000000000
0x0CADC_SMPR1Sample time bits SMPx_x
Reset value00000000000000000000000000000000
0x10ADC_SMPR2Sample time bits SMPx_x
Reset value00000000000000000000000000000000
0x14ADC_JOFR1Res.JOFFSET1[11:0]
Reset value000000000000
0x18ADC_JOFR2Res.JOFFSET2[11:0]
Reset value000000000000
0x1CADC_JOFR3Res.JOFFSET3[11:0]
Reset value000000000000
0x20ADC_JOFR4Res.JOFFSET4[11:0]
Reset value000000000000
0x24ADC_HTRRes.HT[11:0]
Reset value111111111111
0x28ADC_LTRRes.LT[11:0]
Reset value000000000000
0x2CADC_SQR1Res.L[3:0]Regular channel sequence SQx_x bits
Reset value000000000000000000000000
0x30ADC_SQR2Res.Regular channel sequence SQx_x bits
Reset value000000000000000000000000000000

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

OffsetRegister313029282726252423222120191817161514131211109876543210
0x34ADC_SQR3Regular channel sequence SQx_x bits
Reset value000000000000000000000000000000
0x38ADC_JSQRJL[1:0]Injected channel sequence JSQx_x bits
Reset value000000000000000000000
0x3CADC_JDR1JDATA[15:0]
Reset value0
0x40ADC_JDR2JDATA[15:0]
Reset value0
0x44ADC_JDR3JDATA[15:0]
Reset value0
0x48ADC_JDR4JDATA[15:0]
Reset value0
0x4CADC_DRRegular DATA[15:0]
Reset value0

Table 82. ADC register map and reset values (common ADC registers)

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00ADC_CSRRes.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.OVRSTRTJSSTRTEOCAWD
Reset value00000
0x04ADC_CCRRes.Res.Res.Res.Res.Res.Res.Res.TSVREFEVBATRes.Res.Res.Res.ADCPR[1:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value00

Refer to Section 2.2 on page 49 for the register boundary addresses.