STM32L486xx HAL User Manual
Functions
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
Reference Manual to LL API cross reference:
CALFACT CALFACT_S LL_ADC_GetCalibrationFactor
CALFACT CALFACT_D LL_ADC_GetCalibrationFactor
Parameters:
ADCxADC instance
SingleDiffThis parameter can be one of the following values:
Return values:
Valuebetween Min_Data=0x00 and Max_Data=0x7F

Definition at line 2618 of file stm32l4xx_ll_adc.h.

References ADC_SINGLEDIFF_CALIB_FACTOR_MASK.

__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.
Reference Manual to LL API cross reference:
CFGR ALIGN LL_ADC_GetDataAlignment
Parameters:
ADCxADC instance
Return values:
Returnedvalue can be one of the following values:

Definition at line 2700 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.
Reference Manual to LL API cross reference:
CFGR AUTDLY LL_ADC_GetLowPowerMode
Parameters:
ADCxADC instance
Return values:
Returnedvalue can be one of the following values:

Definition at line 2801 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).
Reference Manual to LL API cross reference:
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:
Return values:
Returnedvalue can be one of the following values: (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 2965 of file stm32l4xx_ll_adc.h.

References __ADC_PTR_REG_OFFSET.

Referenced by HAL_ADC_ConfigChannel(), and HAL_ADCEx_InjectedConfigChannel().

__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.
Reference Manual to LL API cross reference:
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:
Return values:
Valuebetween Min_Data=0x000 and Max_Data=0xFFF

Definition at line 2991 of file stm32l4xx_ll_adc.h.

References __ADC_PTR_REG_OFFSET.

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

Reference Manual to LL API cross reference:
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:
Return values:
Returnedvalue can be one of the following values:

Definition at line 3051 of file stm32l4xx_ll_adc.h.

References __ADC_PTR_REG_OFFSET.

__STATIC_INLINE uint32_t LL_ADC_GetResolution ( ADC_TypeDef *  ADCx)

Get ADC resolution.

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

Reference Manual to LL API cross reference:
CFGR RES LL_ADC_GetResolution
Parameters:
ADCxADC instance
Return values:
Returnedvalue can be one of the following values:

Definition at line 2665 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.
Reference Manual to LL API cross reference:
CALFACT CALFACT_S LL_ADC_SetCalibrationFactor
CALFACT CALFACT_D LL_ADC_SetCalibrationFactor
Parameters:
ADCxADC instance
SingleDiffThis parameter can be one of the following values:
CalibrationFactorValue between Min_Data=0x00 and Max_Data=0x7F
Return values:
None

Definition at line 2589 of file stm32l4xx_ll_adc.h.

References ADC_SINGLEDIFF_CALIB_FACTOR_MASK.

__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.
Reference Manual to LL API cross reference:
CFGR ALIGN LL_ADC_SetDataAlignment
Parameters:
ADCxADC instance
DataAlignmentThis parameter can be one of the following values:
Return values:
None

Definition at line 2685 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.
Reference Manual to LL API cross reference:
CFGR AUTDLY LL_ADC_SetLowPowerMode
Parameters:
ADCxADC instance
LowPowerModeThis parameter can be one of the following values:
Return values:
None

Definition at line 2753 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).
Reference Manual to LL API cross reference:
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:
ChannelThis parameter can be one of the following values: (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 2886 of file stm32l4xx_ll_adc.h.

References __ADC_PTR_REG_OFFSET, and ADC_CHANNEL_ID_NUMBER_MASK.

Referenced by HAL_ADC_ConfigChannel(), and HAL_ADCEx_InjectedConfigChannel().

__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.
Reference Manual to LL API cross reference:
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:
OffsetStateThis parameter can be one of the following values:
Return values:
None

Definition at line 3024 of file stm32l4xx_ll_adc.h.

Referenced by HAL_ADC_ConfigChannel(), and HAL_ADCEx_InjectedConfigChannel().

__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.
Reference Manual to LL API cross reference:
CFGR RES LL_ADC_SetResolution
Parameters:
ADCxADC instance
ResolutionThis parameter can be one of the following values:
Return values:
None

Definition at line 2648 of file stm32l4xx_ll_adc.h.