2023-12-01 06:54 AM
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
2023-12-06 09:17 AM
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
2023-12-06 09:42 AM
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.
2023-12-06 11:58 AM
Thank you very much, I'll investigate.