View previous topic :: View next topic |
Author |
Message |
delene
Joined: 13 Oct 2003 Posts: 32
|
1wire RS232 |
Posted: Sun Oct 16, 2011 8:30 am |
|
|
I have two pics that are communicating using 1wire and a 10k resistor.
They do chatter back and forth but my problem is sometimes some of the data being sent is not being received, or if it is its corrupted.
My declaration on the pic not receiving the data is as follows
#use RS232(BAUD = 1200, XMIT=PIN_c2, RCV=PIN_c2, float_high, ERRORS)
Any suggestions as to how I can resolve this?
Many thanks |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Sun Oct 16, 2011 10:28 am |
|
|
CCS has a couple of examples of code in the 'examples' folder and/or the FAQ section of the onscreen manual..maybe that might have some ideas ? |
|
|
Chibouraska
Joined: 11 May 2007 Posts: 57 Location: Montreal,Canada
|
|
Posted: Sun Oct 16, 2011 5:21 pm |
|
|
What value crystal are you using and does the errors occur in sequence or all over the received stream of data? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Sun Oct 16, 2011 5:34 pm |
|
|
hmm..you don't say which PIC and if you're using the internal oscillator,even at 1200 baud, they might be off just enough(one more, one less) to cause miscommunications..... |
|
|
delene
Joined: 13 Oct 2003 Posts: 32
|
|
Posted: Sun Oct 16, 2011 11:38 pm |
|
|
It occours with the pic16f877a and the pic18f452.
Am using a 4 meg crystal
The only idea that I came up with from the examples is to change my pin to be one with an external interrupt. However I am using port b with an LCD display so I don't know if this is going to be possible. Guess I will try it and find out |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Mon Oct 17, 2011 7:07 am |
|
|
Exactly HOW is the data corrupted? Is it bit shifted? that indicates you are not catching the Start bit correctly. Are the bits at the end of the byte bad, but those at the start of the byte are OK? That inicates a baud rate error. Are totally random single bits erroniously 1 or 0? That indicates electrical interference.
Can you put a scope on the serial line and see if there is bus contention (two transmitters fighting and producing midway voltages). _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
|