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.

EK-TM4C1294XL: Continues Clock generation in SPI communication.

Part Number: EK-TM4C1294XL

Hi Team,

We are using EK-TM4C1294XL board to send 24 bit data to our Ethernet switch via SPI and we have to read back 32 bit data from the switch.

Queries:

1) After sending 24 bit data via SPI we are not able to read back 32 bit data, instead 24 bit data only coming. 

Our requirement is to send 24 bit data and read back 32 bit data continuously, i.e. we need to generate 56 clock pulse continuously. Is there any way to generate 56 clock continuously.

Please see the image attached below.

the above mentioned image is our requirement. 

We tried to capture the data transmission in oscilloscope but we are receiving 24 clock pulse alone. i.e. we are not getting the clock continuously.

   

2) We have tried to with two EK-TM4C1294XL board for the same purpose. The master Tiva board will send 24 bit data to the slave board and the slave board will send 32 bit data back to the master board

and in master board we will read the 32 bit data and print the data in serial monitor. But we are receiving 24 bit data only.

 3) In SSIConfigSetExpClk() API there are 6 modes of frame format are there. We have tried to use different frame format for sending data via SPI but we are not able to get the desired result.

Can you suggest which frame format will be more suitable for our application.

Thanks and regards,

Abishake Sivasanmugam

  • Hello Abishake,

    Sorry for the delay in getting back to you - I didn't have the tools to test something on my end initially.

    Re-reading your post I think I underestimated some of what you are trying to do here. I have code that sends 24 and 32 bits of data continuously but I haven't tested trying to receive 32 bits before. I will need to dig into this deeper tomorrow.

    To start I'll share the code I did put together but this doesn't cover your full use case. Maybe it shows you something you didn't know and you can investigate more before I get back to this tomorrow.

    #include <stdint.h>
    #include <stdbool.h>
    #include <inc/hw_gpio.h>
    #include <inc/hw_memmap.h>
    #include <inc/hw_types.h>
    #include <inc/hw_gpio.h>
    
    #include <driverlib/gpio.h>
    #include <driverlib/pin_map.h>
    #include <driverlib/ssi.h>
    #include <driverlib/sysctl.h>
    
    int main(void)
    {
        uint32_t ui32SysClock;
    
        //
        // Run from the PLL at 120 MHz.
        // Note: SYSCTL_CFG_VCO_240 is a new setting provided in TivaWare 2.2.x and
        // later to better reflect the actual VCO speed due to SYSCTL#22.
        //
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_240), 120000000);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    
        GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
        GPIOPinConfigure(GPIO_PB5_SSI1CLK);
        GPIOPinConfigure(GPIO_PB4_SSI1FSS);
        GPIOPinTypeSSI(GPIO_PORTE_BASE , GPIO_PIN_4);
        GPIOPinTypeSSI(GPIO_PORTB_BASE , GPIO_PIN_4);
        GPIOPinTypeSSI(GPIO_PORTB_BASE , GPIO_PIN_5);
    
        SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 19200, 8);
    
        SSIAdvFrameHoldEnable(SSI1_BASE);
        SSIAdvModeSet(SSI1_BASE, SSI_ADV_MODE_WRITE);
    
        SSIEnable(SSI1_BASE);
    
        SSIDataPut(SSI1_BASE, 0xFF);
        SSIDataPut(SSI1_BASE, 0xCC);
        SSIDataPut(SSI1_BASE, 0xAA);
        SSIAdvDataPutFrameEnd(SSI1_BASE, 0x55);
    
        while(1);
    }
    

    Best Regards,

    Ralph Jacobi

  • Hello Abishake,

    So I don't easily have a way to test if this works exactly as intended but I believe the way to make this work would be to send your 24 bytes of data and then send four dummy reads of 0x00 to trigger clock cycles before doing the Frame End:

    #include <stdint.h>
    #include <stdbool.h>
    #include <inc/hw_gpio.h>
    #include <inc/hw_memmap.h>
    #include <inc/hw_types.h>
    #include <inc/hw_gpio.h>
    
    #include <driverlib/gpio.h>
    #include <driverlib/pin_map.h>
    #include <driverlib/ssi.h>
    #include <driverlib/sysctl.h>
    
    int main(void)
    {
        uint32_t ui32SysClock;
        uint32_t ui32Buffer[4];
    
        //
        // Run from the PLL at 120 MHz.
        // Note: SYSCTL_CFG_VCO_240 is a new setting provided in TivaWare 2.2.x and
        // later to better reflect the actual VCO speed due to SYSCTL#22.
        //
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                                 SYSCTL_OSC_MAIN |
                                                 SYSCTL_USE_PLL |
                                                 SYSCTL_CFG_VCO_240), 120000000);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    
        GPIOPinConfigure(GPIO_PE4_SSI1XDAT0);
        GPIOPinConfigure(GPIO_PB5_SSI1CLK);
        GPIOPinConfigure(GPIO_PB4_SSI1FSS);
        GPIOPinTypeSSI(GPIO_PORTE_BASE , GPIO_PIN_4);
        GPIOPinTypeSSI(GPIO_PORTB_BASE , GPIO_PIN_4);
        GPIOPinTypeSSI(GPIO_PORTB_BASE , GPIO_PIN_5);
    
        SSIConfigSetExpClk(SSI1_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 19200, 8);
    
        SSIAdvFrameHoldEnable(SSI1_BASE);
        SSIAdvModeSet(SSI1_BASE, SSI_ADV_MODE_WRITE);
    
        SSIEnable(SSI1_BASE);
    
        SSIDataPut(SSI1_BASE, 0xFF);
        SSIDataPut(SSI1_BASE, 0xCC);
        SSIDataPut(SSI1_BASE, 0xAA);
        SSIDataPut(SSI1_BASE, 0x00);
        SSIDataPut(SSI1_BASE, 0x00);
        SSIDataPut(SSI1_BASE, 0x00);
        SSIAdvDataPutFrameEnd(SSI1_BASE, 0x00);
    
        SSIDataGet(SSI1_BASE, &ui32Buffer[0]);
        SSIDataGet(SSI1_BASE, &ui32Buffer[1]);
        SSIDataGet(SSI1_BASE, &ui32Buffer[2]);
        SSIDataGet(SSI1_BASE, &ui32Buffer[3]);
    
        while(1);
    }
    

    This generated enough clock cycles for your use case:

    Let me know if that resolves your issue. 

    Best Regards,

    Ralph Jacobi