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

Question regarding #use RS232

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



Joined: 06 Oct 2006
Posts: 4

View user's profile Send private message

Question regarding #use RS232
PostPosted: Wed Nov 22, 2006 12:18 pm     Reply with quote

Good day. I have a question regarding the #use RS232 command. I need to transmit 8 data bits via serial communication form a 16F690 to a 16F876A. I used the following command in CCS:

Code:
#use RS232(baud=9600,parity = N,BITS = 8, xmit = PIN_B7, rcv = PIN_B5)


Now, does the BITS = 8 statement mean that is sends 8 bits including the stop and start bit or is that excluding? Should I change the statement to BITS = 10 to transmit 8 data bits?
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Wed Nov 22, 2006 12:56 pm     Reply with quote

Yes, the start and stop bits are always included. BITS refers only to the number of data bits.
_________________
David
Rikus



Joined: 06 Oct 2006
Posts: 4

View user's profile Send private message

Thanks
PostPosted: Thu Nov 23, 2006 1:23 am     Reply with quote

Thanks for your help David. I'll change the code accordingly.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 23, 2006 2:15 am     Reply with quote

Quote:

I need to transmit 8 data bits.

#use RS232(baud=9600,parity = N,BITS = 8, xmit = PIN_B7, rcv=PIN_B5)

I'll change the code accordingly.

Your #use rs232() statement is already correct. "Bits" refers to the
number of data bits that will be sent. It doesn't refer to the Start
and Stop bits.

With your code above, the UART in the 16F690 will send:
1 start bit
8 data bits
1 stop bit

That's exactly what you want. You don't have to change anything.
Rikus



Joined: 06 Oct 2006
Posts: 4

View user's profile Send private message

PostPosted: Thu Nov 23, 2006 3:55 am     Reply with quote

Ok. Thanks. I also tried changing it to 10 bits, but it didn't work. The compiler command BITS = 8 only takes a number up to 9. Thanks for all your help.
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Thu Nov 23, 2006 9:42 am     Reply with quote

From the Reference Manual:

BITS=x Where x is 5-9 (5-7 may not be used with the SCI).

SCI refers to the hardware UART.

ALL PIC hardware UARTs have 8 data bits, some have 8 or 9 data bits.

The software UART the complier generates can have 5 - 9 data bits.
_________________
David
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