HardwareTimer: set pin output to low after pausing the timer #2863
-
|
I use hardware timers and on one pin I toggle a LED and at some point I want it to stop blinking and just be off. Now I simply do What would be the "official" way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
|
How you toggle it? With digitalWrite in the timer callback? If yes then using digitalWrite low seems the best option |
Beta Was this translation helpful? Give feedback.
-
|
No, I toggle it using the timer functionality: |
Beta Was this translation helpful? Give feedback.
-
|
a not very elegant workaround: only possible because timing is not critical at all |
Beta Was this translation helpful? Give feedback.
Hi @PerennialNovice
I found the correct way to do this.
In fact you don't need to pause the timer.
Simpy change the mode to
MyTim->setMode(2, TIMER_OUTPUT_COMPARE_FORCED_INACTIVE, redLEDPin);Then to restore:
MyTim->setMode(2, TIMER_OUTPUT_COMPARE_TOGGLE, redLEDPin);