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/TM4C1290NCZAD: SPI's chip select after each byte

Part Number: TM4C1290NCZAD

Tool/software: Code Composer Studio

Hello,

I'm using the following code to send an SPI message:


char Msg[5]={1,2,3,4,5};
char *p = Msg;
// // Configure the SSI. // ROM_SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8); // // Enable the SSI module. // SSIEnable(SSI2_BASE); for (i=0;i<Size;i++) { SSIDataPut(SSI2_BASE, *p); while(SSIBusy(SSI2_BASE)){}; p++; }

I'm trying to send 5 bytes. 

But according to a scope connected to the chip select(CS) line, the CS is going to '0' after each byte.

It should go down before the first byte and after last byte.

Can you please help ?

Thank you,

Zvika  

  • Hi Zvika,

     First of all, you cannot use SysCtlClockGet() to pass the system clock frequency as in your statement ROM_SSIConfigSetExpClk(SSI2_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 8); The SysCtlClockGet() API is for TM4C123 devices, not for TM4C129 devices. Please refer to the TivaWare examples. Hopefully this is the issue. 

     You should do something like below.

       ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |

                                          SYSCTL_OSC_MAIN |

                                          SYSCTL_USE_OSC), 25000000);

       SSIConfigSetExpClk(SSI0_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,

                          SSI_MODE_MASTER, 1000000, 8);

  • Hi Charles,

    I tried your solution.  Problem was not solved. 

    In order to solve it I configured the CS pin of  SSI2 to a simple output GPIO.

    Before sending the first byte I set this GPIO pin to '0'. 

    After sending the last byte I set this pin to '1'.

    Not sure this is an elegant solution.

    Thank you,

    Zvika 

  • Hi Zvika,

    Zvi Vered said:
    the CS is going to '0' after each byte

     What do you mean the CS is going to '0' after each byte. I can agree that the CS going high after each byte. During each byte transmission, the CS should be low. Or you are looking for the CS to remain low from the first byte to the N bytes and upon finishing the last byte to assert the CS high. Can you show your scope capture?

  • Hi Charles,

    I'm looking for the CS to remain low before sending the first byte to the N bytes and upon finishing the last byte to assert the CS high.
    This is required by the SPI slave device.

    Thank you,
    Zvika
  • Hi Zvi,
    I think you need to use the SSIAdvModeSet() to put the QSSI module in the Advanced mode and then use the SSIAdvFrameHoldEnable() API to hold the CS during transfers. Please refer to the datasheet for QSSI advanced mode. Note in advance mode you can only do 8-bit transfers. Please give it a try and see if it makes a difference.