View previous topic :: View next topic |
Author |
Message |
Rikus
Joined: 06 Oct 2006 Posts: 4
|
Question regarding #use RS232 |
Posted: Wed Nov 22, 2006 12:18 pm |
|
|
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
|
|
Posted: Wed Nov 22, 2006 12:56 pm |
|
|
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
|
Thanks |
Posted: Thu Nov 23, 2006 1:23 am |
|
|
Thanks for your help David. I'll change the code accordingly. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 23, 2006 2:15 am |
|
|
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
|
|
Posted: Thu Nov 23, 2006 3:55 am |
|
|
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
|
|
Posted: Thu Nov 23, 2006 9:42 am |
|
|
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 |
|
|
|