Skip to main content
Visitor II
February 14, 2025
Question

LL_ADC_GetChannelSamplingTime returns incorrect value

  • February 14, 2025
  • 1 reply
  • 450 views

Hi, 

I am using  LL_ADC_GetChannelSamplingTime() to obtain the sampling time of a specific channel but in some cases the return value seems to be incorrect.  In my specific case the SMPR register has the value 0x00008046 and I call the function with channel = LL_ADC_CHANNEL_6. The function then returns 0xFFFFFE08 but I expect  0x00 (ADC_SAMPLINGTIME_COMMON_1) . 

After having a deeper look, it seems that smp_channel_posbit0 is not calculated correctly in this case. Can you confirm this?


I am using STM32CubeMX 6.13.0 + STM32CubeU0 Firmware Package V1.2.0 and the ADC configuration  is as follows:

 

 

 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV1;
 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 hadc1.Init.LowPowerAutoWait = DISABLE;
 hadc1.Init.LowPowerAutoPowerOff = DISABLE;
 hadc1.Init.ContinuousConvMode = ENABLE;
 hadc1.Init.NbrOfConversion = 1;
 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc1.Init.DMAContinuousRequests = DISABLE;
 hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
 hadc1.Init.SamplingTimeCommon1 = ADC_SAMPLETIME_79CYCLES_5;
 hadc1.Init.SamplingTimeCommon2 = ADC_SAMPLETIME_19CYCLES_5;
 hadc1.Init.OversamplingMode = DISABLE;
 hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH;

 

 

This topic has been closed for replies.

1 reply

Joe WILLIAMS
ST Employee
February 15, 2025

Hi FlokRo

This post has been escalated to the ST Online Support Team for additional assistance.  We'll contact you directly.

Regards

Joe

STMicro Support