hi i am having problems with serial communication between piaxe's. iv worked out how to 08m to talk to each other but iv got stuck getting a 28x1 and 08m to talk to each other. below is the code im using and a simple diagram for a test program which is meant to do this,
the 08m counts to 255 and the 28x1 counts to 10 then asks the 08m what number it has counted too and the 08m sends it to the 28x1 that debugs it to my pc,
08m code
symbol chipid =1
symbol result =b4
symbol buffer1 = b2
symbol buffer2 = b3
pause 50
goto send
setint 0,%00010000
main:
for b0 = 1 to 255
if b1= 1 then
gosub send
endif
pause 50
next b0
goto main
send:
if pin4 = 0 then send
let b1 = 0
setint off
output 4
low 4
pause 10
serout 4,N2400,(0,b0)
high 4
input 4
setint 0,%00010000
goto main
interrupt:
serin 4 ,N2400,buffer1,buffer2
if buffer1 = chipid then
let result=buffer2
endif
setint 0,%00010000
return
28x1 code
symbol chipid =0
symbol buffer1 =b0
symbol buffer2 =b1
symbol result = b2
symbol talk = 4
high talk
symbol listen = pin0
setint 0,%00000001
main:
for b3 = 1 to 10
if b3 = 10 then
gosub send
endif
pause 50
next b3
goto main
send:
if listen = 0 then send
setint off
low talk
pause 10
serout talk,N2400,(1,1)
high talk
setint 0,%00000001
return
interrupt:
serin talk,N2400,buffer1,buffer2
if buffer1 = 0 then
let result = buffer2
endif
setint 0,%000000001
debug result
return
the 08m counts to 255 and the 28x1 counts to 10 then asks the 08m what number it has counted too and the 08m sends it to the 28x1 that debugs it to my pc,
08m code
symbol chipid =1
symbol result =b4
symbol buffer1 = b2
symbol buffer2 = b3
pause 50
goto send
setint 0,%00010000
main:
for b0 = 1 to 255
if b1= 1 then
gosub send
endif
pause 50
next b0
goto main
send:
if pin4 = 0 then send
let b1 = 0
setint off
output 4
low 4
pause 10
serout 4,N2400,(0,b0)
high 4
input 4
setint 0,%00010000
goto main
interrupt:
serin 4 ,N2400,buffer1,buffer2
if buffer1 = chipid then
let result=buffer2
endif
setint 0,%00010000
return
28x1 code
symbol chipid =0
symbol buffer1 =b0
symbol buffer2 =b1
symbol result = b2
symbol talk = 4
high talk
symbol listen = pin0
setint 0,%00000001
main:
for b3 = 1 to 10
if b3 = 10 then
gosub send
endif
pause 50
next b3
goto main
send:
if listen = 0 then send
setint off
low talk
pause 10
serout talk,N2400,(1,1)
high talk
setint 0,%00000001
return
interrupt:
serin talk,N2400,buffer1,buffer2
if buffer1 = 0 then
let result = buffer2
endif
setint 0,%000000001
debug result
return
Attachments
-
33.2 KB Views: 29