SPI Data Frames

SPI bus allows continuous data transmission. When you pass a buffer (array of words) to one of the SPI Master Transmission Functions, the DLN adapter transmits the data bit after bit as in the following figure.

SPI Data Transmission

Logically, your application and an SPI slave device treat this data as an array of 8-bit or 16-bit words. Some SPI slave devices (for example, digital-to-analog or analog-to-digital converters) operate with 12-bit words.

DLN adapters allow you to support a wide range of SPI slave devices. You can configure the frame size (number of bits in the word) by using the DlnSpiMasterSetFrameSize() function. DLN adapters support 8 to 16 bits per frame.

SPI 8 bits per frame

SPI 16 bits per frame

In DLN adapters, the frame data is transmitted in a Little Endian format (starting from the most-significant bit and up to the least-significant bit). If the frame size is not a multiple of 8, the unused (most-significant) bits are discarded, regardless of their content.

You want to transmit an array with the following data: ABCDEF01

If the frame size is 8 bits, the transmission proceeds as four 8-bit words: AB CD EF 01

SPI 8-bit transmission

If the frame size is 16 bits, the transmission proceeds as two 16-bit words. Each word is stored in the array in little endian format: CDAB 01EF

SPI 16-bit transmission

If the frame size is 12 bits, the transmission proceeds as two 12-bit words. This frame is not a multiple of 8, so the unused (most-significant) bits of the second byte in each word are discarded: ABC EF0.

Each word is stored in the array in little endian format: CAB 0EF

SPI 12-bit transmission

To transmit data as arrays of more than 8 bits, you can use the DlnSpiMasterReadWrite16() function. It transmits data in little endian format that is very useful because most microcontrollers store data in this format.

For information about all functions that you can use to transmit data, read the SPI Master Transmission Functions section.

Average: 3 (4 votes)

SS Line Release Between Frames

By default, if an array of several frames is transmitted between the master and the same slave, the SS line stays enabled until data transmission completes.

SPI transmission

However, some SPI slave devices require the SS line to be deasserted between frames.

SPI released SS line

To release the SS line, use the DlnSpiMasterReleaseSS(). Use the DlnSpiMasterSSEnable() function to enable the SS line.

DLN-1 and DLN-2 adapters do not support the SS line release between frames.

If an SPI slave device is not fast enough to process continuously incoming data, you can configure your DLN adapter to introduce a specified delay between frames. For more information about this and other delays, read SPI Delays.

Average: 1 (1 vote)