UART corrupted data

uart

I have connected a msp430 with a sensor via max3232 and I am able to see the incoming data. But the problem is that the 9 bytes of the data are ok but then the data get corrupted.
The baudrate I am using 9600 is the same the sensor uses If u connect it to the pc.
If you can point me on what can be the error I would really appreciate it.

Best Answer

What is the max Baud Rate that works error free?

Added: I think that your UART function has an overrun; can you check?

RX ISR should be really short, something like this:

 #pragma vector=USCIAB1RX_VECTOR

  __interrupt void USCI1RX_ISR (void)
{
   char temp = UCA1RXBUF;
   if (pos < BUFFER_LEN) buffer[pos++] = temp;
   // Add call to intrinsic function to clear SR on exit, like _BIC_SR_IRQ(LPM3_BITS);
}

Then code in main() can watch the value of pos and the characters in the buffer to decide what to do.