cancel
Showing results for 
Search instead for 
Did you mean: 

TimeBase example in stm32f3discovery_fw

andreaspiezia9
Associate III
Posted on October 17, 2013 at 12:23

Hi all,

the TimeBase example in stm32f3discovery_fw reports the next code in main.c file:

CCR1_Val = 40961;

TIM_TimeBaseStructure.TIM_Period = 65535;

TIMx->ARR = TIM_TimeBaseInitStruct->TIM_Period ;

What I really don't understand is the comment reported below: 

CC1 update rate = TIM3 counter clock / CCR1_Val = 1757.77 Hz

==> Toggling frequency = 878.88 Hz

Can someone help me?

Thanks and regards

                                              

#stm32f3discovery_fw-stm32-timer
2 REPLIES 2
Posted on October 17, 2013 at 13:36

If it's the example I think it is, the 65535 is the maximal setting for the timer, the CCR1 value is advanced at each CC1 interrupt (see stm32f4xx_it.c), allowing each timer to generate multiple frequencies.

Toggling doubles the period, and thus halves the frequency.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andreaspiezia9
Associate III
Posted on October 18, 2013 at 09:07

Thank you Clive1