diff options
-rw-r--r-- | stmhal/adc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/stmhal/adc.c b/stmhal/adc.c index 4e0ec46a9a..a59543710b 100644 --- a/stmhal/adc.c +++ b/stmhal/adc.c @@ -353,7 +353,8 @@ float adc_read_core_vbat(ADC_HandleTypeDef *adcHandle) { // be 12-bits. raw_value <<= (12 - adc_get_resolution(adcHandle)); - return raw_value * VBAT_DIV / 4096.0f * 3.3f; + // multiplier is 3.3/4095 + return raw_value * VBAT_DIV * 0.8058608058608059e-3f; } float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) { @@ -363,7 +364,8 @@ float adc_read_core_vref(ADC_HandleTypeDef *adcHandle) { // be 12-bits. raw_value <<= (12 - adc_get_resolution(adcHandle)); - return raw_value / 4096.0f * 3.3f; + // multiplier is 3.3/4095 + return raw_value * 0.8058608058608059e-3f; } #endif |