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.

TM4C1294NCPDT: SPI bitrate in Motorola Mode

Part Number: TM4C1294NCPDT

Hi,

I have a problem with the SPI speed of my TM4C1294 Launchpad, to which I connected an LCD via SPI.

Effectively I only get an SPI speed of 1.2 MHz, which is too slow for the LCD, which is capable up to 15 MHz SPI speed.

If I specify a higher bitrate in the configuration, no SPI transmission works anymore.

Here is the initialization code:

    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                             SYSCTL_OSC_MAIN |
                                             SYSCTL_USE_PLL |
                                             SYSCTL_CFG_VCO_480), 120000000);


    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOR);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOT);




    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);

    MAP_SSIDisable(SSI0_BASE);  // disables th SSI module as required for init


    // Configure the GPIO Pin Mux for PA2
    // for SSI0CLK
    //
    MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    // Configure the GPIO Pin Mux for PA4
    // for SSI0XDAT0
    //
    MAP_GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
    // Configure the GPIO Pin Mux for PA5
    // for SSI0XDAT1
    //
    MAP_GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);

    //MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);

    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_2);



    /* SOFTWARE CS */

    while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_SSI0)){}

    MAP_SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_SYSTEM); // sets the system clock as the source of clock

    MAP_SSIConfigSetExpClk(SSI0_BASE, MAP_SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1200000, 8);

    MAP_SSIAdvModeSet(SSI0_BASE, SSI_ADV_MODE_READ_WRITE);

    MAP_SSIEnable(SSI0_BASE); // enables SSI


    // LCD_CS
    // Configure the GPIO Pin Mux for PA3
    // for GPIO_PH0
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);
    //MAP_GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    MAP_GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);

    // LCD_DC
    // Configure the GPIO Pin Mux for PD0
    // for GPIO_PL1
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_1);
    //MAP_GPIOPadConfigSet(GPIO_PORTP_BASE, GPIO_PIN_0, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    MAP_GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_1, GPIO_PIN_1);

    // LCD_RST
    // Configure the GPIO Pin Mux for PD1
    // for GPIO_PL0
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_1);
    //MAP_GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_1, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD);
    MAP_GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_1, GPIO_PIN_1);



If I change the initialization code so that I explicitly enter 120 MHz System Clock Speed in MAP_SSIConfigSetExpClk and 30 MHz SPI bitrate, then only 1.2 MHz SPI speed on the LCD gets effective.

MAP_SSIConfigSetExpClk(SSI0_BASE, 120000000, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 30000000, 8);


In addition, the SPI transmission with real 30 MHz on the LCD should not work at all.

Where could a bug be from me or a bug in the driver library or hardware?

  • Hello Ali,

    15 MHz should be no issue for Master mode. How are you observing the SPI outputs? Are you using an oscilloscope? At those speeds, typical logic state analyzers won't sample the SPI lines correctly (even good models like Saleae can max out at 16 MHz which is too slow to sample 15 MHz per Nyquist rules).

    I would recommend setting it for 15 MHz and then getting a capture of the SPI lines with an oscilloscope so we can look at how the data is being output on the lines.

  • Hi,

    ok, I have watched the SPI clock on the osci and it has been accurate just set in the init-code.

    The problem with the low transmission rates results from the effektive bitrate in long transmission up to 3 Mbit at once. Due to the interruptions of the transmission in 8 and 16 bit packages, there is a effective bitrate of 7 to 10 Mbit per second in the scope of a transmission of several Mbits.

    So I want to achieve a continous transmission on the SPI line without a frame of 8 or 16 bits and the resulting interruptions.

    Is there a possibility with the TIVA drivers or a code of a custom SPI routine function.

    Thank you in advance for help...

  • Hello Ali,

    Depending how continuous you need and how long you need it for, it could be a limitation of the TM4C.

    One way to speed up transmission rate would be to manually control the SS line, this would let you not need the SS line to drop and rise with each transmission.

    You can also use Advanced mode to send more bytes continuously with FSS held low, but I am not sure what the limit is on it. Maybe this would be better for you: https://e2e.ti.com/support/microcontrollers/other/f/908/p/663485/2440947#2440947

    If neither of those SPI handling methods work, then it may be a limitation from the device standpoint as I can't think of much else to suggest to optimize the data transfer.