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


minimal stack usage of tasks with PIC32

Posted by Nils Schulte on April 13, 2011

I currently need to estimate whether I will have enough available RAM for my project when using freeRTOS with PIC32.

One important point is memory usage of tasks. Am I right that will need at least following amount of RAM for each task?
760byte (config_Minimal_Stack_Size=190 words) + 64 byte for task-organization + more stack for any local/non-static data

As I will need to realize a "large" project requiring at least 20 tasks and 20 queues I am concerned that I might run out of RAM soon. So can you give me a hint how I can lower the memory usage? I read about the function attribute "naked" for task functions - about how much would it help to lower config_Minimal_Stack_Size? Or is there some related freeRTOS configuration switch that might help to further reduce the memory usage?


RE: minimal stack usage of tasks with PIC32

Posted by Richard on April 13, 2011
The MIPS core uses a lot of stack. FreeRTOS minimises the stack requirements by provided a separate stack for any interrupts (which may be nested many deep) - thus removing the requirement for each task stack to allocate enough stack for interrupts too.

The figures you state sound about right, but it depends on what the tasks are doing. If the tasks are calling standard C library functions (especially things like printf()), then they will need more. You can minimise that again by providing cut down versions of such library functions (FreeRTOS contains a file to replace the printf()/sprintf() functions, but with limited functionality).

If you are using FreeRTOS V7.0.0 then you have the option to include a lot of functionality in timer callback functions. If a task has "run to completion" type functionality, you can have it in a timer rather than a task, and save yourself lots of stack space.

There is always the option of using co-routines too, which are ultra light weight threads, but they have limited functionality and are a bit legacy now (going back to when 8-bit was used more).


[ 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