cancel
Showing results for 
Search instead for 
Did you mean: 

Slow timer with pulse

crthorne
Associate
Posted on October 19, 2009 at 22:55

Slow timer with pulse

2 REPLIES 2
crthorne
Associate
Posted on May 17, 2011 at 13:26

I need to use a timer on the STM3210E-EVAL card to produce a signal with a 480 Hz repetition rate. I need the signal to be normally high and go low for a period (anything between 1 microsecond and 1/480 Hz is OK) every 480Hz.

I would prefer to use Timer2 CH2 on PA1.

Can anyone give me some guidance?

Thanks

tomas23
Associate II
Posted on May 17, 2011 at 13:26

Hi, look at library examples about the timers, this is clearly the PWM mode. Please check the Reference Manual, too, for the timer description.

In general, you have to know your TIM_CK freq. (72 MHz?), the period (=2.08333 ms) and resolution 1 us?)

You can see that in one period you have 150 000 ticks of timer. While timer has 16 bits only, I recommend to apply divider 3 (you get 50 000 ticks per period) and the PWM resolution will be in multiple tens of nanoseconds.

To port the code from TIM1 to TIM2, you need to modify the GPIO pins used in the examples.