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

How calculate heap, stack for PIC32MX

Posted by ulmus on January 6, 2012
Hi! i have running already my firmware on pic32mx with FreeRTOS, it has 2 serials(printer, usb), 2 I2C(flash, rtc) and 2 SPI (a/c converter) 3 PWMs (calibration, sound) and of course graphics LCD RA8835 with PMP :) Wow! FreeRtos works great! I had it working first as a modules without freertos and now i solve this puzzle with your rtos (semaphores and mutexes are great!)
But... memory... :( can you give me simple tips for calculating heap and maybe stacks? i have tasks created on start of app and never deleted (i am programming measurement device firmware).
I know a little, but info from you, i mean from source :) are best:)
thanx in advance :)

RE: How calculate heap, stack for PIC32MX

Posted by Richard on January 7, 2012
While it is possible to calculate worst case stack usage, likewise heap usage, I take a more pragmatic approach and use experimentation. It is made easier by the fact that, on the PIC32 (and other CPUs), the FreeRTOS port uses a separate stack for interrupts - so interrupt nesting does not need to be taken into consideration on the task stack.

If a stack is too small, then the stack overflow hook will catch it, and you know to increase it.
http://www.freertos.org/Stacks-and-stack-overflow-checking.html

If a stack is larger than necessary, then you can resize it using the information obtained from its high water mark.
http://www.freertos.org/uxTaskGetStackHighWaterMark.html

With regards to the FreeRTOS heap, if you are allocating everything up front then just inspect the FreeRTOS heap to see how much is left, and you can reduce its size accordingly. If you are using heap_1.c or heap_2.c there is even a function provided to query how much is left (xPortGetFreeHeapSize()).

Regards.

RE: How calculate heap, stack for PIC32MX

Posted by ulmus on January 8, 2012
Thanx a lot! As always support here is the greatest!
Thanx!


[ 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