CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How best to poll UART bit

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

How best to poll UART bit
PostPosted: Fri Apr 18, 2008 9:04 am     Reply with quote

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







PostPosted: Fri Apr 18, 2008 9:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 18, 2008 9:48 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 18, 2008 3:54 pm     Reply with quote

This thread may further help you. It worked for me!

http://www.ccsinfo.com/forum/viewtopic.php?t=22649&highlight=txif
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group