Quality RTOS & Embedded Software

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




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists