Shop OBEX P1 Docs P2 Docs Learn Events
Simple Serial Communication Between 2 Propeller Chips — Parallax Forums

Simple Serial Communication Between 2 Propeller Chips

timatrontimatron Posts: 16
edited 2008-09-16 20:04 in Propeller 1
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
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

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-16 19:03
    Where does the slave read the character from the master? I see a 2 second pause, but, if the master is slow getting started, the slave will just start sending.

    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.
  • timatrontimatron Posts: 16
    edited 2008-09-16 20:04
    Sorry on this example, i was having the master and the slave are reversed, where the slave keeps on sending to the master and the master prints to the computer. Same concept, just reverse the names of the master and slave.
Sign In or Register to comment.