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.

MSP430 and RS485 communication

Other Parts Discussed in Thread: MSP430F5438

Hi all,

I am trying to give rs 485 connectivity to my MSP430F5438 kit. As per suggestions to control direction pin i have written following code.

 

while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?     

      P1OUT |= BIT0;                          // P1.0 = 1                

     UCA0TXBUF = UCA3RXBUF;          

     if(UCA0STAT == UCBUSY);              

        P1OUT &= ~BIT0;

 

But the problem is when i try to communicate and transmit transmitter misses some character after every 14-18 character.

Please help me implementing the same.Are there some other methods to do this?

 

Regards.

  • Looks good.

    However, this runs (as required for the RS485 control) in busy.waiting mode. You receive on UCA3 and send on UCA0. With all this busy-waiting, it is possible that you get a receive buffer overflow on UCA3. YOu see, you only start sending after you received a byte, but then you wait until the byte is sent, then you toggle around with the 485 control. These cycles sum up while on UCA3 the data comes in with full speed.

    So when UCA0 and UCA3 are running with the same baudrate, it is no wonder - you are sendiing slower (by the control overhead) than you are receiving.

  • Hi,

    Can any TI employee please give me a solution?

    I am not getting where is the exact problem. Or if possible please give me any sample code for the same.

     

    Regards. 

  • Pallav Gandhi said:
    I am not getting where is the exact problem.

    The problem is the program logic.
    let's assume the baudrate is 10000.

    You are receiving data every ms. One byte per ms, 1000 byte sper second. That's the input rate.

    On the output, you enable the RS485. Takes 0.1ms. Then you send one byte. Takes 1ms. Then you disable RS485. Takes 0.1ms. Then you loop. Takes 0.1ms. Total 1.3ms per byte.

    So your data comes in with 10000Bd, 1ms per byte with no gap in between, but it goes out with 10000Bd but with a 0.3ms gap in between. So while you are outputting with 10000Bd too, you're only sending 770bytes per second. You do not buffer the incoming data in your code, so you'll lose every 5th byte in this constellation.

    Now the values are different on your code and the overhead for the 485 control is smaller, so you lose only every 18th byte or so, but that's what happens and why.

**Attention** This is a public forum