View previous topic :: View next topic |
Author |
Message |
Guest123 Guest
|
Start bit, stop bit and RS232 |
Posted: Mon Dec 10, 2007 11:50 am |
|
|
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
|
|
Posted: Mon Dec 10, 2007 12:26 pm |
|
|
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
|
|
Posted: Sat Jan 19, 2008 9:13 am |
|
|
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
|
|
Posted: Sat Jan 19, 2008 11:02 am |
|
|
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
|
|
Posted: Sat Jan 19, 2008 12:00 pm |
|
|
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
|
|
Posted: Sat Jan 19, 2008 12:11 pm |
|
|
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
|
|
Posted: Sat Jan 19, 2008 9:21 pm |
|
|
IC..Thank you! |
|
|
|