28x1 to 08m serial problems

ld-no.77

New Member
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
 

Attachments

westaust55

Moderator
28X1 to 08M interrupt driven serial comms problem

I have not tried to follow through both lots of program but looking at the 08M part:

1. you never assign a value to variable b0 so the lines:
Code:
for b0 = 1 to 255
if b1= 1 then 
  gosub send
endif
never result in a call to the subroutine "send:"


2. in the interrupt routine you re-establish the interrupt and exit without first checking that pin 4 has changed state so could be dropping straight back into the subroutine. A couple of extra lines may help

Code:
interrupt:
serin 4 ,N2400,buffer1,buffer2
if buffer1 = chipid then
let result=buffer2
endif
[COLOR="Red"]DO
LOOP UNTIL pin4 = 1[/COLOR]
setint 0,%00010000
return
Think that some trials in the Programming Editor by you are in order to see if it is working as you wish it to do.
 

ld-no.77

New Member
serial problems

thanks for your help
the FOR B0 should have been let b0 and also B1 should have been result, il also add the loops you brought up and try it again.

thanks again
 
Top