AnsweredAssumed Answered

Using periodic timer in MQX

Question asked by Richard Rapier on May 8, 2012
Latest reply on May 25, 2012 by Richard Rapier

I am trying to use the periodic timer in MQX to call back to a function that sets an event every 100ms. I use _timer_start_periodic_every(callbackfunction, NULL, TIMER_KERNEL_TIME_MODE, 100).  It appears to work great for some indeterminate time frame.  At some point, it appears to start running the MQX timer task nonstop, never allowing lower priority tasks that are ready to run to do anything.

 

Ultimately, I'll be setting the time interfval to 1 second, hence the name of the event bit.  I have gone through and disable all other tasks except the Idle task so as to make sure there was no interference from them.  Has anyone seen a similar issue?  Am I doing something wrong in the setup?

 

Here is the code that sets up the timer, and handles it, as well as the call back function.

 

   _timer_start_periodic_every(AnalysisPeriodicNotify, (pointer)NULL, TIMER_KERNEL_TIME_MODE, 100L);

   while (TRUE)
   {
      if (_lwevent_wait_ticks(&analysisEvent, ANALYSIS_ONE_SECOND_BIT, FALSE, 0) == MQX_OK)
      {
         wakeEvents = _lwevent_get_signalled();
         
         if ((wakeEvents & ANALYSIS_ONE_SECOND_BIT) != 0)
         {
            _lwevent_clear(&analysisEvent, ANALYSIS_ONE_SECOND_BIT);
            AnalysisPeriodicHandler();
         }
      }
   }
}

 

static void AnalysisPeriodicNotify( _timer_id timer_id, pointer dummyPtr, uint_32 seconds, uint_32 milliseconds )
{
   (void)dummyPtr;
  
   _lwevent_set(&analysisEvent, ANALYSIS_ONE_SECOND_BIT);
}

 


Thanks in advance,

RIchard

Outcomes