Wiring two pics together

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Robert
Registered User
Registered User
Posts: 7
Joined: Fri Jul 04, 2008 2:11 pm
Location: France

Wiring two pics together

Post by Robert » Wed Jul 16, 2008 4:30 pm

Good day all,
I am trying to make 2 pic's talk using the usart. I used two easypic board to make the test. The TX and RX line of the first pic are wired to the RX and TX lines of the second by a twisted pair of about 30cm. The first pic talks, the second listen. The problem is that the second listen... nothing :cry: ! If I use the serial communicator to check each pic, there is no problem. The first one send once per second a "Hello word", and if I send an "Hello word" with the serial communicator to the second one, it is received without difficulty. But when connected together, nothing!
So I guess that perhaps wiring two pic is not so simple than crossing their TX-RX pins.

Can somebody point me in the right direction?

By advance thanks,

Robert

Doj
Posts: 362
Joined: Wed Apr 11, 2007 10:18 pm
Location: East Sussex

Post by Doj » Wed Jul 16, 2008 4:44 pm

Serial communications can be tricky to get right, do not make any assumptions that things are correct, it will always find a way to fail!!!

First silly question, do you also have the ground connected?
Obviously there needs to be a return, as you did not mention this I thought I would!

Second post the code, it may be a very simple reason in the code.

I do communicate very often between PICs and PC so its not too hard, it needs to be perfect every time or it will fail.

Timing, timing, timing is the watch word!

Robert
Registered User
Registered User
Posts: 7
Joined: Fri Jul 04, 2008 2:11 pm
Location: France

Post by Robert » Wed Jul 16, 2008 4:59 pm

Hi Doj,
thanks for your answer...
Your question about the ground is not so silly... In fact it was one of the first thing wich came to my mind... but unfortunatly, they are grounded together...

Here is the code for the "listener" :

Code: Select all

#option LCD_DATA = PORTB.0
#option LCD_RS = PORTB.4
#option LCD_EN = PORTB.5

Include "Lcd.bas"
Include "usart.bas"

Dim chaine As String(10)

SetBaudrate(br19200)
Cls
WriteAt(1,1, "Ready")

While 1=1
If USART.DataAvailable Then
    USART.Read(chaine)
   WriteAt(2,1, chaine)
EndIf 
Wend  
and the code of the sender:

Code: Select all


Include "usart.bas"

SetBaudrate(br19200)
While 1 = 1
USART.Write("Hello World")                // string
DelayMS(1000)
Wend
As I said previously, each one works when used with the serial communicator, but no more when wired directly...

Regards,

Robert

PS: Standard Pic's (18F452 - 20Mhz)

Post Reply