cancel
Showing results for 
Search instead for 
Did you mean: 

LL_ADC_GetChannelSamplingTime returns incorrect value

FlokRo
Associate

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;

 

 

0 REPLIES 0