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/TM4C1294KCPDT: How to use SSI as SPI having muxed CS line instead of direct GPIO pin?

Part Number: TM4C1294KCPDT

Tool/software: Code Composer Studio

Hi,

i need some help with respect sample code provided in TI package for tm4c:

"TivaWare_C_Series-2.1.4.178\examples\peripherals\ssi"

How can I use the sample code for any other SPI support chip say for eg: LTC1863 with muxed CS line instead of direct GPIO pin for CS ?

any kind of guidance and suggestions will be appreciated.

Thanks & regards

Anan

  • scenario briefing:

    I have used pinmux tool to configure pins for SSI1 port. only using the configurations for SSI1XDAT0, SSI1XDat1 and SSI1CLK and for Chip select
    i aim external handling of muxed CS line, selecting the chip while writing() the again disabling it after performing operation similar for reading(). but unable to read the ADC LTC1863 values.

    please correct me where ever required. and guide me for correct approach.

    Thanks
  • Anan,

    Using a GPIO for CSB is actually much more recommended than letting the standard hardware take care of it (because it will likely control it in a non-compatible timing, for SPI is "too flexible"...)

    This is a piece of code that is proven to work for one particular type of sensor. Maybe it will help you . It does use a GPIO for CSB, and reads a small sequence of bytes. I'm not including the configuration part, as you seem to be on the way there.

        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0);       // Lower CSB
        SSIDataPut(gyroHW->SSIBase, frameHigh);                       // Sends only the upper 16 bits
        while(SSIBusy(gyroHW->SSIBase));
        SSIDataGet(gyroHW->SSIBase, &readCrap);                       // Read useless data
        SSIDataPut(gyroHW->SSIBase, (frameLow));                      // This sends the other 16 bits
        while(SSIBusy(gyroHW->SSIBase));
        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin);     // Raise CSB
        SSIDataGet(gyroHW->SSIBase, &readCrap);                       // Read useless data
        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,0);       // Lower CSB
        SSIDataPut(gyroHW->SSIBase, frameHigh);                       // Flush 16 more bits
        while(SSIBusy(gyroHW->SSIBase));                              // Wait for bits to be flushed out
        SSIDataGet(gyroHW->SSIBase, &read16High);                     // Read 16 bits
        SSIDataPut(gyroHW->SSIBase, frameLow);                        // Flush 16 more bits
        while(SSIBusy(gyroHW->SSIBase));                              // Wait for bits to be flushed out
        SSIDataGet(gyroHW->SSIBase, &read16Low);                      // Read more data
        GPIOPinWrite(gyroHW->GPIOFSSPort,gyroHW->GPIOFSSPin,gyroHW->GPIOFSSPin);     // Raise CSB

    Regards

    Bruno

  • Hi Bruno,

    Thanks a lot for your reply. But I have figured out the issue in my case. It was in SSIConfigSetExpClk() configuration. I could have checked it before. so, yeah its my bad... :P 

    But anyways, Now i can work with Multiplexed Chip select line and can save other GPIOS for other purpose. 

    problem was here:

    SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_MODE_MASTER,SSI_MODE_MASTER, 1000000, 8);

    And the corrected configuration:

    SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER, 1000000, 8);

     

    I can read ADC ltc1863 data, and yes this is still under test so cant say much abut its behaviour, But over all project is is stable till now.

    Thanks once again Bruno.

    Regards

    Anan