Other Parts Discussed in Thread: MSP430F149
Tool/software: Code Composer Studio
I use the MSP430FR5994 with an RS-485 Transceiver (SN65HVD12D).
The RS485 transmission begins always with the setting of the RE and DE pins to TX mode (of the RS-485 Transceiver). After that several Bytes are send trough the bus. And finally, we returned in the RX mode for receiving the answer. But before we could do that, we must wait that the transmit buffer is empty. I found several examples using the following command "while((UTCTL1 & TXEPT)==0x00) _NOP();". It works well for the MSP430F149, but not for the MSP430FR5994.
Do someone knew the right command for the waiting time before we could return in the receive mode? It is the time until the TX buffer is empty.
//Sending one single Byte
void sendRS232(unsigned char data) // sends one byte
{ while (!(UCA1IFG & UCTXIFG)); // loop until USART1 TX buffer ready
UCA1TXBUF = data;
}
//Sending an rs485 command
{ RS485TX; //Set RS485 transceiver output Pins to TX
unsigned int i;
for (i=0;i<size;i++)
{sendRS232(data[i]);}
while((UTCTL1 & TXEPT)==0x00) _NOP(); //wait for transmitter empty (false command for the MSP430FR4995)
RS485RX; //Set RS485 transceiver output Pins to RX
}