Vignesh Ganesan

malloc() fails on XDP512 (HCS12x)

Discussion created by Vignesh Ganesan on Oct 11, 2006
Latest reply on Oct 12, 2006 by Pappan T
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 !