Simple Serial Communication Between 2 Propeller Chips
timatron
Posts: 16
Holla,
I'm trying to simply have an array of slave chips listen to a master for commands, what i'm having trouble with is with the handshake, ie having the slave wait for the master to say hi. I've been trying to do this with the FullDuplexSerialPlus obj. If anyone has any recommendations, i would love to hear them[noparse]:)[/noparse]
Below is my master chip and slave chip code.
Thanks!
-tim
Master Code
Slave Code
I'm trying to simply have an array of slave chips listen to a master for commands, what i'm having trouble with is with the handshake, ie having the slave wait for the master to say hi. I've been trying to do this with the FullDuplexSerialPlus obj. If anyone has any recommendations, i would love to hear them[noparse]:)[/noparse]
Below is my master chip and slave chip code.
Thanks!
-tim
Master Code
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 rx = 26 tx = 27 OBJ Comp: "FullDuplexSerialPlus" Slave: "FullDuplexSerialPlus" PUB TwoWayCom | value Comp.start(31, 30, 0, 57600) waitcnt(clkfreq*2 + cnt) Comp.tx(16) Comp.Str(String("Comp communication initalized, starting slave chip initalization", 13)) Slave.start(rx, tx, 0, 57600) waitcnt(clkfreq*2 + cnt) Slave.tx(16) repeat value := Slave.getDec Comp.Dec(value) Comp.Str(String(13))
Slave Code
CON rx = 26 tx = 27 _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 OBJ Master: "FullDuplexSerialPlus" PUB TwoWayCom | value Master.start(rx, tx, 0, 57600) waitcnt(clkfreq*2 + cnt) repeat repeat value from 0 to 100 Master.Dec(value) pause(3_000_000) PUB pause(delay) waitcnt(delay + cnt)
Comments
Do remember that FullDuplexSerial is buffered and it may take a while after the last character is put into the buffer before it's actually sent. You really want some kind of acknowledgement to the slave from the master that it received a data item or group of data items from the slave.