cancel
Showing results for 
Search instead for 
Did you mean: 

How to output a fixed number of PWM cycles on STM32F4

eigenroot
Associate II
Posted on October 06, 2015 at 07:44

In my application, I have a timer generating periodic interrupts. In its ISR a certain number of PWM cycles needs to be generated on a GPIO pin. I first use another timer to time the duration, but it is not very deterministic since the PWM termination is influenced by other events, and it can end up in logic high sometimes. I can also do some integer counting in main() function, but it is less efficient. Is there a simple and efficient way of doing this? 

#stm32f4 #discovery #timers
1 REPLY 1
Posted on October 06, 2015 at 09:54

The second ''supervising'' timer might trigger a DMA transfer into the first's register(s) which would set the first to inactive.

To avoid hazard, you could set ARR to 0 and use shadowing.

JW