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

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?

Thanks.

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.

Regards.

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