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.

MSP430F5418A: Variables turn to wrong values while running

Part Number: MSP430F5418A


I'm implementing some signal processing algorithm on my msp430f5418a board. In the debug mode, I have observed that some varaibles will turn to wrong values after some computation. The computation has a lot of for loops inside but has nothing to do my observed varaible. I guess it is because of some overflow issue. Has anyone has similar problems and would like to give me hint?

Here are my memory allocation and stack usage. I hope they can help diagnose my issue.

Thanks!

  • Can you please provide some examples as to what happens to your variables that is unexpected? Can you separate the algorithms outside of your application code and still observe the issue? Have you correctly initialized your variable type and size to account for all computation outcomes?

    Regards,
    Ryan
  • The classic reason that this happens is that you overrun the bounds of an array, or use a pointer that has gone out of scope. Look really hard at off-by-1 errors.
  • Ryan, thanks for your reply. Let me explain a bit more of my code and the current workaround I'm using.

    The high level code structure looks like this:

    /*******   Process 1   *******/

    <body of code>

    c1 = <some logic>

    /*******   Process 2   *******/

    <body of code>

    <several for loops here>

    c2 = <some logic>

    The error occurs to c1 when I was tracking process 2. Let's say c1 = 1 before entering process 2. c1 turns to some random value (16789, something like that and not consistently the same value) when for loops are executed.  c1 should have nothing to do process 2.

    My current workaround is that I simply put process 2 before process 1. c1 and c2 will always be what I expect.

  • Hi Keith, thanks for your reply. As in my last post, I can get correct results by rearranging code. So I believe it's not an OB1 error. I have tracked all variables in debug mode and compare them with my MATLAB simulation as well.
  • Thanks for the additional info Liang. Have you tried increasing your system stack and heap sizes? This is done inside Project Properties -> C/C++ Build -> Settings -> Tool Settings -> MSP430 Linker.

    Regards,
    Ryan
  • Hi Ryan, my current stack and heap size are both 160. Is there a range within I can safely change the sizes? Thanks.
  • Hi Liang,

    The limitations are your total RAM size (16 KB) and the amount of RAM used for the application (~12.5 KB from your images).

    Regards,
    Ryan

**Attention** This is a public forum