Interrupt Timer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey support,
I'm trying to implement a timer interrupt to my Thread application. Would LPTMR be the easiest to use to accomplish the following? Or would something else be easier?
- An event from one R41Z triggers a function to send a High signal to another R41Z with a motor wired to it. I'd like for this High signal to elapse about 30-35 seconds. After the time has elapsed it would then send the Low signal function to stop the motor.
Any pointers or available references would be helpful. Thanks!


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ‌,
The easiest way is to use TimersManager module (see TimersManager.c, TimersMnager.h) files.
As API the following functions should be used:
- TMR_AllocateTimer - to allocate the timer;
- TMR_StartSingleShotTimer - to start the timer;
- TMR_FreeTimer - to free the timer;
An example of usage is usually presented in each demo application. Please search in your project after "mAppTimerId" or "tmrStartApp".
Regards,
Ovidiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Ovi!
After analyzing the example, here's what I was able to get working. I tested it using an LED turning on for 10 seconds before turning off. Posting code for reference.
/*==================================================================================================
Private macros
==================================================================================================*/
.
.
.
#define gLedTimeout_c 10000 /* milliseconds */
/*==================================================================================================
Public global variables declarations
==================================================================================================*/
.
.
.
/* Led timer Id */
tmrTimerID_t mLedTimerId = gTmrInvalidTimerID_c;
/*==================================================================================================
Public functions
==================================================================================================*/
.
.
.
void APP_LightShellEventReceived(void)
{
if(isLedOn)
{
(void)NWKU_SendMsg(APP_SendExtLedOff, NULL, mpAppThreadMsgQueue);
isLedOn = FALSE;
}
else{
(void)NWKU_SendMsg(APP_SendExtLedOn, NULL, mpAppThreadMsgQueue);
isLedOn = TRUE;
if(mLedTimerId == gTmrInvalidTimerID_c)
{
mLedTimerId = TMR_AllocateTimer();
}
/* Validate Led timer Id */
if(mLedTimerId != gTmrInvalidTimerID_c)
{
/* Start the led timer. Wait gLedTimeout_c
to start countdown before turning off led. */
TMR_StartSingleShotTimer(mLedTimerId, gLedTimeout_c, APP_SendExtLedOff, NULL);
}
}
