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.

RTOS/TM4C1294NCPDT: sample code for SPI Slave write to SPI Master in Tiva C series connect launchpad

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: EK-TM4C1294XL

Tool/software: TI-RTOS

Hi i was tryin to configure hte SSI interface SSI0 as master and SSI2 as slave on the same controller and wrote a common firmware tot est the SPI by connecting the SSI pins to the respective complement pins of SSI2.I was able to read data wrote from master(SSI0) in the slave(SSI2) and tried to write the same data back to the master(SSI0) from salve(SSI2) .But this time when tried to read the data back the debugger stuck at the checking line for SSI busy. PLease help tpo sort out the issue. .

/*SSI init function*?

void ssi_init(void)
{

    ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);
    GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);
    GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);

    SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 10000, 16);
    SSIEnable(SSI0_BASE);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);  //Enable ssi2
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); //Enable PORT B GPIO to be used with ssi2 data and frame signals

    GPIOPinConfigure(GPIO_PD3_SSI2CLK);
    GPIOPinConfigure(GPIO_PD2_SSI2FSS);
    GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);
    GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);
    GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

    SSIConfigSetExpClk(SSI2_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0, SSI_MODE_SLAVE, 10000, 16);
    SSIEnable(SSI2_BASE);
}


/*function to read the data from ssi0 in ssi2 and write it back to ssi0 and compare both*/
void test_spi(void)
{
    uint32_t ui32Index;
    uint32_t ui32Data;
    spi_data_index=0;
    memset(spi_data_recived_back, '\0', 15);
    for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
    {
       ui32Data = spi_test_command[ui32Index];
       SSIDataPut(SSI0_BASE, ui32Data);
       while(SSIBusy(SSI0_BASE))
       {
       }
       SSIDataGet(SSI2_BASE, &spi_recived_char);
       SSIDataPut(SSI2_BASE, spi_recived_char);

while(SSIBusy(SSI2_BASE)) /* DEBUGEGER GET STUCK HERE*/ { }
SSIDataGet(SSI0_BASE, spi_recived_char);//&spi_data_recived_back[spi_data_index++]
} if(strcmp(spi_test_command, spi_data_recived_back) == 0) { pass_or_fail = 1; UARTprintf("\n\rPASSED\n\r"); } else { pass_or_fail = 0; UARTprintf("\n\rFAILED\n\r"); } return; }

  • Each transfer on the SSI is both a transmit and receive for both the master and the slave. To make this work, first do a SSIDataPut() to the slave with some dummy data. Then when you do the SSIDataPut() to the master, the slave will respond because it is ready for the transfer. The transfers always start with the SSIDataPut() to the master. I will put together a sample routine based on your code in a little while.
  • I have attached an example project in a .zip file. Import this project into your code composer workspace by selecting "File" "Import" "Code Composer Studio -> CCS Projects",  "Select archive file". Since I am transferring an ASCII string, I used 8 bit instead of 16 bit transfers.

    /cfs-file/__key/communityserver-discussions-components-files/908/SSI0toSSI2.zip

    On an EK-TM4C1294XL evaluation kit, add jumper wires to connect:

    SSIxCLK PA2 to PD3
    SSIxFSS PA3 to PD2
    SSI0DAT0 PA4 to SSI2DAT1 PD0
    SSI0DAT1 PA5 to SSI2DAT0 PD1

    Here is what it looks like on a logic analyzer. RX is slave receive and master transmit. TX is slave transmit and master receive.