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
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
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
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