malloc() fails on XDP512 (HCS12x)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

malloc() fails on XDP512 (HCS12x)

1,194 Views
VigneshGanesan
Contributor I
We're have an issue with the malloc() command on the MC9S12XDP512 controller (SK-S12XDP512-A EVB) with CodeWarrior for HCS12x v5.7.0. malloc() doesn't seem to work. It doesn't produce any complier or linker warnings. BUT the return pointer points to an address in the EEPROM (the returned pointer value was 0x824). Stepping through the code, we see that the heap_end starts at 0xc000 (flash memory). None of this seems right, but we can't find out how to fix the issue -- possibly some variable somewhere needs to get the right initial value of the memory space or something like that.

We've tried this out with a dummy program with just a main() and malloc() and it still doesn't work -- that is, its not a stack overflow or something running out of memory.

Any help would be greatly appreciated !

Best,
Vignesh.
Labels (1)
0 Kudos
1 Reply

396 Views
pappan
Contributor I
Hi Vignesh,
 

Please check the Project settings and ensure that you selected ANSI C start up, think you are currently using minimal startup code settings.

If you are application requires less than 2000 bytes of heap then you can open the Freescale\CW for HC12 V4.5\lib\hc12c\hc12_lib.mcp project and select the type of .lib u need to compile. Open the stdlib.c and from includes open the libdefs.h header file and change the #define LIBDEF_HEAPSIZE 2000 to required size in order to save the RAM.Compile the lib project and include the new .lib file for your porject.

Have a nice time.

Please feel free to revert for any further clarification in this regard

With Best Regards

Padmakumar

0 Kudos