STM32F4 - Clear VBATE and TSVREFE bits before configuring ADC channels

pull/3467/head
bcostm 2016-11-21 13:07:26 +01:00 committed by Anna Bridge
parent 65fc32fe11
commit 41b8eda589
1 changed files with 2 additions and 1 deletions

View File

@ -183,13 +183,14 @@ static inline uint16_t adc_read(analogin_t *obj)
return 0;
}
ADC->CCR &= ~(ADC_CCR_VBATE | ADC_CCR_TSVREFE); // Workaround
HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);
HAL_ADC_Start(&AdcHandle); // Start conversion
// Wait end of conversion and get value
if (HAL_ADC_PollForConversion(&AdcHandle, 10) == HAL_OK) {
return (HAL_ADC_GetValue(&AdcHandle));
return (uint16_t)HAL_ADC_GetValue(&AdcHandle);
} else {
return 0;
}