chipKIT® Development Platform

Inspired by Arduino™

SPI DSPI Shift Left Shift Right

Created Wed, 09 Mar 2016 17:01:17 +0000 by FredCailloux


FredCailloux

Wed, 09 Mar 2016 17:01:17 +0000

I 'd like to clarify some basic concept regarding MSB LSB and SPI transmission direction. With the SoftSPI object it is possible to choose among MSB first or LSB first for byte transmission direction. Using the DSPI object, only MSB first is allowed, hence, some code implementation is required to reverse the 4 or 5 or 6 bytes needed for transmission. Care must also be taken to make sure data reception is also handled properly. But, nowhere have I been able to clarify what it is about the actual bits transmission direction. Which is a whole different concept in itself. I built a class called SPI7366 to address the LS7366 chip, using DSPI object. It actually work pretty good. I can send any commands to the chip and the chip respond perfectly. While I was studying to comprehend how bits and bytes transfers I was hit with a question. What about bit direction ? When one read the spec sheet on the LS7366 it is clear that the bytes must be transmitted from MSB to LSB. It is also quite clear that each byte transmitted is done with it's own Most Significant Bit first. But what happen when the transmission required is from LSB to MSB, are the Most Significant Bits from each byte are also transmitted first or is the whole transmission direct is reverse altogether as in Least Significant Bit first ?

So the real question: IS Significant Bits transmission direction changes when the Significant Bytes direction is changed ?


majenko

Wed, 09 Mar 2016 17:17:48 +0000

The two concepts are completely separate.

You have bit order and byte order, and the two are separate. It is purely down to the chip manufacturer which combination they use.

Often though only two of the possible 4 combinations are chosen - most significant bit and most significant byte first, or least significant bit and least significant byte first. But that's not always the case. As always: read the datasheet and implement what it tells you.

The reason DSPI doesn't support LSBFIRST is because the PIC32 hardware doesn't support LSB mode. It is quite rare to find anything SPI that uses LSB in any form.