Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
How best to poll UART bit
Posted: Fri Apr 18, 2008 9:04 am
I need to find when the hardware UART transmit buffer is empty so I can shut off the RS485 driver. For odd reasons I can't simply use the enable option of the #use rs232 statement. From the PIC18F2528 datasheet it seems I need to monitor TXSTA bit 1. But I can't find and address for the TXSTA register in either the CCS 18F2585.h file or the datasheet.
If I could fine the address I could write a line like this:
#BIT TXSTA_TRMT = 0x????.1 //Transmit buffer empty
Where should I look for the address? Is there a better way? _________________ The search for better is endless. Instead simply find very good and get the job done.
Matro Guest
Posted: Fri Apr 18, 2008 9:17 am
TXSTA is at address 0xFAC
TRMT is #BIT 0xFAC.1
You can also poll the TXIF bit (in progress transmission flag) is it is better for your application. But polling TRMT is definitely the way to know if the transmit buffer is empty or not.
SFR mapping is (as Microchip used to) in section "Memory organization" of the datasheet (SFR mapping starts at page 70).
Matro
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
Posted: Fri Apr 18, 2008 9:48 am
Thanks, I knew it had to be somewhere in the @#$%^ 484 page datasheet!
It looks like PIR1_TXIF (0xF9F.4) is set when the final data bit is clocked out. You wouldn't happen to know if it is at the beginning or end of the Stop bit? I need to generate a 5ms break character (long start bit) on the RS485 line to synchronize data collection. _________________ The search for better is endless. Instead simply find very good and get the job done.
ThomasC
Joined: 09 Oct 2007 Posts: 62
Posted: Fri Apr 18, 2008 3:54 pm
This thread may further help you. It worked for me!
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum