Proper / MQX Way To Pause A Timer (MQX 3.8.0 - MPC-5125)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Proper / MQX Way To Pause A Timer (MQX 3.8.0 - MPC-5125)

675 Views
Tim562
Senior Contributor I

Hi All,

Can anyone tell me the correct way to temporarily pause a timer? I have a 100mS timer running that I created using MQX as follows:

lError = _timer_create_component(3, 1024);

timer_100ms = _timer_start_periodic_every(INT_100msTimer, 0, TIMER_ELAPSED_TIME_MODE, 100);

It works great but I have occasional need to pause it while I manipulate some data object in main task that may also be referenced in the timer interrupt. I could just use a global variable that I set in main task (or a mutex I suppose) that would cause the timer interrupt service routine to exit without doing anything but that's not a very good solution IMO. I could probably also disable then re-enable the processor interrupt directly (once I figure out which timer MQX used) but I'm wondering if MQX has a way to do this (didn't see one in the RTOS Reference Manual Rev 3).  I'm using an MPC-5125 processor with MQX 3.8.0. Thanks!

~Tim


Tags (3)
2 Replies

452 Views
c0170
Senior Contributor III

Hello,

timer initialization is in init_bsp code file. It starts on the 245th line:

#ifdef BSPCFG_TIMER_GPT_CHANNEL

     /* GPT */

#else

  /* decrementer */

#endif

I would go for synchronization objects, like you mention. Stay away from global variables in RTOS Neither disable interrupts for system ticks.

I checked the timer API but did not find any function to pause a timer. It just ticks and notifies kernel about an event.

Regards,

c0170

453 Views
Tim562
Senior Contributor I

Thanks for your reply Martin, I agree with what you said and think your advice is good. If I do find a safe/convenient way to temporarily halt the proper timer using the processor registers directly I'll post it here. Cheers!

~Tim