Shop OBEX P1 Docs P2 Docs Learn Events
SPI interfacing with BS2...examples please — Parallax Forums

SPI interfacing with BS2...examples please

cwolffcwolff Posts: 24
edited 2004-09-25 20:28 in BASIC Stamp
Any example code of how to interface the BS2 with an SPI device would be appreciated.· Thank you,

Christopher

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-25 05:12
    What device, specifically? If you look at the help file under SHIFTOUT and SHIFTIN you'll find examples that will get you going. Just understand that the BASIC Stamp is the SPI master and can only send (SHIFTOUT) or receive (SHIFTIN) -- not both functions at the same time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • cwolffcwolff Posts: 24
    edited 2004-09-25 05:16
    Jon,

    Thank you for your reply.· I'm trying to interface with a v2xe compass.· I threw together some code but didn't get much output..except "0" tongue.gif

    ' {$STAMP BS2p}
    COMpin········· CON············ 11··············· 'bs input pin
    COMpout········ CON············ 12
    CLK············ CON············ 15··············· 'clock pin
    CS············· CON············ 14··············· 'SS pin
    degree········· VAR············ Word············ 'data coming from compass
    Main:
    LOW CS······································ 'activate the compass
    SHIFTIN COMpin, CLK, MSBFIRST, [noparse][[/noparse]degree]··········· 'shift in the data
    HIGH CS········································· 'deactivate the compass
    DEBUG ? degree
    PAUSE 1000
    GOTO Main:

    Any suggestions, as always, are always appreciated.

    Regards,
    Christopher
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-09-25 16:17
    Take a look at this thread: http://forums.parallax.com/forums/default.aspx?f=5&m=4551

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • cwolffcwolff Posts: 24
    edited 2004-09-25 20:28
    Jon,

    Thanks, i'll move this discussion over there.· Your help is greatly appreciated.
Sign In or Register to comment.