Skip to main content
d_steffen
Associate II
November 5, 2008
Question

UART TX finished interrupt needed

  • November 5, 2008
  • 12 replies
  • 2649 views
Posted on November 05, 2008 at 22:02

UART TX finished interrupt needed

This topic has been closed for replies.

12 replies

paulsmitton9
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:45

Barricade: did you find a solution to your problem?

Or has anyone else found how to detect end of transmission without polling?

Cheers,

Paul :)

mark9
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:45

Thank you all for the discussion. I've been tearing my hair out trying to figure out how to do it. I did the BUSY-polling method, but that didn't work, since the latency was too high and the peer on the RS485 was replying before I could turn the bus direction around. I was about to use a timer (that would trigger after the last TX interrupt), but that seemed messy.

I believe that the best solution is just to use the Loop Back (as Paul Smitton figured out) and basically use the RX interrupt to deal with the problem of the TX interrupt. I am not using DMA, but just normal interrupts. This works great!

Basically, turn on UART0->CR |= LBE, set a counter for the number of bytes in the outgoing packet, set a flag meaning ''write'' mode is asserted, and finally enable TX mode on the RS485 bus.

Then in the ISR, check if ''write'' mode is asserted, and if it is, then decrement the counter. When it hits 0, then disable LBE, disable TX mode and unset the flag meaning ''read'' mode.

Works great! Thanks Paul.

-Mark