View previous topic :: View next topic |
Author |
Message |
reini
Joined: 15 Jul 2005 Posts: 1
|
rs232 with 7bit 2stop bit |
Posted: Fri Jul 15, 2005 10:15 am |
|
|
help! how can you use the integratet UART with 7bit and 2stop bit?
PIC18F4550. I did not find any information to any PIC with UART. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Jul 15, 2005 11:01 am |
|
|
There is no direct support for 7N2, both in hardware or software UART. It is easy to simulate when you realise that a stop bit equals a databit with a logic high level. Data is transmitted with the least significant bit first. The trick is to configure RS-232 for 8N1 and make sure to set the most significant bit (MSB) for every byte sent.
Code: | #use rs232(baud=9600, xmit=PIN_TX, rcv=PIN_RX, parity=N, bits=8)
// Function to send data as 7 bits, 2 stop bits.
void Put7N2(int8 Databyte)
{
bit_set(DataByte, 7); // Simulate an extra stop bit by setting the MSB
putc(DataByte);
}
void main()
{
printf(Put7N2, "Hello world.\n\r");
while(1) ; // Loop forever, prevent the processor going to sleep
}
|
Note: I haven't tested this code, but you get the idea. |
|
|
|