I have now struggled to get the following to work, but the damn things won't do as I suppose they should.
Having a 18M2 to work as a Master and some 08M to work as Slaves. This should be very simple as I only tries to send a character from the Master to the Slave. Afterwards the Slave should return the same character to the Master.
I can send and receive both ways without problem, but when I insert interrupt routines in the slaves, I got wrong charecters. The characters are wrong allready when received by the Slave. Only occasionally the right character shows up.
The diagram here
Master program here
Slave program here
Notice that I until now I only has worked with one slave.
Any help is appreciated.
Having a 18M2 to work as a Master and some 08M to work as Slaves. This should be very simple as I only tries to send a character from the Master to the Slave. Afterwards the Slave should return the same character to the Master.
I can send and receive both ways without problem, but when I insert interrupt routines in the slaves, I got wrong charecters. The characters are wrong allready when received by the Slave. Only occasionally the right character shows up.
The diagram here
Master program here
Code:
#PICAXE 18M2
#No_Data
#Terminal 4800
symbol baud = N2400
symbol outpin = B.4
symbol inpin = B.1
low outpin
b1 = 170
main:
sertxd ("Master Mainloop",cr,lf)
gosub sendit
gosub receiveit
pause 1000
goto main
sendit:
pulsout outpin, 1
pause 5
serout outpin,baud,(b1)
low outpin
return
receiveit:
serin [1000,NoData],inpin,baud, b2
sertxd (#b2," received",cr,lf)
return
NoData:
sertxd (" No data received",cr,lf)
return
Code:
#PICAXE 08M
#Terminal 4800
symbol baud = N2400
symbol outpin = C.2
symbol inpin = C.4
setint %00010000,%00010000
MainLoop:
high C.0
pause 500
low C.0
pause 500
sertxd ("Mainloop/Slave",cr,lf)
gosub Interrupt
goto MainLoop
Interrupt:
serin inpin,baud,b0
sertxd (#b0," ")
serout outpin,baud, (b0)
b0 = 0
setint %00010000,%00010000
return
Any help is appreciated.