Skip to main content
RSimp
Associate II
September 30, 2020
Question

On a NUCLEO-64-F030R8 STM32 Cube I am using Tim3 in toggle mode with variable ARR to output variable pulse widths on PA6. How can I know whether the Timer Int is happening on a digital HI or LOW edge?

  • September 30, 2020
  • 4 replies
  • 1108 views

..

This topic has been closed for replies.

4 replies

TDK
September 30, 2020

It depends which timer interrupt you're referring to and how your pulse is configured. They happen at different times and an inverted pulse will give opposite results.

 

As a quick check, you could simple read the value of the pin in the interrupt.

Oh, in toggle mode you just need to read the value of the pin. GPIO->ODR register.

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
October 1, 2020

> GPIO->ODR register

Why not IDR?

Also, why toggle mode, how is it better than PWM?

JW

TDK
October 1, 2020
Yeah IDR is probably better here.
I've used toggle mode quite a bit when I need to synchronize events between timers. Although it doesn't seem optimal for generating variable PWMs.
"If you feel a post has answered your question, please click ""Accept as Solution""."
RSimp
RSimpAuthor
Associate II
October 8, 2020

Thanks for the feedback, as this is a new environment for me. I will look into the IDR mode, though I don't remember seeing it. Yes, I see where I can read the pin status, and simply exit the interrupt on one phase and process a new ARR value on the other. I just double the speed of the timer. It seems the low overhead for interrupt service in the ARM is really beneficial in that regard.