I want to implement the transceiving part of an IR protocol for my Samsung remote on an nRF54822, using an ARM Cortex M0 core. The protocol is very much like the NEC Protocol, and is using a carrier frequency of 38kHz with bursts of the carrier frequency in different time periods to indicate logical '1's and '0's.

Example: 38kHz ON for 540µs, signal OFF for 1.7ms, signal ON for 540µs.

If I use two timers this should be fairly trivial. One timer to keep the 38kHz carrier frequency active at all times, and the other to keep track of when to set the output of timer one at the IR LED. But what if I am using only one timer? I am able to trigger timer clear (count from zero) and timer stop at value Compare. I can also trigger toggle, set and clear on GPIO at compare.

Any ideas on how I can achieve this?

  • \$\begingroup\$ You can re-configure timer in Timer ISR... So, First it will trigger after 540usec, in that ISR, change timer value to 1.7msec and so on \$\endgroup\$
    – Swanand
    Jul 9, 2013 at 8:53

1 Answer 1


I have a simple non-preemptive RTOS that uses only one hardware timer, so: YES, of course you can do that with one timer.

Just configure that one timer to keep track of time, and you can at appropriate points in your software wait until the proper time has arrived to do the next thing.

A minor inconvenience can arise when your timer rolls over, but assuming you inspect the timer often enough you can maintain an extension of the timer and increment this extension whenever the current timer value is lower than the previous one.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.