I am using TI CC3220SF-LaunchXL board with FreeRTOS 202002, Simplelink SDK v2.10.00.04
I start a 10 second timer (using the below mentioned API’s) and after I am finished with my job (involves servicing GPIO interrupts), I try checking if the timer is active or not, but it returns pdFALSE (10seconds have not passed yet), and if I try stopping the timer here, I observe that the device gets hanged.
If I don’t stop this timer the callback gets called after 10seconds.
I have tried increasing the priority of Timer task (configTIMER_TASK_PRIORITY) to max priority (configMAX_PRIORITIES - 1) but same result.
To check if Timer is Active and stop it: (if checked before timer expiry returns pdFALSE)
/* If Timer is active Stop */
if( xTimerIsTimerActive( SensorTimer ) )
{
if(pdFAIL == xTimerStop( SensorTimer, 0 )){
IotLogInfo("Failed to Stop Sensor timer");
}
else{
IotLogInfo("Stopped Sensor timer");
}
}
Through debugging I have observed pxTimer->ucStatus |= tmrSTATUS_IS_ACTIVE; this gets executed after I am done with my job and after trying to stop the timer. What might be the reason for this?
The likely reason is that you are done with your job before the timer task gets a chance to run and process the tmrCOMMAND_START command. Do you have any other task running at configMAX_PRIORITIES - 1 priority? If yes, can you try reducing their priority?
Are you saying that if you remove if( xTimerIsTimerActive( SensorTimer ) ) and directly stop the timer, the device hangs? If so, please break the code in the debugger and see what the code is doing?
I am using the FreeRTOS kernel version 10.3.0 and it is not possible for me to upgrade this.
Though I still tried merging the changes done in the commit with my codebase and I am able to stop the timer with xTimerStop. But xTimerIsTimerActive still returns pdFALSE.
(Now I am closing the timer without checking xTimerIsTimerActive and the device is not hanging)
I dont have any other tasks running at configMAX_PRIORITIES - 1 priority. Is interrupt servicing after timer is started causing the priority issue?
Regarding the hang, I observe it when the device is not in debugging mode. When I put in debug mode it works as expected and I don’t observe the hang. pretty strange behavior.
But as mentioned in my previous reply the issue seems to be mostly fixed by merging changes from this PR.