Using periodic timer in MQX

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Using periodic timer in MQX

跳至解决方案
8,836 次查看
RichardR
Contributor IV

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

0 项奖励
回复
1 解答
5,190 次查看
RichardR
Contributor IV

It looks like the problem we were having is one that has been reported, and was corrected in MQX 3.8, it appears to be the issue with PendSV described in the post I linked to below

 

https://community.freescale.com/thread/96384

在原帖中查看解决方案

0 项奖励
回复
24 回复数
697 次查看
DavidS
NXP Employee
NXP Employee

Hi Richard,

Thank you for your due dilegence and reporting on your efforts.

I will pass them along to our MQX development team for review.

The RTOS uses priorities 0-8 for various things (Ethernet, USB, MFS, kernel, etc.) so having the periodic timer task at a high priority might have been blocking something else in the RTOS from running causing the issue.

I looked up the USB priority and it is set to 8 which kind of implies that the timer task and the USB will round robin and not block each other.

When I get additional information I'll update this post.

Best Regards,

David

0 项奖励
回复
5,191 次查看
RichardR
Contributor IV

It looks like the problem we were having is one that has been reported, and was corrected in MQX 3.8, it appears to be the issue with PendSV described in the post I linked to below

 

https://community.freescale.com/thread/96384

0 项奖励
回复
697 次查看
MarkP_
Contributor V

I used lwtimers in MQX3.7, they worked OK.

Functions to use: _lwtimer_create_periodic_queue and _lwtimer_add_timer_to_queue.

~Mark

0 项奖励
回复
697 次查看
RichardR
Contributor IV

Ran it overnight without the _timer_start, no problems.  It does not do what I need it to do timing wise, but I think I can conclusively say that the issue is with the MQX timer task.  If it matters, K60 is the target processor.

0 项奖励
回复