FreeRTOS timer not stopping

I am having an issue with my timer code under FreeRTOS v9.0 using an STM32F4. I am trying to create a one shot timer with a period of 1000mS. The timer is being activated correctly and the callback function is being run, but after it has finished it is repeatedly called again 1000mS later. My timer is being set up as follows: ~~~ static void SerialTimerCallback( TimerHandlet pxExpiredTimer ); static TimerHandlet SerialTimerHandle = NULL; SerialTimerHandle = xTimerCreate(“Video DMA Timer”, 1000, pdFALSE, ( void * ) 123, SerialTimerCallback ); static void SerialTimerCallback( TimerHandle_t pxExpiredTimer ) { printf(“Timer expiredn”); // Do other stuff } ~~~ I have also tried making the timer auto reload and calling the stop timer command in my callback with the same result. Any suggestions? Thank you Keith

FreeRTOS timer not stopping

I’ve never come across that symptom before. Is anything else using the SerialTimerHandle handle in any way? Could it be accidentally reset by any other code? Where is xTimerCreate() being called from? Could it be accidentally created more than once?

FreeRTOS timer not stopping

Thank you for responding. The timer is being created in my init code that is efinately only run once. Aside from that I have code that checks if SerialTimerHandle is NULL and only tries to create it if it is. I just looked over my code and the only place the timer is touched is when it is initialized. Keith

FreeRTOS timer not stopping

This is very odd, and perhaps it is a simple data corruption that has effected the timer’s structure. Place a break point on the function prvProcessExpiredTimer(), which is in FreeRTOS/Source/timers.c. The break point will get hit when your timer expires. Step through the function and see what happens – there is a line “if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )” – if it goes through there then the timer thinks it is an auto reload timer. If that is the case it would indeed seem to have been corrupted – in which case restart the application and step through the code that creates the timer. pxTimer->uxAutoReload should get set to pdFALSE (0) – does it? If it does then you will have to try and catch the place where it gets overwritten – the easiest way of doing that would be to put a data watchpoint on the pxTimer->uxAutoReload memory address that will automatically stop the code when that memory address gets written to.