Skip to content

Commit 1252221

Browse files
committed
STM32L0 internal channel ADC_TEMP
Temperature measurement was not stable
1 parent 5bbe628 commit 1252221

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

targets/TARGET_STM/TARGET_STM32L0/analogin_device.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ uint16_t adc_read(analogin_t *obj)
172172

173173
HAL_ADC_ConfigChannel(&obj->handle, &sConfig);
174174

175+
/* need to wait for some stabilization time after setting the TSEN bit in the ADC_CCR
176+
register to wake up the temperature sensor from power down mode */
177+
if (sConfig.Channel == ADC_CHANNEL_TEMPSENSOR) {
178+
wait_ms(20);
179+
}
180+
175181
HAL_ADC_Start(&obj->handle); // Start conversion
176182

177183
// Wait end of conversion and get value

0 commit comments

Comments
 (0)