TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Embed: (wiki syntax)

« Back to documentation index

Configuration of ADC hierarchical scope: ADC instance

Configuration of ADC hierarchical scope: ADC instance
[ADC Exported Functions]

Functions

__STATIC_INLINE void LL_ADC_SetCalibrationFactor (ADC_TypeDef *ADCx, uint32_t SingleDiff, uint32_t CalibrationFactor)
 Set ADC calibration factor in the mode single-ended or differential (for devices with differential mode available).
__STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor (ADC_TypeDef *ADCx, uint32_t SingleDiff)
 Get ADC calibration factor in the mode single-ended or differential (for devices with differential mode available).
__STATIC_INLINE void LL_ADC_SetResolution (ADC_TypeDef *ADCx, uint32_t Resolution)
 Set ADC resolution.
__STATIC_INLINE uint32_t LL_ADC_GetResolution (ADC_TypeDef *ADCx)
 Get ADC resolution.
__STATIC_INLINE void LL_ADC_SetDataAlignment (ADC_TypeDef *ADCx, uint32_t DataAlignment)
 Set ADC conversion data alignment.
__STATIC_INLINE uint32_t LL_ADC_GetDataAlignment (ADC_TypeDef *ADCx)
 Get ADC conversion data alignment.
__STATIC_INLINE void LL_ADC_SetLowPowerMode (ADC_TypeDef *ADCx, uint32_t LowPowerMode)
 Set ADC low power mode.
__STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode (ADC_TypeDef *ADCx)
 Get ADC low power mode:
__STATIC_INLINE void LL_ADC_SetOffset (ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t Channel, uint32_t OffsetLevel)
 Set ADC selected offset number 1, 2, 3 or 4.
__STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel (ADC_TypeDef *ADCx, uint32_t Offsety)
 Get for the ADC selected offset number 1, 2, 3 or 4: Channel to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected)
__STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel (ADC_TypeDef *ADCx, uint32_t Offsety)
 Get for the ADC selected offset number 1, 2, 3 or 4: Offset level (offset to be subtracted from the raw converted data).
__STATIC_INLINE void LL_ADC_SetOffsetState (ADC_TypeDef *ADCx, uint32_t Offsety, uint32_t OffsetState)
 Set for the ADC selected offset number 1, 2, 3 or 4: force offset state disable or enable without modifying offset channel or offset value.
__STATIC_INLINE uint32_t LL_ADC_GetOffsetState (ADC_TypeDef *ADCx, uint32_t Offsety)
 Get for the ADC selected offset number 1, 2, 3 or 4: offset state disabled or enabled.

Function Documentation

__STATIC_INLINE uint32_t LL_ADC_GetCalibrationFactor ( ADC_TypeDef *  ADCx,
uint32_t  SingleDiff 
)

Get ADC calibration factor in the mode single-ended or differential (for devices with differential mode available).

Note:
Calibration factors are set by hardware after performing a calibration run using function LL_ADC_StartCalibration().
For devices with differential mode available: Calibration of offset is specific to each of single-ended and differential modes CALFACT CALFACT_S LL_ADC_GetCalibrationFactor
CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
Parameters:
ADCxADC instance
SingleDiffThis parameter can be one of the following values:

  • LL_ADC_SINGLE_ENDED
  • LL_ADC_DIFFERENTIAL_ENDED
Return values:
Valuebetween Min_Data=0x00 and Max_Data=0x7F

Definition at line 2561 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE uint32_t LL_ADC_GetDataAlignment ( ADC_TypeDef *  ADCx )

Get ADC conversion data alignment.

Note:
Refer to reference manual for alignments formats dependencies to ADC resolutions. CFGR ALIGN LL_ADC_GetDataAlignment
Parameters:
ADCxADC instance
Return values:
Returnedvalue can be one of the following values:

  • LL_ADC_DATA_ALIGN_RIGHT
  • LL_ADC_DATA_ALIGN_LEFT

Definition at line 2639 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE uint32_t LL_ADC_GetLowPowerMode ( ADC_TypeDef *  ADCx )

Get ADC low power mode:

Note:
Description of ADC low power modes:
  • ADC low power mode "auto wait": Dynamic low power mode, ADC conversions occurrences are limited to the minimum necessary in order to reduce power consumption. New ADC conversion starts only when the previous unitary conversion data (for ADC group regular) or previous sequence conversions data (for ADC group injected) has been retrieved by user software. In the meantime, ADC remains idle: does not performs any other conversion. This mode allows to automatically adapt the ADC conversions triggers to the speed of the software that reads the data. Moreover, this avoids risk of overrun for low frequency applications. How to use this low power mode:
    • Do not use with interruption or DMA since these modes have to clear immediately the EOC flag to free the IRQ vector sequencer.
    • Do use with polling: 1. Start conversion, 2. Later on, when conversion data is needed: poll for end of conversion to ensure that conversion is completed and retrieve ADC conversion data. This will trig another ADC conversion start.
  • ADC low power mode "auto power-off" (feature available on this device if parameter LL_ADC_LP_MODE_AUTOOFF is available): the ADC automatically powers-off after a conversion and automatically wakes up when a new conversion is triggered (with startup time between trigger and start of sampling). This feature can be combined with low power mode "auto wait".
With ADC low power mode "auto wait", the ADC conversion data read is corresponding to previous ADC conversion start, independently of delay during which ADC was idle. Therefore, the ADC conversion data may be outdated: does not correspond to the current voltage level on the selected ADC channel. CFGR AUTDLY LL_ADC_GetLowPowerMode
Parameters:
ADCxADC instance
Return values:
Returnedvalue can be one of the following values:

  • LL_ADC_LP_MODE_NONE
  • LL_ADC_LP_AUTOWAIT

Definition at line 2740 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE uint32_t LL_ADC_GetOffsetChannel ( ADC_TypeDef *  ADCx,
uint32_t  Offsety 
)

Get for the ADC selected offset number 1, 2, 3 or 4: Channel to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected)

Note:
Usage of the returned channel number:
  • To reinject this channel into another function LL_ADC_xxx: the returned channel number is only partly formatted on definition of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared with parts of literals LL_ADC_CHANNEL_x or using helper macro __LL_ADC_CHANNEL_TO_DECIMAL_NB(). Then the selected literal LL_ADC_CHANNEL_x can be used as parameter for another function.
  • To get the channel number in decimal format: process the returned value with the helper macro __LL_ADC_CHANNEL_TO_DECIMAL_NB().
On STM32L4, some fast channels are available: fast analog inputs coming from GPIO pads (ADC_IN1..5). OFR1 OFFSET1_CH LL_ADC_GetOffsetChannel
OFR2 OFFSET2_CH LL_ADC_GetOffsetChannel
OFR3 OFFSET3_CH LL_ADC_GetOffsetChannel
OFR4 OFFSET4_CH LL_ADC_GetOffsetChannel
Parameters:
ADCxADC instance
OffsetyThis parameter can be one of the following values:

  • LL_ADC_OFFSET_1
  • LL_ADC_OFFSET_2
  • LL_ADC_OFFSET_3
  • LL_ADC_OFFSET_4
Return values:
Returnedvalue can be one of the following values:

  • LL_ADC_CHANNEL_0
  • LL_ADC_CHANNEL_1 (7)
  • LL_ADC_CHANNEL_2 (7)
  • LL_ADC_CHANNEL_3 (7)
  • LL_ADC_CHANNEL_4 (7)
  • LL_ADC_CHANNEL_5 (7)
  • LL_ADC_CHANNEL_6
  • LL_ADC_CHANNEL_7
  • LL_ADC_CHANNEL_8
  • LL_ADC_CHANNEL_9
  • LL_ADC_CHANNEL_10
  • LL_ADC_CHANNEL_11
  • LL_ADC_CHANNEL_12
  • LL_ADC_CHANNEL_13
  • LL_ADC_CHANNEL_14
  • LL_ADC_CHANNEL_15
  • LL_ADC_CHANNEL_16
  • LL_ADC_CHANNEL_17
  • LL_ADC_CHANNEL_18
  • LL_ADC_CHANNEL_VREFINT (1)
  • LL_ADC_CHANNEL_TEMPSENSOR (4)
  • LL_ADC_CHANNEL_VBAT (4)
  • LL_ADC_CHANNEL_DAC1CH1 (5)
  • LL_ADC_CHANNEL_DAC1CH2 (5)
  • LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  • LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  • LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  • LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)

(1) On STM32L4, parameter available only on ADC instance: ADC1.
(2) On STM32L4, parameter available only on ADC instance: ADC2.
(3) On STM32L4, parameter available only on ADC instance: ADC3.
(4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.
(5) On STM32L4, parameter available on devices with only 1 ADC instance.
(6) On STM32L4, parameter available on devices with several ADC instances.
(7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)). Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).
(1, 2, 3, 4) For ADC channel read back from ADC register, comparison with internal channel parameter to be done using helper macro __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().

Definition at line 2904 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE uint32_t LL_ADC_GetOffsetLevel ( ADC_TypeDef *  ADCx,
uint32_t  Offsety 
)

Get for the ADC selected offset number 1, 2, 3 or 4: Offset level (offset to be subtracted from the raw converted data).

Note:
Caution: Offset format is dependent to ADC resolution: offset has to be left-aligned on bit 11, the LSB (right bits) are set to 0. OFR1 OFFSET1 LL_ADC_GetOffsetLevel
OFR2 OFFSET2 LL_ADC_GetOffsetLevel
OFR3 OFFSET3 LL_ADC_GetOffsetLevel
OFR4 OFFSET4 LL_ADC_GetOffsetLevel
Parameters:
ADCxADC instance
OffsetyThis parameter can be one of the following values:

  • LL_ADC_OFFSET_1
  • LL_ADC_OFFSET_2
  • LL_ADC_OFFSET_3
  • LL_ADC_OFFSET_4
Return values:
Valuebetween Min_Data=0x000 and Max_Data=0xFFF

Definition at line 2930 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE uint32_t LL_ADC_GetOffsetState ( ADC_TypeDef *  ADCx,
uint32_t  Offsety 
)

Get for the ADC selected offset number 1, 2, 3 or 4: offset state disabled or enabled.

OFR1 OFFSET1_EN LL_ADC_GetOffsetState
OFR2 OFFSET2_EN LL_ADC_GetOffsetState
OFR3 OFFSET3_EN LL_ADC_GetOffsetState
OFR4 OFFSET4_EN LL_ADC_GetOffsetState

Parameters:
ADCxADC instance
OffsetyThis parameter can be one of the following values:

  • LL_ADC_OFFSET_1
  • LL_ADC_OFFSET_2
  • LL_ADC_OFFSET_3
  • LL_ADC_OFFSET_4
Return values:
Returnedvalue can be one of the following values:

  • LL_ADC_OFFSET_DISABLE
  • LL_ADC_OFFSET_ENABLE

Definition at line 2990 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE uint32_t LL_ADC_GetResolution ( ADC_TypeDef *  ADCx )

Get ADC resolution.

Refer to reference manual for alignments formats dependencies to ADC resolutions. CFGR RES LL_ADC_GetResolution

Parameters:
ADCxADC instance
Return values:
Returnedvalue can be one of the following values:

  • LL_ADC_RESOLUTION_12B
  • LL_ADC_RESOLUTION_10B
  • LL_ADC_RESOLUTION_8B
  • LL_ADC_RESOLUTION_6B

Definition at line 2604 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE void LL_ADC_SetCalibrationFactor ( ADC_TypeDef *  ADCx,
uint32_t  SingleDiff,
uint32_t  CalibrationFactor 
)

Set ADC calibration factor in the mode single-ended or differential (for devices with differential mode available).

Note:
This function is intended to set calibration parameters without having to perform a new calibration using LL_ADC_StartCalibration().
For devices with differential mode available: Calibration of offset is specific to each of single-ended and differential modes (calibration factor must be specified for each of these differential modes, if used afterwards and if the application requires their calibration).
In case of setting calibration factors of both modes single ended and differential (parameter LL_ADC_BOTH_SINGLE_DIFF_ENDED): both calibration factors must be concatenated. To perform this processing, use helper macro __LL_ADC_CALIB_FACTOR_SINGLE_DIFF().
On this STM32 serie, setting of this feature is conditioned to ADC state: ADC must be enabled, without calibration on going, without conversion on going on group regular. CALFACT CALFACT_S LL_ADC_SetCalibrationFactor
CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
Parameters:
ADCxADC instance
SingleDiffThis parameter can be one of the following values:

  • LL_ADC_SINGLE_ENDED
  • LL_ADC_DIFFERENTIAL_ENDED
  • LL_ADC_BOTH_SINGLE_DIFF_ENDED
CalibrationFactorValue between Min_Data=0x00 and Max_Data=0x7F
Return values:
None

Definition at line 2538 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE void LL_ADC_SetDataAlignment ( ADC_TypeDef *  ADCx,
uint32_t  DataAlignment 
)

Set ADC conversion data alignment.

Note:
Refer to reference manual for alignments formats dependencies to ADC resolutions.
On this STM32 serie, setting of this feature is conditioned to ADC state: ADC must be disabled or enabled without conversion on going on either groups regular or injected. CFGR ALIGN LL_ADC_SetDataAlignment
Parameters:
ADCxADC instance
DataAlignmentThis parameter can be one of the following values:

  • LL_ADC_DATA_ALIGN_RIGHT
  • LL_ADC_DATA_ALIGN_LEFT
Return values:
None

Definition at line 2624 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE void LL_ADC_SetLowPowerMode ( ADC_TypeDef *  ADCx,
uint32_t  LowPowerMode 
)

Set ADC low power mode.

Note:
Description of ADC low power modes:
  • ADC low power mode "auto wait": Dynamic low power mode, ADC conversions occurrences are limited to the minimum necessary in order to reduce power consumption. New ADC conversion starts only when the previous unitary conversion data (for ADC group regular) or previous sequence conversions data (for ADC group injected) has been retrieved by user software. In the meantime, ADC remains idle: does not performs any other conversion. This mode allows to automatically adapt the ADC conversions triggers to the speed of the software that reads the data. Moreover, this avoids risk of overrun for low frequency applications. How to use this low power mode:
    • Do not use with interruption or DMA since these modes have to clear immediately the EOC flag to free the IRQ vector sequencer.
    • Do use with polling: 1. Start conversion, 2. Later on, when conversion data is needed: poll for end of conversion to ensure that conversion is completed and retrieve ADC conversion data. This will trig another ADC conversion start.
  • ADC low power mode "auto power-off" (feature available on this device if parameter LL_ADC_LP_MODE_AUTOOFF is available): the ADC automatically powers-off after a conversion and automatically wakes up when a new conversion is triggered (with startup time between trigger and start of sampling). This feature can be combined with low power mode "auto wait".
With ADC low power mode "auto wait", the ADC conversion data read is corresponding to previous ADC conversion start, independently of delay during which ADC was idle. Therefore, the ADC conversion data may be outdated: does not correspond to the current voltage level on the selected ADC channel.
On this STM32 serie, setting of this feature is conditioned to ADC state: ADC must be disabled or enabled without conversion on going on either groups regular or injected. CFGR AUTDLY LL_ADC_SetLowPowerMode
Parameters:
ADCxADC instance
LowPowerModeThis parameter can be one of the following values:

  • LL_ADC_LP_MODE_NONE
  • LL_ADC_LP_AUTOWAIT
Return values:
None

Definition at line 2692 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE void LL_ADC_SetOffset ( ADC_TypeDef *  ADCx,
uint32_t  Offsety,
uint32_t  Channel,
uint32_t  OffsetLevel 
)

Set ADC selected offset number 1, 2, 3 or 4.

Note:
This function set the 2 items of offset configuration:
  • ADC channel to which the offset programmed will be applied (independently of channel mapped on ADC group regular or group injected)
  • Offset level (offset to be subtracted from the raw converted data).
Caution: Offset format is dependent to ADC resolution: offset has to be left-aligned on bit 11, the LSB (right bits) are set to 0.
This function enables the offset, by default. It can be forced to disable state using function LL_ADC_SetOffsetState().
If a channel is mapped on several offsets numbers, only the offset with the lowest value is considered for the subtraction.
On this STM32 serie, setting of this feature is conditioned to ADC state: ADC must be disabled or enabled without conversion on going on either groups regular or injected.
On STM32L4, some fast channels are available: fast analog inputs coming from GPIO pads (ADC_IN1..5). OFR1 OFFSET1_CH LL_ADC_SetOffset
OFR1 OFFSET1 LL_ADC_SetOffset
OFR1 OFFSET1_EN LL_ADC_SetOffset
OFR2 OFFSET2_CH LL_ADC_SetOffset
OFR2 OFFSET2 LL_ADC_SetOffset
OFR2 OFFSET2_EN LL_ADC_SetOffset
OFR3 OFFSET3_CH LL_ADC_SetOffset
OFR3 OFFSET3 LL_ADC_SetOffset
OFR3 OFFSET3_EN LL_ADC_SetOffset
OFR4 OFFSET4_CH LL_ADC_SetOffset
OFR4 OFFSET4 LL_ADC_SetOffset
OFR4 OFFSET4_EN LL_ADC_SetOffset
Parameters:
ADCxADC instance
OffsetyThis parameter can be one of the following values:

  • LL_ADC_OFFSET_1
  • LL_ADC_OFFSET_2
  • LL_ADC_OFFSET_3
  • LL_ADC_OFFSET_4
ChannelThis parameter can be one of the following values:

  • LL_ADC_CHANNEL_0
  • LL_ADC_CHANNEL_1 (7)
  • LL_ADC_CHANNEL_2 (7)
  • LL_ADC_CHANNEL_3 (7)
  • LL_ADC_CHANNEL_4 (7)
  • LL_ADC_CHANNEL_5 (7)
  • LL_ADC_CHANNEL_6
  • LL_ADC_CHANNEL_7
  • LL_ADC_CHANNEL_8
  • LL_ADC_CHANNEL_9
  • LL_ADC_CHANNEL_10
  • LL_ADC_CHANNEL_11
  • LL_ADC_CHANNEL_12
  • LL_ADC_CHANNEL_13
  • LL_ADC_CHANNEL_14
  • LL_ADC_CHANNEL_15
  • LL_ADC_CHANNEL_16
  • LL_ADC_CHANNEL_17
  • LL_ADC_CHANNEL_18
  • LL_ADC_CHANNEL_VREFINT (1)
  • LL_ADC_CHANNEL_TEMPSENSOR (4)
  • LL_ADC_CHANNEL_VBAT (4)
  • LL_ADC_CHANNEL_DAC1CH1 (5)
  • LL_ADC_CHANNEL_DAC1CH2 (5)
  • LL_ADC_CHANNEL_DAC1CH1_ADC2 (2)(6)
  • LL_ADC_CHANNEL_DAC1CH2_ADC2 (2)(6)
  • LL_ADC_CHANNEL_DAC1CH1_ADC3 (3)(6)
  • LL_ADC_CHANNEL_DAC1CH2_ADC3 (3)(6)

(1) On STM32L4, parameter available only on ADC instance: ADC1.
(2) On STM32L4, parameter available only on ADC instance: ADC2.
(3) On STM32L4, parameter available only on ADC instance: ADC3.
(4) On STM32L4, parameter available only on ADC instances: ADC1, ADC3.
(5) On STM32L4, parameter available on devices with only 1 ADC instance.
(6) On STM32L4, parameter available on devices with several ADC instances.
(7) On STM32L4, fast channel (0.188 us for 12-bit resolution (ADC conversion rate up to 5.33 Ms/s)). Other channels are slow channels (0.238 us for 12-bit resolution (ADC conversion rate up to 4.21 Ms/s)).

OffsetLevelValue between Min_Data=0x000 and Max_Data=0xFFF
Return values:
None

Definition at line 2825 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE void LL_ADC_SetOffsetState ( ADC_TypeDef *  ADCx,
uint32_t  Offsety,
uint32_t  OffsetState 
)

Set for the ADC selected offset number 1, 2, 3 or 4: force offset state disable or enable without modifying offset channel or offset value.

Note:
This function should be needed only in case of offset to be enabled-disabled dynamically, and should not be needed in other cases: function LL_ADC_SetOffset() automatically enables the offset.
On this STM32 serie, setting of this feature is conditioned to ADC state: ADC must be disabled or enabled without conversion on going on either groups regular or injected. OFR1 OFFSET1_EN LL_ADC_SetOffsetState
OFR2 OFFSET2_EN LL_ADC_SetOffsetState
OFR3 OFFSET3_EN LL_ADC_SetOffsetState
OFR4 OFFSET4_EN LL_ADC_SetOffsetState
Parameters:
ADCxADC instance
OffsetyThis parameter can be one of the following values:

  • LL_ADC_OFFSET_1
  • LL_ADC_OFFSET_2
  • LL_ADC_OFFSET_3
  • LL_ADC_OFFSET_4
OffsetStateThis parameter can be one of the following values:

  • LL_ADC_OFFSET_DISABLE
  • LL_ADC_OFFSET_ENABLE
Return values:
None

Definition at line 2963 of file stm32l4xx_ll_adc.h.

__STATIC_INLINE void LL_ADC_SetResolution ( ADC_TypeDef *  ADCx,
uint32_t  Resolution 
)

Set ADC resolution.

Refer to reference manual for alignments formats dependencies to ADC resolutions.

Note:
On this STM32 serie, setting of this feature is conditioned to ADC state: ADC must be disabled or enabled without conversion on going on either groups regular or injected. CFGR RES LL_ADC_SetResolution
Parameters:
ADCxADC instance
ResolutionThis parameter can be one of the following values:

  • LL_ADC_RESOLUTION_12B
  • LL_ADC_RESOLUTION_10B
  • LL_ADC_RESOLUTION_8B
  • LL_ADC_RESOLUTION_6B
Return values:
None

Definition at line 2587 of file stm32l4xx_ll_adc.h.