2014-02-13 05:11 AM
Hi all,
I'm using stm32f100c8 with an external oscillator 8MHz to produce a system clock of 24MHz. All the peripherals are on the default division lines.Now the ADC1 which is with the TIM1 on PCLK2 is supposed to read the battery value which reaches 9v.The battery value is an output from a voltage divider, the following picture, the bottom is connected to the ground. The adc reads from the junction between the two resistors.The problem is it doesn't read correct. If the value is 9v, it reads about 8 or 7.8 and that's when I'm dividing the ADC prescaler by 8 and using the maximum sampling time 239.5The problem was solved when I divide the PCLK2 by 4 but that affected the frequency of TIM1 too.The question is, Is there any other to make the adc reads correctly without the need to change the frequency of the PCLK2??Thanks2014-02-13 05:53 AM
Hi !
I believe that your problem lies in the choice of the resistors' values. In order to work correctly, the sampling capacitor of the ADC should charge quickly enough. There should be somewhere in one the manuals (device datasheet or STM32F1xx manual) the maximum impedance allowed to ensure a correct conversion value. Here you have used several megohms of resistance to limit the discharge of the battery, but just replacing megohms with kilo-ohms should give accurate results without sacrificing the conversion time. If you really don't want to discharge the battery with the resistor bridge, you could add a P-MOS to switch on the bridge when reading the battery voltage.Have a nice day,Kraal