Msp430 DMA UART for Modbus

dmamsp430rs485

I am using MSP430 UART with DMA transfer for sending Modbus packets. As a master at the end of packer I need to change my RS 485 transceiver direction line for reception.
I am sending 10 bytes in packet and at the end of last byte sent I want to change direction line. But DMA interrupt occurs when byte count reaches to zero and not when last byte is transferred. Hence I change the line in DMA interrupt my last byte will not pass through transceiver.

Best Answer

When the DMA has handled the last byte, you need to wait for the UART to be no longer busy (typically, this is indicated by the UCBUSY bit).

If your chip does not have an interrupt for that, you need to poll the bit, or use a timer that waits for 10 bit times.