Quality RTOS & Embedded Software

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


HSC12 - demo application - out of RAM space

Posted by Nobody/Anonymous on May 3, 2006
I am trying to run the HSC12_small demo application using Freescale's CSM12C32 module (it has the MC9S12C32 MCU with 48 pins). I have to reassign ports/pins as the original (SofTec) uses the 80pin version, but the rest should be the same, i.e., 2 kB RAM. Nevertheless, the linker complains about not enough RAM for the demo application: "Linker error: L1102: Out of allocation space in segment RAM at address 0xF8E". RAM is starting at 0x800 and of size 0x800.

As I am sure the application has been tested with 2kB RAM, I assume I am doing something wrong here. Did anybody else experience this and could give me a hint on what to adjust?


Note: The .map file summarizes RAM usage to be 1934 bytes; FreeRTOSConfig.h uses #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048 - 256 ) ) which is 1792 bytes. But using 2048 does not make a difference.

RE: HSC12 - demo application - out of RAM space

Posted by Nobody/Anonymous on May 4, 2006
I think the RAM usage in this demo is quite tight.

As an experiment, try making the heap size smaller, say by 256 bytes to start with. Then see if it links. If so see how close you can get it back to the original value. This will give you an idea of how close it is to fitting, and how much needs shaving off.

Does the FreeRTOS hcs12 demo use any special linker file, or just the standard one. I remember there was something about the processor expert screwing up interrupt vectors, but i can't think it would do anything to the linker.

Do the larger 80pin device headers include any badly written library code that is eating ram for no reason?

RE: HSC12 - demo application - out of RAM spa

Posted by Nobody/Anonymous on May 4, 2006
Thanks for your input - changing the heap size does not seem to help but your advice made me look at the Processor Export CPU setting of the stack size: it was set to 80 rather than the smaller value of 30 of the original FreeRTOS HCS12 project. I guess creating/opening it with my PE set it to this default value?

I can know run all the demo tasks and the .map file indicates RAM usage of 1982 bytes, which may still be too high - I would appreciate any comments on this as it may indicate that I won't be able to program much with 2kB RAM.

Note: I had to change one thing in main.c to correctly reset the PP5 button-interrupt:
/* Clear the interrupt flag. */
PIFP = 0x60; // PIFP = 1 doesn't work

RE: HSC12 - demo application - out of RAM spa

Posted by Richard on May 4, 2006
Thanks for the heads up on the bit clearing.

On the smaller devices the demo apps are often written to take up a lot of the available RAM, if not all of it. You can remove some of the demo tasks to free up the RAM requirements, then reduce the amount of heap allocated to the kernel.

If you are very tight on RAM then consider using co-routines instead of tasks. These remove the necessity to allocate a stack to each 'thread' of execution.


RE: HSC12 - demo application - out of RAM spa

Posted by Jeff Smith on May 18, 2006
Also sometimes the useless demo functions will free up a lot of RAM if removed for your own functions.

RE: HSC12 - demo application - out of RAM spa

Posted by Jeff Smith on May 18, 2006
Oh Richard already mentioned removing the demo functions...

I want to make more clear the other thing suggested:
The demos are allocating most or all RAM for the RTOS heap. If the linker says "out of RAM", then that does not mean all the RAM in the heap is used. So in fact, if you are out of RAM, you actually might be able to _reduce_ the heap size to solve it.

In "heap_2.c" I looked and found pxNextFreeBlock. I have tracked this variable to see how much heap I needed. It was much less than what is allocated.

RE: HSC12 - demo application - out of RAM spa

Posted by Jeff Smith on May 18, 2006
Sorry, was misleading about finding free heap space...

- in "heap_1.c" you can simply track xNextFreeByte to see how much heap used

- in "heap_2.c" looks more complicated
You would have to search the linked list starting at xStart and find the highest pxNextFreeBlock. It seems like xEnd.xBlockSize could be updated to track free space, but it isn't. It is initialized:
xEnd.xBlockSize = configTOTAL_HEAP_SIZE;

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

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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

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