cancel
Showing results for 
Search instead for 
Did you mean: 

ADC frequency

sherif
Associate II
Posted on February 13, 2014 at 14:11

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. 

0690X00000602rGQAQ.jpg

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.5

The 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??

Thanks
1 REPLY 1
Kraal
Senior III
Posted on February 13, 2014 at 14:53

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