Quality RTOS & Embedded Software

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


Loading

stack overflow

Posted by Samuel on November 9, 2011
My application goes to "vApplicationStackOverflowHook()" in some conditions, I can't work out the reason. There are 4 tasks, 3 in block state, only one is running, I add "ChargerTaskWaterMark3 = uxTaskGetStackHighWaterMark(NULL);" at the end of this task, but it return good value (436).

Would someone give me a clue how to trace this problem.

RE: stack overflow

Posted by Richard Damon on November 9, 2011
Note that the vApplicationStackOverflowHook is called with 2 parameters to help figure out what happened, the first is the TCB of the task that failed, and the second is the task name.

Note that tasks can sometimes take differing amounts of memory depending on the path they take, and on many implementations which interrupts occured while they are running.

RE: stack overflow

Posted by Jeff Andle on November 9, 2011
Keep a global dubug structure and for each task take the lesser of the measurement and remaining stack.
Place the test at places where you might allocate temporary variables like a char array[size] that chew up stack briefly but not permanently. Allow extra stack for called functions, ISR's etc.

unsigned short usNew = uxTaskGetStackHighWaterMark (xTH_Serial0Command);
xDebug.usSD_Serial0Command = xDebug.usSD_Serial0Command

RE: stack overflow

Posted by Samuel on November 9, 2011
Problem found.
There is a function force the MCU go to sleep, the high frequency oscillator is turned off, systick timer is connected to high frequency oscillator, but the 32Khz low frequency oscillator is still running.

But I can't work out why "systick timer" stop will cause stackoverflow.
If MCU go to sleep, How to make RTOS keep going after MCU wakeup? Connect the "systick timer" to 32Khz oscillator with
same Tick_Rate_Hz"(say 10mS per tick), then switch to high frequency oscillator after wakeup?

RE: stack overflow

Posted by Richard on November 10, 2011
I can't answer specifically, just generically, but would say it sounds like you are entering a very deep sleep, and therefore it depends on what happens to other peripherals/RAM etc while asleep, and what happens when you wake up again.

I'm not sure how you are wanting your system to work, but if the SysTick is stopping, than task blocks times that are not infinite are probably not going to function correctly, as to them, time will have stopped.

This might be of interest to you - in particular the pdf file:
http://interactive.freertos.org/entries/20291196-energy-optimized-port-of-freertos-6-for-efm32

Regards.

RE: stack overflow

Posted by glory_man on January 20, 2012
I'm little confused.
I use STM3240g evaluation board. And try to run FreeRTOS on it. My main function

int main(void)
{
unsigned portBASE_TYPE i;

/* Initialize CAN interface */
vSetupNVIC_CAN();
vSetupCAN();
vSetupCANFilters();

CAP2Init();

LCD_LED_Init();

for(i=0;i {
xAutoReloadTimers = xTimerCreate(.............);
}

xTimerReset(xAutoReloadTimers[0], 0);
xTimerReset(xAutoReloadTimers[1], 0);

xTaskCreate( ...............);

vTaskStartScheduler();

return 0;
}

After LCD_LED_Init(); program goes to vApplicationStackOverflowHook.
But when I move LCD initialization in task-function like this:

static void vTaskLCD( void *pvParameters )
{
volatile TaskParam *pxTaskParam;
pxTaskParam = (TaskParam *) pvParameters;
LCD_LED_Init();
for( ;; )
{
vTaskDelay( 100 / portTICK_RATE_MS);
... led blinking ...
}
vTaskDelete( NULL );
}

and create new task
xTaskCreate( vTaskLCD, (signed char *) "Task LCD", configMINIMAL_STACK_SIZE*2, (void*)&xTP1, 1, NULL );
everything work - LCD initialized.

Where may be a problem ?
sources
http://rghost.ru/36003924
http://rghost.ru/36004000
http://rghost.ru/36004015
USE_LCD - defined


[ 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