Shop OBEX P1 Docs P2 Docs Learn Events
Code help needed please — Parallax Forums

Code help needed please

Don MDon M Posts: 1,653
edited 2011-02-11 20:01 in Propeller 1
This project involves a Master / Slave type arraignment utilizing 9 bit serial data. The 9th bit is used as a mode flag to specify if the information transmitted is a command (9th bit set) or just data (9th bit cleared).

It goes through an initial handshake whereby the Master sends out a 10 10 Hex. The first 10 is the Command and the second 10 is the checksum.

The Slave is to then respond within 5 mSec with an ACK which is 00 Hex.

The Master then sends out a POLL command which is 12 12 (12 command and 12 checksum)

The Slave is to then respond with 00 00 Hex to indicate that the Slave is Just Reset. The Master then sends an ACK (00) to acknowledge.

What I am getting is an additional 00 sent from the Slave. The only time that the Slave is to respond with 00 00 is after the Master has requested it to be reset otherwise it is correct for the Slave to respond to the Master Poll (12 12) with just a single ACK (00).

I have attached 2 photos from the logic analyzer showing this.

Please excuse the messy code. Anyone have any ideas?

Thanks.
Don



1010 OK.png
1212 NOT OK.png

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-02-11 18:26
    Don M wrote: »
    What I am getting is an additional 00 sent from the Slave. The only time that the Slave is to respond with 00 00 is after the Master has requested it to be reset otherwise it is correct for the Slave to respond to the Master Poll (12 12) with just a single ACK (00).
    Self-inflicted damage I'm afraid.
    $12:                                        ' look for master command 12 which is poll
          [COLOR="blue"]if (state == 0)[/COLOR]
            d := mdbrx.rxtime(2)                 
            txmdb(MDB_ACK,MDB_SLAV)                 ' send "just reset"= 00 00  reply to master
            txmdb(($1_00) | MDB_ACK,MDB_SLAV)       ' have to set the mode 1 somehow??? = last byte
            [COLOR="red"]state := 1[/COLOR]                                           
    
          [COLOR="blue"]if (state > 0)[/COLOR]
            pollack
    
    Both if-statements are evaluated in order. The first one - if true - will open the path for the second so you'll get the 00 00 response and another pollack because now (state > 0) is true. Maybe you meant to use if/elseif?
    $12:                                        ' look for master command 12 which is poll
          [COLOR="red"]if (state == 0)[/COLOR]
            d := mdbrx.rxtime(2)                 
            txmdb(MDB_ACK,MDB_SLAV)                 ' send "just reset"= 00 00  reply to master
            txmdb(($1_00) | MDB_ACK,MDB_SLAV)       ' have to set the mode 1 somehow??? = last byte
            state := 1
    
          [COLOR="red"]elseif (state > 0)[/COLOR]
            pollack
    
  • Don MDon M Posts: 1,653
    edited 2011-02-11 20:01
    kuroneko- Thanks a million! That solved the problem. Now on to the next problem.... :)
Sign In or Register to comment.