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.

CCS/MSP430FR2355: code running off in limbo?

Part Number: MSP430FR2355
Other Parts Discussed in Thread: MSP-FET

Tool/software: Code Composer Studio

Hello...

I have code where I do some clock, gpio and uart set up functions then a while(1) loop.  I have one rx/tx ISR active.  I frequently am finding that my code is somehow resetting....If I place one breakpoint before the while loop I run to it then hit run again and after a short period the code will circle out of the while loop and break at that point.....If I remove the TXIE in INITUART I no longer have the issue.  I am convinced that somehow one of my pointers is running away and causing grief....Can anyone see anything glaring about how I may be poorly handling pointers to cause grief?  In particular the pTx..... 

#include <msp430.h>
#include <string.h>
#include <stdint.h>
#include "rc.h"
#include "LPRSradio.h"

volatile char *pRx;
char incoming[20];
const char *pTx;
const char *configCmdAck[3] = {r_RSSIon, r_bandSet, r_USAFCC};
const char *testack = "ACK";
uint8_t i = 0;
boolean tx = T;
int k;
unsigned int r;
boolean redflag = F;

int main(void)

{
    WDTCTL = WDTPW | WDTHOLD;   // stop watchdog timer

    IOconfig;
    initClockTo16MHz();
    initUART();
    pRx = incoming;
    pTx = configCmdAck[0];
    __bis_SR_register(LPM3_bits + GIE); //go to sleep: LPM3
    while (i<3)
    {
        __bis_SR_register(LPM3_bits + GIE); //go to sleep: LPM3
        if (tx) {
            pTx++;
        }
        else {
            if (!strncmp(incoming, configCmdAck[i], strlen(configCmdAck[i])))
            {
                pTx = testack;
                i++;
                redflag = T;
            }
            pRx++;  //see note below...Do not put at end of loop!
            if (redflag) {
//                redflag = F;
/*URGENT: Setting UCTXIFG must be the last line of code. If set earlier we will go into ISR, come out and process the next line of code
 * before going back into ISR because TXIFG will get set because of TXBUF going empty...This unfortunate event will promote a double character instance.
 * redflag will alert us that we want to go back into ISR...hence prepare everything, create redflag then use it at very end of if statement to generate ISR
 * such that when we return we will move to next line of code (ie LPM3 sleep), then TXIFG will wake us at beginning again.
*/
                UCA1IFG |= UCTXIFG;
            }
        }
    }
    UCA1IE &= ~UCTXIE;
    __bis_SR_register(LPM3_bits + GIE);
}


#pragma vector=USCI_A1_VECTOR
__interrupt void M(void)
{
    switch(__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG))
    {
      case USCI_NONE: break;
      case USCI_UART_UCRXIFG:
          tx = F;
          *pRx = UCA1RXBUF;
          __bic_SR_register_on_exit(LPM3_bits);
          break;
      case USCI_UART_UCTXIFG:
          tx = T;
          if (*pTx != '\0')
              UCA1TXBUF = *pTx;
          else {
              if (redflag) {
                  redflag = F;
                  pRx = incoming;
                  pTx = configCmdAck[i];
                  for (r = 0; r<2000; r++); //2000 minimum
                  UCA1TXBUF = *pTx;
              }
          }
          __bic_SR_register_on_exit(LPM3_bits);
          break;
      case USCI_UART_UCSTTIFG: break;
      case USCI_UART_UCTXCPTIFG: break;
    }
}

  • After further investigation I removed the opportunity for the transmit pointer to move forward after the first command, echo, ACK and my code does not seem to do weird stuff while connected to the debugger....Now the question is (I am using a MSP430FR2355 EVM), when I pause then stop the debugger and press the reset button on the EVM the debugger LEDs alternate flashing RED and GREEN....Further troubleshooting with a GPIO indicates that it is resetting every ~450ms...I have the watchdog disabled, can anyone tell me why the code wouldn't just run through as above on the debugger and go into LPM3 and just sit there until I hit the reset again.  I am powered off the USB same as when debugger is connected.  I have the 3.3V, GND, SBWTDIO and SBWTCK jumpers connected, once again no different than when I am hooked to debugger.

    ...A follow up on debugging....If I go into LPM3 with GIE just before while loop AND disable TXIE the LEDs do NOT flash RED, GREEN, on and on when the debugger is removed....It clearly has something to do with enabling the TXIE bit.

    I have included the code for the ISR (nothing special).....I am out of ideas as to why the EVM keeps resetting off of debugger????

    void initUART(void)
    {
        UCA1CTLW0 = UCSWRST;                      // Put eUSCI in reset
    
        UCA1CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK
        UCA1BR0 = 52;                               // 16000000/16/115200 : 8
        UCA1BR1 = 0x00;
        UCA1MCTLW |= UCOS16 | UCBRF_1 | 0x4900;   //0xF700 is UCBRSx = 0xF7 : UCBRF_10
    
        UCA1CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
        UCA1IE |= UCRXIE | UCTXIE;// | UCTXCPTIE;             // Enable USCI_A0 RX interrupt and TX complete
    }
    

     

    Thoughts?

    Thanks

    Steve

  • Hi, Steve, 

    Do you run the code on the MSP430FR2355 LuanchPad (there is debugger eZ-FET on the launchpad) or the MSP430FR2355 Target board and debugger is the MSP-FET?  

    It is strange the debugger LEDs alternate flashing RED and GREEN and reset every ~450ms. Could you have tried different code (for example MSP430FR2355 code examples) to see similar issue? 

    I will take some time to check your code and feedback to you. 

    Thanks, 

    Lixin 

  • Lixin.....

    I am running on the LaunchPad....and it is definitely code going off somewhere and causing the board to reset.  I have been able to turn off TXIE and all issues go away.

    ....more info.....I have a very stable version of code when CCS is connected that ALWAYS runs then sleeps....works very well....If I then close CCS and hit the reset button on the LaunchPad the Red, Green repeat begins....HOWEVER if I connect a 3.3V power source to the TARGET side of the EVM all looks good....I then disconnected USB from Laptop and ran 5V from a bench supply to the LaunchPad and got the same Red, Green, repeat pattern...Finally I removed the SBWTCK and SBWTDIO jumpers between Target and Programmer and still with bench supply I have the issue....I took a scope picture of the 3.3V power on the target side when this was occurring....It is clear to me that there is an issue with the firmware on the LaunchPad programmer and the Software controlled DC/DC converter....

    badPwr.docx

    Thanks

    Steve

  • Hi, Steve, 

    Sorry for late the reply. 

    It seems you have found the root cause: LaunchPad programmer failed on the DC/DC converter control. Do you have changed to another LaunchPad to confirm this finding? If it is confirmed, there should be something wrong on the LaunchPad programmer power circuit.

    I don't think it will be software issue of the programmer because the programmer software should not be changed in the flash. It may be hardware issue. The suggestion is changing to another LaunchPad for your code debug. 

    Thanks, 

    Lixin 

**Attention** This is a public forum