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/MSP-EXP430FR5994: Software execution stop after a random time period and UART communication

Part Number: MSP-EXP430FR5994
Other Parts Discussed in Thread: MSP430FR5994

Tool/software: Code Composer Studio

I am working with the MSP430FR5994 devkit hardware. I am experiencing the following problem: during the UART communication, the software execution stop after a random time period.

My while structure:

while(1)
{
    LED toggle on P1.1 pin  (for oscilloscope tracking)

    if (ISRflag=1)
    {
        Read I2C sensor data
        Data conversion
        Send data over UART
    }
}

I query the sensor at a 10ms time interval. When UART data transfer is switched OFF, the code running without any problem.

When the UART data transfer switched ON, the code execution terminated after a random period of time. This random time period varies, it sometimes happen after 1 minute, sometimes after 15-20 minutes, etc. During the code execution, I measure square signal at the P1.1 pin. When the code execution terminated randomly, the status of P1.1 shows continues L or H level.

My UART init code:

void uartInit()
{
    P2SEL0 &= ~(BIT0 | BIT1);
    P2SEL1 |= BIT0 | BIT1;                  // USCI_A0 UART operation

    // Configure USCI_A0 for UART mode
    UCA0CTLW0 = UCSWRST;                    // Put eUSCI in reset
    UCA0CTLW0 |= UCSSEL__SMCLK;             // CLK = SMCLK 8MHz
    UCA0BRW = 4;                            // 8000000/16/115200bps
    UCA0MCTLW |= UCOS16 | UCBRF_5 | 0x5500; // UCBRSx value = 0x55 (See UG)
    UCA0CTLW0 &= ~UCSWRST;                  // Initialize eUSCI
    UCA0IE |= UCRXIE;                       // Enable USCI_A0 RX interrupt
test.newStringReceived = FALSE; }

UART interrupt routine:

#pragma vector=EUSCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
//	int receiveByte = UCA0RXBUF;
//	UCA0TXBUF = receiveByte;

    switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
    {
        case USCI_NONE:
        	break;

        case USCI_UART_UCRXIFG:
            RTS_CLEAR;
            char data = UCA0RXBUF;  //RXBUF0;

            //#define ECHO_ON
        #ifdef ECHO_ON
            while (!(IFG1 & UTXIFG0));                // USART0 TX buffer ready?
            TXBUF0 = data;                          // RXBUF0 to TXBUF0
        #endif

            uartReceive(data);
            if(test.newStringReceived == TRUE){
        //        _bic_SR_register_on_exit(LPM4_bits); /* Exit Low Power Mode 4 */
            }
            RTS_SET;
            break;

        case USCI_UART_UCTXIFG:
        	break;

        case USCI_UART_UCSTTIFG:
        	break;

        case USCI_UART_UCTXCPTIFG:
        	break;

        default:
        	break;
    }

    __bic_SR_register_on_exit(LPM0_bits);   // Exit active CPU
}

Transmission routine:

void sendBytes(int len){
	
   unsigned int i;

	for (i = 0; i < len; ++i)
    {
	   // wait until UART ready
	   while (!(UCA0IFG & UCTXIFG));             // USCI_A0 TX buffer ready?
	   UCA0TXBUF = test.txString[i];
    }
}

String definition in uart_driver.h file:

typedef struct {
	unsigned char newStringReceived;
	char          txString[MAX_STR_LENGTH];
	char          rxString[MAX_STR_LENGTH];
}s_test;

extern s_test test;

From main.c:

while(1)
	{
            LED2_TOGGLE();

		if (readDataFlag)
		{
			readDataFlag = 0;
			AFE44xx_SPO2_Data_buf[0] = AFE4404_Reg_Read(42);  //read LED2 Data
			AFE44xx_SPO2_Data_buf[1] = AFE4404_Reg_Read(43);  //read LED3 data
			AFE44xx_SPO2_Data_buf[2] = AFE4404_Reg_Read(44);  //read LED1 Data
			AFE44xx_SPO2_Data_buf[3] = AFE4404_Reg_Read(45);  //read Ambient Data
			AFE44xx_SPO2_Data_buf[4] = AFE4404_Reg_Read(46);  //read LED2 - LED3 Data
			AFE44xx_SPO2_Data_buf[5] = AFE4404_Reg_Read(47);  //read LED1 - Ambient Data
			sendDataFlag = 1;
		}

		if (sendDataFlag)
		{
			statHRMAlgo (AFE44xx_SPO2_Data_buf[5]);
			// Overwrite LED2-AMB2 with Heart rate
			AFE44xx_SPO2_Data_buf[4] = HeartRate;

			sendDataFlag = 0;

			test.txString[0] = (unsigned char)(AFE44xx_SPO2_Data_buf[0] & 0x000000FF);  // LED2 Data
			test.txString[1] = (unsigned char)((AFE44xx_SPO2_Data_buf[0] & 0x0000FF00) >> 8);
			test.txString[2] = (unsigned char)((AFE44xx_SPO2_Data_buf[0] & 0x00FF0000) >> 16);

			test.txString[3] = (unsigned char)(AFE44xx_SPO2_Data_buf[1] & 0x000000FF);  // LED3 data
			test.txString[4] = (unsigned char)((AFE44xx_SPO2_Data_buf[1] & 0x0000FF00) >> 8);
			test.txString[5] = (unsigned char)((AFE44xx_SPO2_Data_buf[1] & 0x00FF0000) >> 16);

			test.txString[6] = (unsigned char)(AFE44xx_SPO2_Data_buf[2] & 0x000000FF);  // LED1 Data
			test.txString[7] = (unsigned char)((AFE44xx_SPO2_Data_buf[2] & 0x0000FF00) >> 8);
			test.txString[8] = (unsigned char)((AFE44xx_SPO2_Data_buf[2] & 0x00FF0000) >> 16);

			test.txString[9] = (unsigned char)(AFE44xx_SPO2_Data_buf[3] & 0x000000FF);  // Ambient Data
			test.txString[10] = (unsigned char)((AFE44xx_SPO2_Data_buf[3] & 0x0000FF00) >> 8);
			test.txString[11] = (unsigned char)((AFE44xx_SPO2_Data_buf[3] & 0x00FF0000) >> 16);


			//txString[12] = (unsigned char) EOT;
			test.txString[13] = (unsigned char) HeartRate;
			test.txString[14] = (unsigned char) LF;
			test.txString[25] = (unsigned char) CR;

			printf(test.txString);
			sendBytes(16); //Send UART data string  115200bps & 22byte = 1.90972222ms
		}


	}

/*******************************************************************************
 * Port 3 interrupt service routine
 ******************************************************************************/

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT3_VECTOR
__interrupt void port3_isr_handler(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT3_VECTOR))) port3_isr_handler (void)
#else
#error Compiler not supported!
#endif
{
    switch(__even_in_range(P3IV, P3IV__P3IFG7))
    {
        case P3IV__NONE:
        	break;          // Vector  0:  No interrupt
        case P3IV__P3IFG0:
        	break;          // Vector  2:  P1.0 interrupt flag
        case P3IV__P3IFG1:
            break;			// Vector  4:  P1.1 interrupt flag
        case P3IV__P3IFG2:
        	break;          // Vector  6:  P1.2 interrupt flag
        case P3IV__P3IFG3:
        	break;          // Vector  8:  P1.3 interrupt flag
        case P3IV__P3IFG4:
        	break;          // Vector  10:  P1.4 interrupt flag
        case P3IV__P3IFG5:
        	break;          // Vector  12:  P1.5 interrupt flag
        case P3IV__P3IFG6:
        	LED1_TOGGLE();  // Diag
        	readDataFlag = 1;  // Set Flag to read AFE44x0 ADC REG data
        	break;          // Vector  14:  P1.6 interrupt flag
        case P3IV__P3IFG7:
        	break;          // Vector  16:  P1.7 interrupt flag
        default:
        	break;
    }
}

**Attention** This is a public forum