I have a project where I need to send an impulse to a relay. If the XBee module receives a valid command, a relay will be triggered for 125ms. For this purpose I wanted to use the High Resolution Timer (ONE_SHOT).
So I:
- Configured my timer accordingly:
timer_config(relayTimer, FALSE, ONE_SHOT, 125000);
(this call returned 0 to indicate success)
- I tried to enable the timer when needed:
timer_enable(relayTimer, TRUE);
But nothing happened!? Interestingly, the API for timer_enable doesn’t return anything so I can’t tell if the timer was enabled correctly.
If I configure the timer to start immediately, it works as expected. I also tried to start a periodic timer with individual calls:
timer_set_timeout(relayTimer, 125000);
timer_set_mode(relayTimer, PERIODIC);
timer_irq_enable(relayTimer, TRUE);
timer_enable(relayTimer, TRUE);
But this didn’t work either… So… should it work? False expectations? Something wrong on my end? I have no issues calling the timer_config() to start immediately but I keep wondering why can’t I start a configured timer that’s disabled?
API Reference: http://exsilium.github.io/xbee-sdk-doc/group__api__timer.html