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 support@ccsinfo.com

Start bit, stop bit and RS232

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







Start bit, stop bit and RS232
PostPosted: Mon Dec 10, 2007 11:50 am     Reply with quote

When I use this command

#use RS232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7)

Does the start bit and stop bit generated automatically by CCS compiler?
I use CCS ver. 3.249 and pic 16F877a. Thanks in advance for all your help!
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon Dec 10, 2007 12:26 pm     Reply with quote

Yes, either the compiler or the UART will generate the Start & Stop bits for you. The line will idle in the Stop bit condition. When you send a byte the line will go to Start bit for one bit time, then cycle through LSB to MSB, and return to Stop bit of at least one bit time, or until you send another byte.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Sat Jan 19, 2008 9:13 am     Reply with quote

If I'm sending 8-bit data,for example '0b01010101' to TX, then at RX, am I need to consider the start bit and stop bit when getc()? Meaning that adding two extra bit to the receive signal?
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Jan 19, 2008 11:02 am     Reply with quote

This is a typical consult of somebody coming from the Assembler, am I wrong?

From the C language poit of view, by definition the getc() function returns the next
character from the input data stream.
From the hardware point of view - as SherpaDoug said - the UART is who take care of the
Start and Stop bits.

Quote:

If I'm sending 8-bit data,for example '0b01010101' to TX

I show you 3 ways to do that:
putc(0b01010101);
putc(0x55);
putc('U');


and you will see the full character (including Start and Stop bits) coming out from the
defined Tx pin.


Humberto
in



Joined: 18 Jan 2008
Posts: 2

View user's profile Send private message

PostPosted: Sat Jan 19, 2008 12:00 pm     Reply with quote

I've tried "putc(0b01010101)", and I saw 10-bit '0010101011' coming out, and also with an extra high bit in front of the 10-bit.

The question now is when I use getc() function at the RX pin, the data that I need to process is '0b0010101011' or '0b10010101011' due to the idle bit in front, or just the original sent data '0b01010101'?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jan 19, 2008 12:11 pm     Reply with quote

Quote:
I'm sending 8-bit data,for example '0b01010101' to TX, then at RX, am I need to consider the start bit and stop bit when getc()?

No. The start and stop bits are handled internally by the compiler or
the PIC hardware. The getc() and putc() functions only use 8-bit data.
You don't need to append or strip the start and stop bits. You (as the
programmer) don't have to handle the start and stop bits.
in



Joined: 18 Jan 2008
Posts: 2

View user's profile Send private message

PostPosted: Sat Jan 19, 2008 9:21 pm     Reply with quote

IC..Thank you!
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