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;
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?
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?
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.
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.