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.

MSP430F5335: RAM usage

Part Number: MSP430F5335


Hi all.

I'm developing an application where I need large data arrays in RAM.

The IAR memory map shows I'm using "17 178 bytes of DATA  memory (+ 151 absolute )" on a 18 kB RAM device.

My code is working well but I need your opinion whether I can have problems during execution due to high RAM usage.

Regards,

  • Hi Jorge,

    This should not be an issue so long as enough room has been left for the stack. Are there any specific concerns that you would like addressed? ftp.iar.se/.../EW430_CompilerReference.pdf

    Regards,
    Ryan
  • Hi Ryan.
    I looked deeper into IAR and I found that my stack usage is 1336 + 1300 = 2666 bytes

    ****************************************
    * *
    * STACK USAGE *
    * *
    ****************************************

    Call Graph Root Category Max Use Total Use
    ------------------------ ------- ---------
    interrupt 1 294 1 330
    Program entry 1 336 1 336


    So I changed my stack size to 2700 bytes, this gives in memory map: 18 278 bytes of DATA memory (+ 151 absolute ) = 18429 bytes.
    Don't know from +151 absolute comes from, the 18278 are 0x33+0x3CA7+0xA8C.

    So the memory map stays:

    DATA16_I 1C00 - 1C32 33 rel 1
    DATA16_Z 1C34 - 58DA 3CA7 rel 1
    CODE_I 58DC rel 1
    DATA20_Z 58DC rel 1
    DATA20_I 58DC rel 1
    DATA20_N 58DC rel 1
    CSTACK 5974 - 63FF A8C rel 1

    As far as I understood, because my RAM is from 1C00 - 63FF, although I'm on the limit, I shouldn't have problems, right?

    Regards,
    Jorge

  • Hi Jorge,

    No joke about being on the limit, that's cutting it quite close. But so long as the compiler is able to put it all inside of the RAM space properly and there are no errors then you should not encounter any problems.

    Regards,
    Ryan
  • Hi Ryan.

    I like living on the edge...

    I did some more tests and using some other IAR features, like the stack view and RAM memory view, I found that really only 1294 bytes are used on the stack. So as far as I understood the stack usage on the map file gives the worst case scenario. Acording to this I should get lucky and not run into troubles...

    One of the things is contributing for the high stack usage is UART debug messages. Because I'm still developing I need it, but in the production firmware it will not be necessary, so I will retrieve it, leaving more space for stack.

    Can you tell me what "DATA memory (+ 151 absolute )" on the map file means?

    Regards,

    Jorge

  • Jorge Cunha18 said:
    So as far as I understood the stack usage on the map file gives the worst case scenario. Acording to this I should get lucky and not run into troubles...

    At least the toolchains I use to work with (does not include the MSP430 !) do not make any static stack size calculations and checks. And even high-priced tools are weak on static stack size estimations, if they do that at all. The map file reflects the stack size setting done elsewhere, usually somewhere in the project settings.

    Actual stack usage is determined by the complexity of your application (call depth), ABI (method of parameter passing), and asynchronous events (interrupts using the stack). So, you basically have to "brace" your application for the worst case, and make an educated guess. This worst case can come with rare conditions, and crash you app in a seemingly random manner even after all foreseeable scenarios are tested. (MCUs with priorized interrupts and potentially large interrupt stack frames - MSP432 with FPU context save - are more prone here ...).

    Jorge Cunha18 said:
    Can you tell me what "DATA memory (+ 151 absolute )" on the map file means?

    I have no experience with the MSP430 compiler/linker, but it should be easy to find out. Check what data go into that section, and cross reference to the source. Perhaps constant data ?

**Attention** This is a public forum