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.

MSP430FR2355: how to use the stack to find out what is causing a reset?

Part Number: MSP430FR2355


Hello....

I have code that takes button inputs from switches and does actions based on these.  I have tried to adapt the code to read the P1IN for momentary action and now I am resetting sometimes....  

I have a few places in code where I write the incorrect value to the watchdog, WDTCTL which causes a reset but it seems if I place breakpoints here that none of these are causing the resets. The debug window shows the following:

Can someone please tell me how to read this and use this to find the issue??  As a hardware guy my debug level is setting a breakpoint and adding expressions to watch after breakpoint.  ...or looking into registers....beyond that I am not sure what to try as I don't know how to use the stack to my advantage.....

The code is using all the timers and CCR registers to do many things....guessing something is running off into limbo

Thanks

  • The reason for a reset is stored in system register SYSRSTIV. Keeping in mind that it returns values in priority order so you need to read it till it returns zero. Not a big problem as part of your normal startup process but if read using the debugger there could be several codes set.

  • Can you elaborate any more?  For instance I reset code and already the SYSRSTIV says 0X0E ....Why not 0?

    Can I run code then place a breakpoint at the front end of main so that when it resets I just look at the register?

  • The device data sheet lists all of the codes. A power up reset of course sets a code.

    Breakpoints can go anywhere.

  • I set a breakpoint (see below) at the WDTCTL line...I start code up at fresh and get 0x0E....I hit a few buttons here and there and break the code as it resets and stops at the breakpoint I just mentioned....SYSRSTIV still reads 0x0E....no difference....Do I need to do something else:?

    int main(void)


    {
    uint8_t sysLoop = 0;

    WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer

  • What code is at line 1210 of application.c? 

    The first thing that catches my eye is that a the most recent recognizable function is called "<something>_ISR". Is this really an ISR?

  • Bruce...

    You are correct....it is a timer ISR ....called RFMessageHandler_ISR

    #pragma vector=TIMER0_B1_VECTOR
    __interrupt void rfMssgTimeHandler_ISR(void)
    {
        switch(__even_in_range(TB0IV,TB0IV_TBIFG))
        {
          case TB0IV_NONE:   break;
          case TB0IV_TBCCR1:
              if (!ISR.buttonPushedFlag)
              {
                  UCA1IE &= ~UCRXIE;
                  TimerCompare_Disable_IRQ(TIMER_RADIO, CC_ONE);
                  ISR.mssgRcvdFlag = T;
                  LPM3_EXIT;
              }
              break;
          case TB0IV_TBCCR2:
              pTx = mssg;
              TB0CCTL2 &= ~CCIE;
              UCA1IFG |= UCTXIFG;
              UCA1IE |= UCTXIE;
              break;
          case TB0IV_TBIFG: break;
          default: break;
        }
    }
    

    line 1210 is when TXIE gets enabled

  • It seems odd since line 1210 doesn't call anything. Enabling TXIE could trigger an interrupt, but you're in an ISR so interrupts are disabled.

    What code is at line 162 of application.c (i.e. the next entry up in the call stack)? 

  • 162 is a breakpoint I had set which occurs before the while(1) loop during configuration....Basically I set it to catch when I reset

    So that timer expires and sets the enable for the transmitter....after breaking out of this ISR, GIE should set and I jump right into the UART ISR which the code seems to do

  • The stack traceback implies that the ISR was suspended at line 1210, so something happened before it exited.

    What code is at line 162 of application.c?

**Attention** This is a public forum