Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Using Malloc and Free

Status
Not open for further replies.

Ishaan Karnik

Member level 3
Member level 3
Joined
Jun 16, 2012
Messages
64
Helped
14
Reputation
28
Reaction score
14
Trophy points
1,288
Activity points
1,726
I am using Freescale Semiconductor MC9S08LG32 controller.
I am using Code Warrior 10.2 Special edition IDE for development.
I am trying to dynamically allocate and dellocate memory (an single dimension array of type float of size 30) dynamically inside a function.
However I getting an error Out of Allocated Space Segment RAM at Address 0x131.
Any Ideas why?
 

I'm not surprised. You only have 2k of RAM on that microcontroller. 30 x float is 120 bytes, which is probably way more than allowed by
your linker config file. If you only have 2k of RAM then in general you shouldn't even be using malloc, you should know in advance how
much space you need, and define an array for that purpose in your function.
 
I would agree with sky_123, although many Embedded C Compilers offer dynamic memory allocation valid and appropriate uses with microcontrollers have limited storage resources are few.

Depending on you code, 120 bytes of storage can quickly become 1200 bytes or more if not managed correctly.

The error message maybe do to the exhausting of storage resources or a memory map/linker script issue. Unfortunately, I'm not familiar enough with the Code Warrior line of compilers to advise you without reviewing your code and the memory map/linker script.

BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top