application: fix voltage caculation

This commit is contained in:
King Kévin 2021-03-11 10:59:54 +01:00
parent 468f199d22
commit 7ede0c9862
1 changed files with 2 additions and 1 deletions

View File

@ -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;
}