Advertisement
Guest User

Serial Pass Through

a guest
Jun 29th, 2012
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. CON
  2. _clkmode = xtal1 + pll16x
  3. _xinfreq = 5_000_000
  4. ' Set pins and Baud rate for XBee comms
  5. XB_Rx = 0 ' XBee DOUT
  6. XB_Tx = 1 ' XBee DIN
  7. XB_Baud = 9600
  8. ' Set pins and baud rate for PC comms
  9. PC_Rx = 31
  10. PC_Tx = 30
  11. PC_Baud = 9600
  12.  
  13. Var
  14. long stack[50] ' stack space for second cog
  15.  
  16. OBJ
  17. PC : "FullDuplexSerial"
  18. XB : "FullDuplexSerial"
  19. Pub Start
  20. PC.start(PC_Rx, PC_Tx, 0, PC_Baud) ' Initialize comms for PC
  21. XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
  22. cognew(XB_to_PC,@stack) ' Start cog for XBee--> PC comms
  23. PC.rxFlush ' Empty buffer for data from PC
  24. repeat
  25. XB.tx(PC.rx) ' Accept data from PC and send to XBee
  26.  
  27. Pub XB_to_PC
  28. XB.rxFlush ' Empty buffer for data from XB
  29. repeat
  30. PC.tx(XB.rx) ' Accept data from XBee and send to PC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement