Quality RTOS & Embedded Software

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


Loading

tasks, interrupts and stack

Posted by Jesper Matthiesen on September 19, 2008
Hi,

I'm having trouble with an application with (currently) 3 tasks on an ATMega32 and FreeRTOS 5.

one is servicing usart communications and the other 2 are currently only flashing their own individual LED.

when adding all 3 tasks, the application crashes (no tick, causing the wdt to reset).. adding only any 2 of the 3 tasks, all works fine.. i'm suspecting stack overflows are the cause of this, but can't find any pattern in the behaviour..

am i correct in saying that a tasks stack usage is not affected by other tasks, only interrupts? because then if a task works, adding in new tasks (that do not cause interrupts and have sufficient stack) should not affect existing ones..

the strange thing is, it is always the 3rd task (last one added), that does not work, but this task sits highest in memory, so it can't get its stack overwritten by the other tasks, only itself can overwrite its TCB...

on a side note: the idle task default stack size of 85, where does that come from? is it the stack used by the task itself, so adding interrupts to the system may make this stack too small?

RE: tasks, interrupts and stack

Posted by Richard on September 22, 2008
> am i correct in saying that a tasks stack usage is not affected by other tasks, only interrupts?

Yes.

> because then if a task works, adding in new tasks (that do not cause interrupts and have
> sufficient stack) should not affect existing ones..

Have you checked the return value of the xTaskCreate() function, maybe the task is not getting started at all. Does vTaskStartScheduler() return?

> on a side note: the idle task default stack size of 85, where does that come from? is it
> the stack used by the task itself, so adding interrupts to the system may make this stack
> too small?

The size is determined as a 'safe minimum' for the demo application, which includes at least one interrupt (UART) so this is taken into account.

Take a look at http://www.freertos.org/Stacks-and-stack-overflow-checking.html and http://www.freertos.org/uxTaskGetStackHighWaterMark.html but note on 8bit machines you might get funny results if the return values are >255.

Regards.


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


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

Careers

FreeRTOS and other embedded software careers at AWS.


Latest News

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


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

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