This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TM4C123GH6PM: Not able to communicate more than 16 bits through SPI

Part Number: TM4C123GH6PM

Tool/software: Code Composer Studio

Hi,

I am using TM4C123GH6PM MCU and need to communicate through SPI. But the data size of  SPI is maximum 16 bits. So maximum 16 bits only can transmit at a time. In my case i have to transmit  20 bit data through SPI and not finding anyway to do that.

According to MCU datasheet, For continuous back-to-back transfers, the SSInFss pin is held Low between successive data words and termination is the same as that of the single word transfer. But not clear that how to do this .

So please help me to find a way to keep SSInFss low for sending complete 20 bit data and please explain how to transmit 20 bits data through SPI (as the data size can be maximum 16)

  • " i have to transmit 20 bit data through SPI "

    break it down to multiple 16-bit transmissions.
  • Hello Dipin,

    For transferring 20 bits, it would depend a bit on the behavior of your slave. Do you need to send all 20 bits without having any gaps between 4 bit or 8 bit data packets or can there be slight pauses between data nibbles/bytes so long as Slave Select is held low? And if there can't be gaps between the nibbles, would the slave device be able to ignore additional clocks if transferring 24 bits of data with only 20 bits being valid. That will be determine whether or not it is possible.

    If you can get away with small gaps between the data, then the easiest method would be as follows. First, you can manually hold SS low by controlling the pin as a GPIO and not an SSI pin. That is a fool proof means to force SS low throughout the transfer.

    Then what you would need to do is set the SSI to be 4 bit wide transfers and then send 5 packets out which will total up to be 20 bits. This method will result in small gaps between each 4 bit nibble of data though as the SSI peripheral on the TM4C123G pauses the clock briefly between loading each byte.

    Unfortunately because there would be small gaps between each nibble, that also means that if you can't get away with having those small gaps between the data nibbles, then the TM4C123G device may not be capable of what you are seeking. However devices from our TM4C129x family may be able to solve the issue as they have an Advanced SSI Mode which might be able to be used to facilitate what you need.

    A very similar issue came up not long ago with a user trying to do a 24 bit transfer and had an issue where he couldn't have any gap between the bytes being sent out. One of our community members solved the issue and described the solution plus provided source code here: e2e.ti.com/.../2440947

    However, there is still a 'gotcha' with the TM4C129x Advanced SSI mode, which is that it can only transfer data at an 8 bit length, so you would have to expose the Slave device to 4 dummy clocks which may or may not be accepted by the slave device.