xTimerResetFromISR do not restart the timer period properly

sminder wrote on Wednesday, June 25, 2014:

I use the a periodical software timer that has period of 25 ms. Also I have an asynchronous interrupts which have to restart period of my timer (after the interrupt the next timer callback expected after 25 ms). But I have a problem: after the interrupt the next timer callback occur after random time, not my expected value (25 ms). What is wrong?

Code sample for restart timer (in the interrupt) follow:
void rtosStartDataPrdTimer()
{
portBASE_TYPE xHigherPriorityTaskWoken = pdTRUE;

xTimerResetFromISR(rtos_timers[xDataPrdInterval], &xHigherPriorityTaskWoken);

}

rtel wrote on Wednesday, June 25, 2014:

Have you tried using the xHigherPriorityTaskWoken parameter to ensure the timer task runs straight away if reseting the timer resulted in the timer task becoming the higher priority ready task? You do that calling either portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) or portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ) (depending on the port you are using) before exiting the ISR.

Did you check the return value of xTimerResetFromISR() to ensure the call was successful?

Regards.

sminder wrote on Friday, June 27, 2014:

Absolutely, I check the return value of the xTimerResetFromISR() and it looks good. Since I use an ARM port of the FreeRTOS should I use the portYIELD_WITHIN_API() function?

rtel wrote on Friday, June 27, 2014:

Well FreeRTOS supports 8 different ‘ARM’ architectures, but on all of them portYIELD_WITHIN_API() should not be used. It is not part of the published API, and not intended for use by application writers.

You could use portYIELD_FROM_ISR(). That would ensure any task unblocked by the ISR would get a chance to run immediately that the ISR returns (the ISR would return to it, rather than the interrupted task) if the unblocked task has a priority higher than or equal to the currently running task.

Regards.

sminder wrote on Friday, June 27, 2014:

Sorry for an inaccurate information. My chip is ATSAM4L (ARM Cortex-M4 core) but I didn’t find the portYIELD_FROM_ISR() macro in my RTOS sources (I’ve got a 7.4.2 version). Where can I get this macro for my chip?
P.S. IDE is IAR.

rtel wrote on Friday, June 27, 2014:

In that version you will probably need to use portEND_SWITCHING_ISR(). Newer versions have both.

Regards.

sminder wrote on Wednesday, July 23, 2014:

Thanks a lot! I’ve used the portEND_SWITCHING_ISR() function and it looks like successful.