Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT


FreeRTOS timer not stopping

Posted by ksoldavin on November 16, 2016

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

Posted by rtel on November 16, 2016

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

Posted by ksoldavin on November 17, 2016

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.


FreeRTOS timer not stopping

Posted by rtel on November 17, 2016

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.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS