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

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