2015-02-24 08:23 AM
I have an input signal of 0.2V that I want to digitize; questions:
2015-04-27 03:08 AM
Hi,
From memory.... The bandgap on the STM8 I think is outputting 1. So assuming your VDD is 3.3, 1.25V is 87% of VDD. In ADC counts this is 15 Obviously this value will then move up and down depending on supply voltage. On the STM32 there is a calibration register for the bandgap, so: adc_result = adc_meas * cal_bandgap_reg / bandgap_meas; However I am not sure it's on the STM8. So I assume a constant based on a 3.3V rail:#define BANDGAP_REF 1550
uint16_t adc_res;
uint32_t tmp32;
/* Multiply the ADC measurement by the bandgap reference. */
tmp32 = adc_meas * BANDGAP_REF;
/* Divide the result by the measured bandgap value. */
adc_res = tmp32 / adc_bandgap;
Cheers,
Martin.