chipKIT® Development Platform

Inspired by Arduino™

DSPI Mode Description

Created Sun, 07 Feb 2016 17:36:59 +0000 by FredCailloux


FredCailloux

Sun, 07 Feb 2016 17:36:59 +0000

I am presently studying the DSPI library and while reading the description I find that the function setMode() uses 4 possible parameters. DSPI_MODE0 DSPI_MODE1 DSPI_MODE2 DSPI_MODE3 - According to library description they set the clock edge effect and the idle_low or idle_high states. But nowhere can I find which mode is which parameters. Can anyone point me to an information source describing what the 4 modes relates to ? I am trying to build a driver for the LS7366 chip from LSI but even in their chip description there is no reference to this Mode parameter. I search the web and the forums with no success...

Thanks


FredCailloux

Sun, 07 Feb 2016 18:31:34 +0000

Now I am even more puzzled with this DSPI_MODE thing. According to the LS7366 Datasheet (which for some puzzling unknown reasons, I could not attach here the PDF file? ) the LS7366 chip would use (page 1) the clock Leading edge to Receive Data and use the clock Trailing edge to transmit data. Would that mean that one must terminate the DSPI object and recreate another DSPI object with a different mode in order to switch from Transmitting parameters to the chip and Receiving data from the chip ? Wow! If that is the case I think I will abandon trying to implement the DSPI and switch back to the proposed archaic SPI driver on the wiki page. http://hades.mech.northwestern.edu/index.php/Using_the_LS7366R_SPI_Quadrature_Counter Can someone bring clarification on this ?


FredCailloux

Sun, 07 Feb 2016 18:36:58 +0000

Excerpt from the LS7366 Datasheet, page 1:

A transmission cycle is initiated by a high to low transition of the SS/ input. The first byte received in a transmission cycle is always an instruction byte, whereas the second through the fifth bytes are always interpreted as data bytes. A transmission cycle is terminated with the low to high transition of the SS/ input. :o Received bytes are shifted in at the MOSI input, MSB first, with the leading edges (high transition) of the SCK clocks. Output data are shifted out on the MISO output, MSB first, with the trailing edges (low transition) of the SCK clocks. :o


majenko

Sun, 07 Feb 2016 20:40:51 +0000

The modes are standard terminology for SPI and are detailed in the wikipedia page for SPI.

Sent from my SM-T555 using Tapatalk


GrahamM242

Mon, 08 Feb 2016 09:52:47 +0000

the LS7366 chip would use (page 1) the clock Leading edge to Receive Data and use the clock Trailing edge to transmit data. Would that mean that one must terminate the DSPI object and recreate another DSPI object with a different mode in order to switch from Transmitting parameters to the chip and Receiving data from the chip

The SPI description you've highlighted is pretty normal. You don't need to change the DSPI object, although you might want to read a bit more about how SPI operates. It might help to remember that SPI is synchronous (IE, you always TX and RX at the same time) and the SPI master always generates the clock signal. Having the slave transmit its data 180 degrees behind is typical operation.

As Majenko says, the Wiki article has useful information, especially the section on Clock polarity and phase including the SPI timing diagram. There's two settings for clock polarity and two settings for which edge to clock data out on. If you configure these from the point of view of the master you should be fine. If you look at the timing diagrams on page 7 of the datasheet, you can see the clock idles low. Based on that, you should be able to see that your choices have been narrowed to mode 0 or 1. Hopefully you can figure out when you need to transmit the data and thus choose the appropriate mode from there. If you are still finding it difficult, then a quick seach for "LS7366 SPI mode" should help.

The archaic SPI driver has the same requirements to know what the SPI mode is, as this is fundamental to how SPI operates - if it is not set correctly, you will not be able to transfer data.


FredCailloux

Mon, 08 Feb 2016 15:34:37 +0000

Thank you both very much for these valuable inputs. I finally figured out that I need DSPI_MODE0. I still cant figure out this sentence from the LS7366 datasheet that goes like this: > Read and write commands cannot be combined. For example, when the device is shifting out read data on MISO output, it ignores the MOSI input, even though the SS/ input is active. SS/ must be terminated and reasserted before the device will accept a new command.

So, If I understand correctly, Reading and Writing to the LS7366 will necessitate two calls? And, During those calls I will have to assume that either the uController Output will send command data while receiving useless data from LS7366 or none at all during a Write, and during a Read I will have to send useless data to the LS7366 while LS7366 is transmitting it's answer ? I am instinctively certain that this is not what's taking place. If I send a request for reading the counter, according to procedure I must send an 8bits chunk to command the chip, then what do I do ? transmit another 4x8bits to make room for 32bit counter value (I assume) ? In that 32bits transmission I have no idea what to transmit, probably some zeros. Then, I must transmit what ? Another request ? The datasheet clearly specify that the LS7366 cannot do a Read and a Write combined. Does this mean that LS7366 is an exception to the SPI standard ? Thanks for your help


FredCailloux

Mon, 08 Feb 2016 16:17:08 +0000

Ureka :!: I just found the answer to my own question. LS7366 can actually accept a command via a transmission from the uController and following this 8bits command will start transmitting the requested data, during one single SS low period of 5 bytes. The mention that LS7366 cannot Read and Write combines is pertaining to the first 8bits command chunk. Thanks to LSI engineer... So, thank you all for your help.