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: TIVA C Series TM4C123G Launchpad SSI Questions about General Operation and Programming

Part Number: TM4C123GH6PM

Tool/software: Code Composer Studio

Hello, 

Let me start off by saying I am a complete newbie with the TM4C123G Launchpad and still a beginner with C coding. I am a college student and just finished a course using PIC micro controllers. I am using the TM4C123G (programming in CCS) for my senior project which feels like an enormous leap from using MPLAB and the PICs. I have read everything on SSI in the datasheet and deciphered what I could from the SSI.C functions from the TIVA C Library, but I do have some questions that I couldn't find the answers to:

1. Is the Freescale SPI Format (clock, SSInFss, Rx, Tx) automatically performed by the SSI module when I write/read data to/from the SSI data register? For PIC, I had to manually set chip select and transmit a dummy byte to keep the clock going when reading data. From what I have read in the TIVA datasheet, it seems like the TM4C123G does all of that for me.

2. For my project, I need to receive a lot of bytes of continuous data. probably up to 64 bytes, which is a lot for me since the most I have transmitted/read continuously in my PIC course is roughly 2-3 bytes. My understanding of SSI is that I just need to send data which includes the address, R/W, and command to read from a slave device, then read the received data from the data register. Assuming that is correct, if I need to receive continuous data, do I just keep reading from data register back to back?

For example, in my project I need to talk with a USB host controller (VDIP1) using SPI. I have to send 3 separate transmissions to tell it to send back information like its firmware version. Then it sends me a big stream of data. (I consider one sentence of data a lot at my current skill level). How do I read continuously? Can I just use the SSIDataGet function on loop or back to back until the VDIP1 is done sending? for example, could the following code work? (Assume SSI module is configured correctly and enabled. Ignore syntax issues as this is just a hypothetical section of code) I just want to know if I am on the right track.

 //these are just arbitrary values. Pretend these are the three values I need to send to the host controller to read data.

SSIDataPut(SSI0_BASE, 0x9F);   

SSIDataPut(SSI0_BASE, 0x9F);

SSIDataPut(SSI0_BASE, 0x9F);

//I'll figure out the while loop later. I haven't thought about how I would check to see if I'm done receiving data yet.

while(a<b)

{

SSIDataGet(SSI0_BASE, *pui32Data);

*pui32Data ++;

a++;

}

3. If I did something like the above, would I be able to read a continuous stream of data? Does the SSI module automatically pulse the SSInFss. Will the clock just keep going if I do this?

I appreciate any responses that I get. However, I do ask that you dumb it down as much as possible for me. Still learning a lot of the technical language surrounding micro controllers and C code.

  • Bryan Holland said:
    1. Is the Freescale SPI Format (clock, SSInFss, Rx, Tx) automatically performed by the SSI module when I write/read data to/from the SSI data register? For PIC, I had to manually set chip select and transmit a dummy byte to keep the clock going when reading data. From what I have read in the TIVA datasheet, it seems like the TM4C123G does all of that for me.

    Yes, your understanding is correct. I will suggest you start with the TivaWare SSI examples. You can find examples in <TivaWare_Installation>/examples/peripherals/ssi. Please also go through the TivaWare driverlib user's guide instead of going through the ssi.c to find the usage of all the APIs. Here is the user's guide incase you have not found it. 

     On your second question, you are on the right track. You will poll the SSIRIS register using the SSIIntStatus() API to find out if there is still data in the received FIFO. If yes, you will keep reading. You can consider using the interrupt mode. For simplicity you can start with polling mode first. Also note that the second argument to pass to the SSIDATAget is a pointer. If your pui32Data is already a pointer then you don't need to dereference it. 

    Bryan Holland said:
    Does the SSI module automatically pulse the SSInFss. Will the clock just keep going if I do this?

    Yes, the SSI module will automatically de-assert between frames. You may see a slight de-assertion on the SSInFss between frames if you keep on reading. The best is for you to use a scope to observe what is going on. 

  • Let me revise my answers a bit. Since you are the master, you will be generating the SPICLK to your external slave. You should know how many data you are expecting to read from the slave.
  • Charles,

    Thank you for the response. I do have some follow-up questions.

    Are saying for the second argument in SSIDataGet to just enter the name of a pointer instead literally using "*pui32Data"?

    As far as being master, when you say I will be generating the SPICLK, doesn't the SSI module still generate a clock automatically after I read/write to the Data Register?

    Also, something I discovered last night. The slave device I am communicating with expects CS to be held high. In all modes of SSI on the Master, SSInFss idles high and is held low for transmission. Is there a way to manually control SSInFss or another Chip Select option in the TM4C123G . Currently my plan of attack is to just use an inverter on the CS pin.

    Regards,

    Bryan
  • Bryan Holland said:
    Are saying for the second argument in SSIDataGet to just enter the name of a pointer instead literally using "*pui32Data"?

    Correct.

    Bryan Holland said:
    As far as being master, when you say I will be generating the SPICLK, doesn't the SSI module still generate a clock automatically after I read/write to the Data Register?

    When you write to the Data register it will initiate the SSI transmission which will generate the SPICLK provided that you are the master. Reading from the data register merely reads data RXFIFO. It will not generate SPICLK. You will need to create some dummy write on the TX so the SPICLK is generated to your slave. The communication is full-duplex. Your slave should know that it can ignore these dummy bytes from the master while it is returning the data to the master. 

    Bryan Holland said:
    The slave device I am communicating with expects CS to be held high.

    You can add an inverter on your board or you can use GPIO as the CS for your slave.