View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Indication of Pending Hardware TX |
Posted: Mon Apr 16, 2007 6:29 pm |
|
|
Hello All,
I just had stroke of brilliance....
Instead of placing a delay_ms after printfs to avoid losing data when I shut attached radios down, I'd like to check and see if there is any pending data on the hardware RS232 port. Once all the pending data is sent, then I can shut the radio down.
What do I check to see if there is nothing left for TX in the RS232 port?
Thanks,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 17, 2007 1:55 am |
|
|
Test the TRMT bit. If it's high, then the 1 or 2 bytes that were pending
transmission in the hardware UART have been sent. Though, according to
the timing diagram in the 16F877 data sheet, TRMT goes high before
the final stop bit is sent on the last byte. So you really should wait for
one bit time after TRMT goes high (assuming only one stop bit is used). |
|
|
|