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.

MSP430F5358: UART0 Overrun Rx

Part Number: MSP430F5358
Other Parts Discussed in Thread: MSP430F5510

Tool/software:

Hi Everyone,

I'm trying to implement a serial communication via UART between my MSP430F5358 chip and another microcontroller (Atmel AtxMega32e5). I set a receive interrupt on Uart0 in order to receive messages from the other micro. The unit of measurement of the message is the byte, that is, the interrupt is triggered when a byte arrives on the Uart_Rx pin. Which the serial works with a baud rate of 115.2 KHz (the same that the Atmel serial has set) -> each bit lasts about 8.6us.
The problem I have is that when I receive "long" messages the serial seems to overrun, unable to keep up with the bytes that arrive (which are gradually saved in a circular buffer). The final part of the message is always dirty and this means that the entire implemented message parsing protocol does not work correctly, returning an error on the framing of the received message.

Example (short message):
Message actually received (viewed with the oscilloscope):
0x55, 0x02, 0x7F (message Tag), 0x03
Message read in dubug on UART0:
0x55, 0x02, 0x7F (message Tag), 0x03        (OK!!)

Example (long message):
Message actually received (viewed with the oscilloscope):
0x55, 0x02, 0xB0(message Tag), 0x00 , 0x00, 0x00, 0x00, 0x03
Message read in dubug on UART0:
0x55, 0x02, 0xB0(message Tag), 0x00 , 0x00      (3 bytes missing!!)

At the moment I have verified the following things:
- the baud rate is precise and the same for both serial ports (equal to 115.2KHz).;
- the interrupt function in reception responds and works correctly, resulting in a correct timing with each single incoming byte (verified by inserting a toggle of a GPIO pin at each execution of the interrupt);
- there are no spurious interrupts that could cause problems in the reception timing;

This is the function for UART setting:

void InitUartMan(void)
{
   UCA0CTL1 |= UCSWRST; // disable USCI module, enable settings change

   UCA0CTL0 &= ~UC7BIT;                 // 8-bit data
   UCA0CTL1 |= UCSSEL__ACLK;     // UCLK = ACLK
   UCA0BRW_L = BAUD115;               // 115200 bps baudrate @ ACLK = 4096000Hz.
   UCA0BRW_H = BAUD0;
   UCA0MCTL = 0x00;            

   UCA0CTL1 &= ~(UCSWRST);         // enable USCI module, disable settings change

   UCA0IE |= UCRXIE;                        // receive interrupt enable, transmit interrupt disable

   AckCmdMan = 0;                             // init command status
}

 and this is the interrupt function written for the reception on UART0:

#pragma vector=USCI_A0_VECTOR
__interrupt void UartRx0(void)
{
    char rxchar;

    rxchar = UCA0RXBUF;              // save received byte.

   *InpkcqMan.wr++ = rxchar;         // Circular buffering of input data.
    if(InpkcqMan.wr>InpkcqMan.top)
    InpkcqMan.wr = InpkcqMan.bot;

}

If anyone has any advice to give me to solve this problem I would be grateful!

Many Thanks!!

Matteo

  • What is running MCLK of MSP430F5358? Maybe problem is somewhere else. Don't know about C compiler optimization of interrupt function, and how much lite it is (in CPU cycles) at the end. Maybe I am reading wrong but why two and not one "+" in this line...

     *InpkcqMan.wr++ = rxchar; 

    Because I guess that one byte is received, not two.

    I was able to push MSP430F5510 @ 24 MHz on highly optimized assembler code to receive on both UART's @ 4Mbps (sent from two MSP430x2xx without any delays at the same time in parallel) and send them to PC over CDC without losing any characters.

  • Hi zrno,

    My MSP430F5358 has an external clock source of 8MHz. The clock source used by the Uart to generate the baud rate is ACLK=8/2=4MHz. As for the maximum speed that can be set, I am forced to keep the speed at 115.2KHz. I absolutely must be able to make everything work at this speed.
    Having said that, do you have any further advice for me?
    Thanks.

    Matteo

  • You should try increasing the speed of MCLK.

    I am a little confused as to the actual bit rate. At different places the input to the bit rate clock is 4MHz or 4.096MHz. One gets you a precise bit rate and the other doesn't. Perhaps details on the setup of the clock system and this external clock source would clear things up.

**Attention** This is a public forum