Shop OBEX P1 Docs P2 Docs Learn Events
Sending data MDB or LSB first order. Why? — Parallax Forums

Sending data MDB or LSB first order. Why?

What is the reason in for choosing to send data with MSB or LSB first order?

I'm assuming there is a reason I have a choice in doing this . I just don't see any difference.

Some of my chips let me choose this as an option in sending data using SPI.

Thanks


Comments

  • jmgjmg Posts: 15,173
    jdolecki wrote: »
    I just don't see any difference.

    To the programmer, this does not matter, but to the connected device it matters a lot :)
    The designer of that chip has to choose some MSB/LSB order, and, of course, they do not all choose the same - so having the option in the host avoids needing a SWAP function.


  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-08-07 15:17
    The way the bits are shifted out can make small speed differences in the low level PASM driver. I think I'd give MSB the advantage if you're using any random I/O pin but if you can use I/O pin #0 then LSB has a slight advantage.

    If you're shifting multiple bits at once on a parallel bus, the LSB on the lowest I/O pins can end up saving a full hub cycle. At least this is what I remember from my attempt to use eight SRAM chips in parallel.

    When writing a bit banging driver in Spin, I think LSB first seems most natural to shift data out and MSB first is easiest when shifting data in.
  • kwinnkwinn Posts: 8,697
    I didn't find it made any difference whether the data was shifted out msb or lsb first when doing a project that had 7 TPICs for outputs and 10 '597's for inputs. Having the input and output connections in sequence made the wiring simpler, and matching the input/output number to the bit position in the longs made writing the program easier.
Sign In or Register to comment.