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/MSP430FR5994: MSP430FR5994: UART – The first byte is not received, transmission starts only from the second byte

Part Number: MSP430FR5994

Tool/software: Code Composer Studio

Hello,

I have the problem that in the received data string often (but not always) the first byte of an incoming string is ignored (isn't received at all) by the MSP430FR5994. When I use an external "serial port monitor" software, it shows that all the incoming bytes looks right. So the problem must be somewhere in the MSP430FR5994 interrupt function, witch ignore the first received byte. All other bytes are received well. As soon as the first byte is the address byte, and I don't know if, or if not, the first byte is received, it seems impossible to say "always ignore the first byte, and start transmission with the second byte", as I read in some forums.

For information, the MSP430FR5994 sending data string works well. I use P54 and P55 with 115200bps for this UART.

void initUART2(void)   //UART_2
{   UCA2CTLW0 = UCSWRST;
    UCA2CTLW0 |= UCSSEL__SMCLK;
    UCA2BR0 = 2;
    UCA2BR1 = 0x00;
    UCA2MCTLW |= UCOS16 | UCBRF_2 | 0x0300;
    UCA2CTLW0 &= ~UCSWRST;
    UCA2IE |= UCRXIE;
    received_bytes=0;
    unsigned int i;
    for (i=0;i<LENGHT_BUFFER;i++)
       {recbuf[i]=0x00;}
}

#pragma vector=USCI_A2_VECTOR
__interrupt void usart2_rx(void)
{  recbuf[received_bytes]= UCA2RXBUF;
   received_bytes+=1;
}

int main(void)
{  ...
   initPorts();
   initUART2();
   ...
   while(1)
      {...   //do something with recbuf[]
      if (nothing else to do)
         {LPM1;}
      }
}

What should I change to receive securely all the bytes by the MSP430FR5994?

Thank you very much for your help.

  • Hi, 

    1. Does the issue still occur when reducing the baud rate to lower speed, such as 9600? 

    2. Do you have used the low power mode for receiving the UART data? If yes, the UART clock source SMCLK wake-up time needs to be considered. It is mentioned in the section 24.3.14 of user's guide slau367. 

    Thanks, 

    Lixin 

  • Thank you very much for this information.

    1. Unfortunately I could not test it with 9600, because our sensor only works with 115200bps.

    2. The LPM-Modes seems to be the source of the problem. When I remove the line "LPM1;", then the UART works fine again. No missing first byte is detected, and all the bytes are received correctly.

    Does someone know a solution to use the UART from LPM1? Or must we found an other round-around to solve this problem differently.

    Thanks a lot.

  • Hi, 

    Here are some workarounds: 

    1. Make a custom UART protocol to define the first byte as dummy data so the receiver can discard it. 

    2. Send a GPIO signal signal 10~20us ahead of the UART start edge to wake up from LPM1 firstly before receiving the UART data. 

    Thanks, 

    Lixin 

  • Thank you very much for your Answer.

    1. It is difficult in my case, because sometimes the first byte is received, sometimes not. Furthermore the protocol of the sensor is fixed by the manufacturer.

    2. I will try to find a solution with a second GPIO interrupt to exit the LPM1 mode. That should be possible.

**Attention** This is a public forum