Quality RTOS & Embedded Software

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


Loading

Timer stack overflow problem

Posted by Mohammed Abdalhakam on February 6, 2013
I'm new to FreeRTOS, I got a timer stack overflow caught by vApplicationStackOverflowHook when xTimerChangePeriod called, what could be the reason
I create a stopwatch timer as follows:

stopwatchTimer = xTimerCreate(flshTmrStr,DUMMY_TIME_PERIOD,pdFALSE,
(void*)STOPWATCH_TIMER_ID, stopwatchCallback);

and in the task function:

stopwatchTimeExpired= pdFALSE;
xTimerChangePeriod(stopwatchTimer,delay*1000/portTICK_RATE_MS,0);
xTimerStart(stopwatchTimer,0);
while(stopwatchTimeExpired == pdFALSE)
{
//do some stuff till time expired (flag set true in timer callback)
}

in FreeRTOSConfig.h file:

#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY 3
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE

I'm using ATMEGA32 in WinAVR GCC compiler, thanks for your help...

RE: Timer stack overflow problem

Posted by Richard on February 6, 2013
The ATMega32 does not have much SRAM, but if a task that is calling xTimerChangePeriod() is experiencing a stack overflow you will most likely have to increase the stack allocated to that task when the task is created.

You can also try reducing the stack used by the task by reducing the size of any arrays allocated on the stack, or by moving variables from the stack to instead by static or global (if your application allows).

Regards.

RE: Timer stack overflow problem

Posted by Mohammed Abdalhakam on February 6, 2013
Dear Richard,
the overflow is not caused by the task, but by the timer service; when monitoring the task name in vApplicationStackOverflowHook it was 'Tmr Scv'. I checked the remaining byte left for that task by using
leftMem=uxTaskGetStackHighWaterMark(NULL);
and it was 91 byte (out of 200)
in fact the application run fine despite that overflow,

RE: Timer stack overflow problem

Posted by Richard on February 6, 2013
It is possible that on AVR devices the timer stack size needs to be greater than the configMINIMAL_STACK_SIZE setting. configMINIMAL_STACK_SIZE is set for the idle task, which (unless an idle task hook function is defined) does nothing more than call some very small functions.

Regards.

RE: Timer stack overflow problem

Posted by Mohammed Abdalhakam on February 6, 2013
Yes, we're right, increasing the timer stack size from 100 to 120 solved the problem.
I think I may consider counting ticks instead (and taking care of 0xFFFF~0 rollover)....

Thank you A lot...

RE: Timer stack overflow problem

Posted by Mohammed Abdalhakam on February 6, 2013
Yes, you're right, increasing the timer stack size from 100 to 120 solved the problem. I think I may consider counting ticks instead (and taking care of 0xFFFF~0 rollover).... Thank you A lot...


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner