6 years, 4 months ago.

timer measurement error? STM32L152

I am using the timer.read_us() to measure the time for a give routine. I tried to verify the result with a oscilloscope, but get a pretty larger different. On two different oscilloscopes I measure 5.5 ms for a routine. With reading the time I get about 4.5 ms. I am sure there is some register somewhere to correct this, but I using generic mbed code. Any ideas would be appreciated.

1 Answer

6 years, 4 months ago.

The STM boards are running out of the internal oscillator. If you need a more precise timing source, you have to add a external crystal. See http://mbed.org/users/dreschpe/code/ST_401_84MHZ/ for picture. The newer mbed lib will detect this and use it : http://mbed.org/teams/ST/wiki/Automatic-clock-configuration

While thats true, his error is way too large, thats a 20% error, while according to the datasheet the absolute maximum error over both voltage and temperature range at the same of the HSI is -4% till +3%.

posted by Erik - 10 Sep 2014