This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Building to execute from RAM

Hi.

I am trying to build an infield programming project, i have the code and it does all work upto the point where i currently am.

I want to have the code loaded into and run from RAM, however im unable to get CCS to build this. Could anyone help point me in the right direction I basically want to acheive the following: 

1. Build a ROM image with the correct addresses

2. Have variables share the RAM with the code.

Currently the code can be loaded into RAM but all branches are showing in assembler as been absolute addressing i.e. CCS is addressing the code as if it was in flash. Im sure its simple enough to do, i just cant see where CCS allows this configuration.

Thank you

James

  • Since the MSP has no protection for code that is in ram (and can easily be overwritten), executign code in ram shouldn't be done unless absolutely necessary (e.g. for a fast flash write function, since during flash write, no code can be read from flash).

    Howeve,r teh easiest way is to tell the compiler that the code goes to teh segment for initialized variables isntead of the normal code/text segment. then it is compiled and linked for a fixed ram position, but placed in flash toegther with the initalization values of your variables. At start, both, the init values and the funciton code will be copied to ram. And calling it from anothe rfunction will call teh correct address in ram.

    How this is done depends on the compiler. See the compiler/linker documentation Syntax and segment names are different for each compiler.

  • For example, in IAR you declare your function like this:

    __ramfunc void foo(void);

    And the compiler, linker, and cstartup take care of the rest.

    Jeff

  • Thanks for all the replys, i have changed my implementation now slightly so this isnt an issue but it was your suggestions that shifted me in that direction.

    basically iv used the pragmas in

    http://www.ti.com/lit/ug/slau132f/slau132f.pdf

    and created a new memory map, then using the #pragma SET_CODE_SECTION(".firmware") pragma been able to place my update code in a seperate portion of flash rather than RAM.

    Thanks

    James

  • Hi James,

    actually there is already an example code for this. Please take a look to the MSP430F543x example code:

    http://www.ti.com/litv/zip/slac166q

    inside  you can find the msp430x54x_flashwrite_04.zip file containing the code exactly what you need. I tested it before with CCS v4, and i think it should be also no problem running it on CCS v5.

**Attention** This is a public forum