View previous topic :: View next topic |
Author |
Message |
Jasen
Joined: 31 Aug 2009 Posts: 6
|
Receive 7 bits communication |
Posted: Mon Aug 31, 2009 12:59 pm |
|
|
I have a device thats send data = 7 bits and stop bit=2. How can i proceed to read this variable using PIC16F648A. |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 31, 2009 1:27 pm |
|
|
Just don't worry about it!...
When receiving, extra stop bits don't matter.
If you just receive the data as 8bit, one stop, and clear the top bit of the received byte, it'll receive correctly.
Best Wishes |
|
|
Jasen
Joined: 31 Aug 2009 Posts: 6
|
|
Posted: Mon Aug 31, 2009 1:48 pm |
|
|
I create this following test program to make sure that the PIC16F648A will read correctly the 7 bits data.
Code: |
#use rs232(baud=4800, xmit=pin_b2, rcv=pin_b1)
if ( getc() == 12) output_high (pin_b6);
|
With external PC communication program, I simulated sending by RS232 the data 12. The output goes hi only when I set 8 bits data on the PC communication program. With 7 bits, the output keep low.
Tks, Jasen |
|
|
Ttelmah Guest
|
|
Posted: Mon Aug 31, 2009 2:20 pm |
|
|
You are not clearing the top bit (& 0x7F).....
Best Wishes |
|
|
Jasen
Joined: 31 Aug 2009 Posts: 6
|
|
Posted: Mon Aug 31, 2009 2:52 pm |
|
|
Could you give me a Hint how to clearing top Bit.
Tks, Jasen |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Aug 31, 2009 3:23 pm |
|
|
You missed something...
Though clearing a bit is standard C-code Ttelmah did give you the answer. Read his post again... |
|
|
|