serin/out, pic to pic communications

Status
Not open for further replies.

Jerran

New Member
Im having trouble with a simple project. Im wanting to send data between 2 pics using the serin/serout commands in picbasic pro. Basically Im wanting the transmitting pic to send data out serially when a button is pressed, the reciever will turn on a led(for testing purposes, in application it will store the data sent) while the button is pressed.

Are there any obvious errors Im missing?

Code:
B0 VAR byte
input porta.2
output porta.3
'Transmitter
main:
B0 = 0
button porta.2, 0, 255, 255, B0, 1, transmit
goto main

transmit:
serout porta.3, 4, ["A", 125]
goto main

end

'Receiver
B0 VAR byte
output porta.2
input porta.3
main:
B0 = 0
serin porta.3, 4,["A"], B0
if B0 = 125 then
	high porta.2
else
low porta.2	
endif

goto main
end
 
Well... what errors are you getting?
I would change the INPUT commands, OUTPUT command for:

Code:
B0 VAR byte 

TRISA = %00100  ' makes porta.2 input all others output

'Transmitter 
main: 
B0 = 0 
button porta.2, 0, 255, 255, B0, 1, transmit 
goto main 

transmit: 
serout porta.3, 4, ["A", 125] 
goto main 

end 

'Receiver 
B0 VAR byte 

TRISA = %0100  ' makes porta.3 input all others output

main: 
B0 = 0 
serin porta.3, 4,["A"], B0 
if B0 = 125 then 
   high porta.2 
else 
low porta.2    
endif 

goto main 
end

I would try and see what it is sending by checking the output in a computer. Also make sure that you are connecting the transmiting and receiving pins right. What oscillator are you using, make sure that you define it if it is something else than 4Mhz.

Ivancho
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…