Hello,
Hopefully someone can tell me what Im doing wrong here or suggest a better way of tackling my problem if Im going about this the wrong way.
I am trying to uses a timer to break me out of a while loop that is waiting for an EEPROM busy test.
The timer is started at function entry and moves to the running state. The timer is at the highest priorty and higher than the task that performs the check.
I then sit in a while loop checking the spi eeprom status register. If the timer callback is called i.e. a timeout has occured then its sets a flag.This flag is checked in the while loop to break me out.
The code gets stuck in the while loop and the callback never called. Im confident the timer code is correct.
Code bones below ( I know this can be tided up somewhat )
Thanks.
/////////////// the function in the lower priority task //////////////////
paeepromTimeoutStatus = ERR_NONE;
// start the timeout timer
if (xTimerStart(PA_EEPROM_Timer, 0) != pdPASS )
{
return ERR_EXTEEPROM_TIMEOUT;
}
{
// The timer expired, therefore ‘EEPROM_TIMEOUT_MS’ ms must have passed
// Indicate that a timeout occurred
paeepromTimeoutStatus = ERR_EXTEEPROM_TIMEOUT;
}
/////////////// timer creation function //////////////////////
This does seem a bit puzzling. You say the timer callback is not run, I am presuming that means you have tried putting a breakpoint there (or the equivalent) and it doesn’t get hit.
Have you confirmed that the system tick is still running? If something has stopped that it will give you issues with the timers.
Make sure nothing else can be resetting the timer, if you keep poking it then it won’t expire.
The timercallback is hit on code startup when the timer expires. I do have a breakpoint there to verfiy that, so I know it does get called and belived the timer setup was correct.
Its a one shot timer and on entry to the function checking the bust status it is my understanding that the xTimerStart resets and restarts the timer. A breakpoint in my Callaback is never hits again . The code is still running but stuck in the do while loop in the lower priorty task, with nothing to break it out.
I had assumed with the timer task being higher priority that it would remain running and allow me to break out from the callback.
The timer is not started or reset anywhere else in my code. Im puzzled henc emy request for help, incase I had overlooked something obvious.
Im sorry but its dumb question time because Im not that familiar with FreeRTOS yet. I assume I should be checking the systick timer is running by looking at xPortSysTickHandlerin port.c?
If that is the case then its not hitting it when I get stuck it the loop. So thanks for pointing me in the right direction. Just need to find out why now…
Thanks for taking time to assist Richard.