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.

Stack Pointer Error with FRAM Memory

Other Parts Discussed in Thread: MSP430FR5739

Hello all,

I'm trying to collect data samples on the 10-bit ADC, store them to the 16 KB FRAM Memory on my MSP430FR5739, calculate an RMS value when the various 'pages' of memory are full,  then transmit those RMS values with the CC3000 (using experimenter's board).  Code compiles, links, downloads without a problem, however, after I connect to the router, and then try to start collecting data to store to the FRAM, all my LEDs that indicated my device was connected to the router shut off and the following message pops up in IAR:

"The stack pointer for stack 'Stack' (currently Memory:0x20000) is outside the stack range (Memory:0x1E70 to Memory:0x2000)"

Does this mean I'm trying to write to memory out of the range or that I'm overwriting program code that is causing my entire device to malfunction?

Note this only happened once I started trying to assign ADC values to various 'pages' of the FRAM.  Before if I just tried to instantly transmit ADC values from RAM (without storing values then recalling them to calculate RMS), it worked just fine.

Let me know if you have any thoughts or would like to see specific parts of the code.

Thanks!

  • 'The stack grows as the program flows'

    There is no way to control stack growth. When you call a function, define local variables, or when an interrupt is served, the stack will grow (and shrink when you exit the ISR or the function with the local vars). There is no way to limit it. However, in the project setting you tell that linker that you expect a maximum stack size of x (IIRC, 80 bytes is the default).

    This blocks this amount of ram from being allocated for global vars. It will also cause the compiler to show a warning when at a breakpoint the stack appears to have grown outside this range.

    In your case, the expected stack range seems to be 0x1e70 to 0x2000. Which is 400 bytes. Yet the stack pointer is found to be 0x20000, which is obviously somewhere else. Far off. Very far off.
     And nowhere near ram at all.

    So I guess, for some reason, the stack pointer was changed. Where and why, I don't know. After all, the stack pointer is a register almost like any other (R1) and can be changed to any value.

    A possible reason is a device reset, during which the stack pointer was lost and hadn't been initialized again when the debugger attached.

    It would be interesting at which code position (program counter) this happens. However, a debugging session through the forum is 'a bit' difficult.

  • Thanks for your help! 

    It only appears to be bringing up this error when I try and store ADC values in the 16KB FRAM memory, then calculate an RMS value (also stored in FRAM), then try and transmit that RMS value over UDP.  

    Also, what happens is that my code hangs on the part where the "MAGIC NUMBER" of the transmission buffer is overwritten, causing the code to stop.

    Today I got the same error message, but this time I got a completely different stack pointer.

    I had restarted the device a couple of times, but I don't know if that's the complication.

    Should I try and change values in the Linker Options? Please let me know! thank you so much!

  • Joseph Boruch said:
    It only appears to be bringing up this error when I try and store ADC values in the 16KB FRAM memory

    Is it possible that you trigger a PUC due to a memory write access violation?

    I don't know enough about your project (code, project settings, whatever) to do a full analysis. (and I have neither CCS nor an FRAM device to test myself). So I can't give you any detailed advice, only rather general hints.

    Maybe someone else can help you further.

**Attention** This is a public forum