AnsweredAssumed Answered

CW 2.10 for MPC56, how to change RAM mapping in LCF file?

Question asked by Daniel Lundin on Mar 17, 2014
Latest reply on Apr 1, 2014 by Pascal Irrle

Using CW 2.10 for MPC5643L (cut 3.1).

 

I'm trying to re-map the RAM areas for my project. Default mapping by Freescale is as follows:

 

internal_ram:      org = 0x40000000,   len = 0x0001C000
heap  :            org = 0x4001C000,   len = 0x00002000 /* z4 Heap start location */
stack :            org = 0x4001E000,   len = 0x00001f00 /* z4 Start location for Stack */

 

Now, this memory map has a lot of problems. Surprisingly, I'm using this safety MCU in a safety-critical application. So first of all I want to get rid of the heap entirely: dynamic memory allocation is completely banned by SIL, MISRA etc. Also, I don't want my stack to down-count into my variables! If I would for some reason get a stack overflow, the MPC56 would go completely haywire with this memory map, rather than to give an exception.

 

This is what I did and it seems to work fine:

 

stack :            org = 0x40000000,   len = 0x00002000
internal_ram:      org = 0x40002000,   len = 0x0001C000

 

But now I also want to add a custom memory segment of 64k for some special variables. I'd also like to use the whole 128k of RAM.

I change to the following:

 

stack :            org = 0x40000000,   len = 0x00002000
internal_ram:      org = 0x40002000,   len = 0x0000E000
ram_param_image:   org = 0x40010000,   len = 0x00010000

 

    GROUP : {

      .ram_param :{}

    } > ram_param_image

 

And then in my C code:

 

#pragma push

#pragma section data_type ".ram_param" ".ram_param"

__declspec(section ".ram_param")

 

static uint8_t ram_nvm_mirror [RAM_NVM_SIZE];

#pragma pop

 

This also works fine... as long as I have my debugger attached. When I try to run the program stand-alone with no JTAG connected, the program just hangs. If I remove my custom section and put the custom variable in default RAM (.bss), then everything works fine without the debugger attached. The debugger is Lauterbach Trace 32.

 

Any idea what might be causing this? Did I write the #pragma correctly? Have I misunderstood the memory mapping?

 

The MPC5643L should have 128k RAM. As far as I can tell, it should go from 0x4000 0000 and upwards. (The manual chapter 2 is a bit confusing since it mentions 0x5000 0000. I did try to put my custom variable there, but then I got IVOR1, debugger or not, so that address doesn't seem valid.)

Outcomes