I configured the ADC of my STM32L051C8 (Revision Z) to measure temperature. I saw in the errata sheet DM00114897 that there are issues if there is a time greater than 0.5ms between two measurement.
How ever, my first conversion always brought up a bad value. Allowing settling time (after configuration) of 5ms improved the result. Waiting for 10ms solved the Problem. The datasheet states, that the Maximum settling time would be 3ms.
Could that be an other error in the Hardware?
Here's my config (I use HSI16 on 16MHz, Voltage Range 2):
ADC1->CFGR2 |= ADC_CLOCKPRESCALER_PCLK_DIV1;
ADC1->CFGR1 &= ~ADC_CFGR1_CONT;
ADC1->CHSELR = ADC_CHSELR_CHSEL18;
ADC1->SMPR |= ADC_SAMPLETIME_239CYCLES_5;
ADC->CCR |= ADC_CCR_TSEN;
SYSCFG->CFGR3 |= SYSCFG_CFGR3_ENBUF_SENSOR_ADC | SYSCFG_CFGR3_EN_VREFINT;
... wait until SYSCFG_CFGR3_SENSOR_ADC_RDYF is cleared
Currently I just discard the first value.
Any hints are appreciated.