Skip to content

Commit a3baf2d

Browse files
committed
Add more comment on the modified line
1 parent 2ae7489 commit a3baf2d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

targets/TARGET_STM/TARGET_STM32F4/analogin_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ static inline uint16_t adc_read(analogin_t *obj)
183183
return 0;
184184
}
185185

186-
ADC->CCR &= ~(ADC_CCR_VBATE | ADC_CCR_TSVREFE); // Workaround
186+
// Measuring VBAT sets the ADC_CCR_VBATE bit in ADC->CCR, and there is not
187+
// possibility with the ST HAL driver to clear it. If it isn't cleared,
188+
// VBAT remains connected to the ADC channel in preference to temperature,
189+
// so VBAT readings are returned in place of temperature.
190+
ADC->CCR &= ~(ADC_CCR_VBATE | ADC_CCR_TSVREFE);
191+
187192
HAL_ADC_ConfigChannel(&AdcHandle, &sConfig);
188193

189194
HAL_ADC_Start(&AdcHandle); // Start conversion

0 commit comments

Comments
 (0)