Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CON
- _clkmode = xtal1 + pll16x
- _xinfreq = 5_000_000
- ' Set pins and Baud rate for XBee comms
- XB_Rx = 0 ' XBee DOUT
- XB_Tx = 1 ' XBee DIN
- XB_Baud = 9600
- ' Set pins and baud rate for PC comms
- PC_Rx = 31
- PC_Tx = 30
- PC_Baud = 9600
- Var
- long stack[50] ' stack space for second cog
- OBJ
- PC : "FullDuplexSerial"
- XB : "FullDuplexSerial"
- Pub Start
- PC.start(PC_Rx, PC_Tx, 0, PC_Baud) ' Initialize comms for PC
- XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
- cognew(XB_to_PC,@stack) ' Start cog for XBee--> PC comms
- PC.rxFlush ' Empty buffer for data from PC
- repeat
- XB.tx(PC.rx) ' Accept data from PC and send to XBee
- Pub XB_to_PC
- XB.rxFlush ' Empty buffer for data from XB
- repeat
- PC.tx(XB.rx) ' Accept data from XBee and send to PC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement