Shop OBEX P1 Docs P2 Docs Learn Events
16 bit SPI device with an 8 bit microcontroller... — Parallax Forums

16 bit SPI device with an 8 bit microcontroller...

well wisherwell wisher Posts: 4
edited 2013-02-01 02:52 in General Discussion
Hi all,
Is it possible to interface a 16 bit SPI device with an 8 bit microcontroller..?(16 bit SPI device in the sense it's registers are of 16 bit.)

Comments

  • jmgjmg Posts: 15,173
    edited 2013-02-01 01:54
    Hi all,
    Is it possible to interface a 16 bit SPI device with an 8 bit microcontroller..?(16 bit SPI device in the sense it's registers are of 16 bit.)

    Unless your 8 bit micro is very unusual, yes, this is just a matter of sending two bytes, and after Byte1 is send, you save the SPI reply, before sending Byte2, and now you merge the two replies.
  • well wisherwell wisher Posts: 4
    edited 2013-02-01 02:04
    Thankyou 4 your reply.

    That means 16 bit data can be send as two 8 bit data.Am I correct?If yes,then which one to be send first MSB or LSB? (I am using a PIC16f873 controller.)
  • jmgjmg Posts: 15,173
    edited 2013-02-01 02:13
    That means 16 bit data can be send as two 8 bit data.Am I correct?If yes,then which one to be send first MSB or LSB? (I am using a PIC16f873 controller.)

    Yes, you send as 2 x 8 bit bytes.
    Which one is MSB, depends on the SPI slave, as usually you have more choices in the uC registers, so the slave sets the 'convention'.

    Check the slave info, to see what order it wants the bits fed, and then setup the uC registers to do that.
    In extreme cases if the bit order cannot be chosen in a register, you sometimes have to add software for byte-reversal (swaps the order of the bits )
  • well wisherwell wisher Posts: 4
    edited 2013-02-01 02:52
    Thank you jmg.


    I will try.
Sign In or Register to comment.