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.

Flash / SRAM Program execution

Other Parts Discussed in Thread: MSP430F5438

Hi all,

This is probably a very basic question but I couldn't find the answer to this anywhere hence the need to post.

I'm looking at the datasheet of MSP430F5438, which talks about Active Mode current of 312uA in flash program execution and 140uA in RAM program execution. Looking at these figures, the first thing that comes to my mind is to run from RAM, for lower current consumption. 

Assume that I have a simple program in IAR EW, that just toggles the LED, when I download and debug it, where is the program running from (by default)? At 3V input supply, I measured the current to be about 295uA so the higher number suggests it is running from flash, is that correct? If so, why?

I am really confused about flash/ram execution mode and having 16KB of SRAM on the controller, I'd like to see how the current consumption can be brought down executing the program from ram.

It is also possible that I'm thinking complete rubbish, if that's the case please point me in the right direction.

Thanks!

  • You're thinking 'PC'.

    On a PC, teh programs are stored on a HD. The BIOS copies the program over from HD to ram and executes in RAM.

    The MSP is rather like the BIOS itself. The code is not read from here and stored there. It is already on the place it is to be run from, the flash (just like the BIOS chip).

    If you want to execute code from ram, then you'll need to copy it there manually.
    There are some tricks to make the compiler do it for you on program start: put function you want to copy to ram into the initialized data segment, so they are copied togehter with the data init values when the program starts, and will be automatically accessed there.
    However, if you want to dynamically load functions from flash (or an external storage) to ram and execute them, you'll need to write the code for it, as well as code for relocate them (as their execution position is different from the link position).
    This is a job for an OS. Which needs to run from flash.

    Inmost cases, you'll require the ram for storing data and stack anyway.

  • Thanks a lot. That clears it up!

**Attention** This is a public forum