cancel
Showing results for 
Search instead for 
Did you mean: 

Timer PWM and Counter question

barry
Associate II
Posted on December 31, 2014 at 16:53

I am using an STM32F407

I want to generate exactly 400 pulses on PE5 or PE6 with a 50% duty cycle.

I believe PE5 can be connected to TIM9 CH1, and PE6 can be connected to TIM9 CH2

I have the PWM code running and I have located the TIM Base/ counter example.

Questions

Do I need to use an interrupt or can I just load a counter with 400 and let it count down to zero and stop?

Can I do this with one timer or do I need two timers?

If I need two timers how do I synchronize them so I can get exactly 400 pulses?

Thanks and Happy New Year.

Barry

#tim-counter
1 REPLY 1
Posted on December 31, 2014 at 18:17

Not sure if TIM9 has a ''Repetition Count'', but even so those are only 8-bit wide.

If the frequency isn't too high you should be able to count off 400 updates and turn the pulse(s) off easily enough.

With one timer you can output two phase aligned output of the same period, but differing duty, if you want something more complicated than that then you'll need more than one timer.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..