cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407, Timer6 running 2x too fast (SOLVED)

kk6gm
Associate II
Posted on September 12, 2014 at 09:12

I'm reluctant to post this because I figure it's operator error, but I'm stuck.  I'm running an STM32F407 Discovery board using AdaCore's Ada2012 release.  Simple tasks seem to run correctly, and at the correct speed, but I'm trying to configure Timer6 to give 2.5ms interrupts, and it seems to run at double the expected speed.

I've confirmed that the runtime is setting RCC_CFGR.PPRE1 to b101 (divide by 4).  I'm setting Timer6 PSC to 42-1 and ARR to 2500-1 to give a period of 2.5ms, but when I count 400 overflows I only get 1/2 second, not 1 second as expected.  I'm just counting and resetting the SR.UIF flag at this point.  What am I missing?

EDIT: OK, I'm missing the TIMPRE bit!  Now I see where the x2 comes in.  I'll post this anyway in case it can help somebody else.

Mike

2 REPLIES 2
Posted on September 12, 2014 at 09:35

TIMPRE is present only in  STM32F42x and STM32F43x. In the STM32F40x/41x the ''timers-tick-twice-as-fast-if-APB-prescaler-is-not-1'' feature is fixed.

The manual is badly written, and the timers' chapters are one of the worst of it. All peripherals' chapters are written from an isolated point of view of an IP module stuck somehow to the SoC,  but this particular issue is an example how a small piece information originating from a different module could help avoiding unnecessary confusion.

JW
kk6gm
Associate II
Posted on September 12, 2014 at 16:27

OK, thanks for the clarification.

Mike