Using periodic timer in MQX

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Using periodic timer in MQX

ソリューションへジャンプ
8,845件の閲覧回数
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,199件の閲覧回数
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 返答(返信)
698件の閲覧回数
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,200件の閲覧回数
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 件の賞賛
返信
698件の閲覧回数
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 件の賞賛
返信
698件の閲覧回数
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 件の賞賛
返信