Solved
This topic has been closed for replies.
Yes, it's possible.
Using interrupts:
- Set up the timer channel as described in the PWM mode section of the reference manual, Enable the update interrupt in DIER.
- The interrupts will be coming fast, so don't waste much time in the interrupt handler. Clear the SR register, increment a counter, rewrite ARR and CCR1 when the counter reaches the frequency value. Don't use any HAL functions, there are too slow.
Using the other timer as a 1s timebase:
- Set up the timer generating the PWM signal like above, but don't request interrupts.
- Set up the other timer to generate an interrupt once every second.
- Starting the timers is a bit tricky, because there is no hardware synchronization between them, so:
- disable interrupts
- start the first timer (the one doing the PWM)
- start the other timer (which generates the interrupt)
- enable interrupts
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
