From 7ede0c9862da50fd31a6206d64b221b9c0b89b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Thu, 11 Mar 2021 10:59:54 +0100 Subject: [PATCH] application: fix voltage caculation --- application.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application.c b/application.c index f062e93..47a4398 100644 --- a/application.c +++ b/application.c @@ -119,8 +119,9 @@ static float* measure_voltages(void) adc_start_conversion_regular(ADC1); // start conversion (using trigger) while (!adc_eoc(ADC1)); // wait until conversion finished adc_values[i] = adc_read_regular(ADC1); // read voltage value (clears flag) - voltages[i] = adc_values[i] * 1.21 / adc_values[0] * 2; // use 1.21 V internal voltage reference to get ADC voltage (there is a /2 voltage divider) + voltages[i] = adc_values[i] * 1.21 / adc_values[0]; // use 1.21 V internal voltage reference to get ADC voltage } + voltages[1] *= 2.0; // the is a /2 voltage divider for target voltage return voltages; }