cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L471RGT6 ADC Calibration

rwils.1
Associate III

Hi ,

 Is there an automatic calibration routine for the STM32L471RGT6 ADC? If there isn't can someone point me to example code on how to read the internal reference (or some other approach) so I can write code to perform calibration. 

Thank you very much 

Richard

12 REPLIES 12
rwils.1
Associate III

TDK,

 Fixed!. As these problems always are it is simple once you know. When the ADC takes a reading, it charges an internal capacitor from voltage present on the pin. The output of the op-amp driving the pin drooped during this period. So where I thought I was measuring a stable DC voltage, I wasn't, I was sampling during the charge time. Once I realized this I changed the delay to the maximum time and everything works as expected. 

         ADC_ChannelConfTypeDef sConfig = {0};

         sConfig.Channel = ADC_CHANNEL_12;

         sConfig.Rank = ADC_REGULAR_RANK_1;

--->    //sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;

         sConfig.SamplingTime = ADC_SAMPLETIME_640CYCLES_5;

         sConfig.SingleDiff = ADC_SINGLE_ENDED;

         sConfig.OffsetNumber = ADC_OFFSET_NONE;

         sConfig.Offset = 0;

         if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)

         {

           Error_Handler();

         }

Pretty simple once you know! Thanks for your help

 

Richard

 

 

raptorhal2
Lead

Since an opamp is the signal source, you will probably still find joy at much lower sample cycles. The ADC section in the data sheet should provide the info needed.

Thank you very much, I'll investigate.