I need to implement RS485 at 115200 baud, so I'm using the DMAC to send data to eliminate the interrupts. I need to turn off my transmit buffer once the last byte has been shifted out.
The question is, how do I reliably determine that the last byte the DMA has written to the USART has completely been shifted out?
I assume I can clear the TXCIF flag in the DMA complete ISR (as it may well be already set due to non-deterministic DMA timing), and enable the TXCIF interrupt which, when it is actioned, will turn off the buffer. This of course assumes the DMA complete interrupt ISR will be actioned before the last byte is fully shifted out.
Anyone done this?