cancel
Showing results for 
Search instead for 
Did you mean: 

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?

RSimp
Associate II
 
4 REPLIES 4
TDK
Guru

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".

> GPIO->ODR register

Why not IDR?

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

JW

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
Associate II

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.