rs485 Serial3 wait for transmission to complete

Hello,

i’m using rs485 for communication and i’d like to optimize sending process, right now it work this way:

  1. set to send
  2. send data
  3. wait fixed amount of time
  4. set to receive

I would like to change point 3 to “wait until all data are send”. I found on iternet code like this:

 while (!(UCSR0A & (1 << TXC0)));   // Wait for the transmision to complete
 while (!(UCSR0A & (1 << UDRE0))); // Wait for empty transmit buffer

But this look like code for Serial0 to me. I’m using Serial3 on my due. I can’t test it right now but will change TXC0 to TXC3 work ? Or do i need to change register UCSR0A too ? I’m not able to test it now, and i have limited time for this so i would like to prepare solution or solution in advance.

thanks for help

Matus