Skip to main content
eigenroot
Associate II
October 6, 2015
Question

How to output a fixed number of PWM cycles on STM32F4

  • October 6, 2015
  • 1 reply
  • 632 views
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
This topic has been closed for replies.

1 reply

waclawek.jan
Super User
October 6, 2015
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