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.

SPI communication between TM4C1294NCPDT and TM4C123GH6PM

Other Parts Discussed in Thread: TM4C1294NCPDT, TM4C123GH6PM

I am trying to communicate between  TM4C1294NCPDT and TM4C123GH6PM using SPI but my code is not running
.I connected HW like below

129(MASTER)                123(SLAVE)

PA2(SSI0CLK)  ---->    PA2(SSI0CLK)

PA3(SSI0FSS) ----->  PA2(SSI0FSS)

PA4(SSI0XDAT0)  ----> PA4(SSI0RX)

PA5(SSI0XDAT1)  <---- PA5(SSI0TX)

////////////////////////////////////////////////////////// TM4C1294NCPDT code////////////////////////////////////////////////////////////////////////////////////////////////

main()

{

ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
   
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);//chip select
    
  SSIAdvModeSet(SSI0_BASE,SSI_ADV_MODE_LEGACY);  //FOR SPI MODE
    
    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0XDAT0);//TX
  GPIOPinConfigure(GPIO_PA5_SSI0XDAT1);    //RX
    
    GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);
    GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
    
    SSIConfigSetExpClk(SSI0_BASE, ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER, 10000, 8);

    
    //GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 1);
    SSIEnable(SSI0_BASE);

     //GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
     SSIDataPut(SSI0_BASE,i);    
    while(SSIBusy(SSI0_BASE))
    {
    }

while(1);

}

////////////////////////////////////////////////////////////////////////////////////// TM4C123GH6PM code//////////////////////////////////////////////////////////////////////////////////////////////////////////

main()

{

SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
      
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    SSIAdvModeSet(SSI0_BASE,SSI_ADV_MODE_LEGACY);
    
    GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    GPIOPinConfigure(GPIO_PA4_SSI0RX);
    GPIOPinConfigure(GPIO_PA5_SSI0TX);
    
    GPIOPinTypeSSI(GPIO_PORTA_BASE,GPIO_PIN_4|GPIO_PIN_3|GPIO_PIN_2);
    SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_SLAVE, 10000, 8);
    SSIEnable(SSI0_BASE);

     SSIDataGet(SSI0_BASE,&i);
     UARTprintf("i=%d\n",i);

SSIDataPut(SSI0_BASE,j);


           
while(1);
    
}

Also tell me what is the configuration for changing ssi to spi?

  • Hello Jithin,

    Did you check the SPI Bus and confirm that the data is being sent from the M->S and S->M?

    How do you make sure that both Master and Slave are configured correctly at the time of the data transfer(s)

    And lastly... Are you sure, please refer to the data sheet?

    PA4(SSI0XDAT0) ----> PA4(SSI0RX)

    PA5(SSI0XDAT1) <---- PA5(SSI0TX)

    Regards
    Amit
  • According to data sheet of tm4c1294ncpdt  

    PA4 (SSI0XDAT0) = SSI Module 0 Bi-directional Data Pin 0 (SSI0TX in  Legacy SSI Mode).
    PA5 (SSI0XDAT1 = SSI Module 0 Bi-directional Data Pin 1 (SSI0RX in Legacy SSI Mode).

    So I connecte Tx pin of 129(PA4 ie SSI0XDAT0 ) to Rx pin of 123  PA4(SSI0RX).

    Rx pin of 129(PA5 ie SSI0XDAT1) to Tx pin of 123 (PA5 ie SSI0TX).

    After dumping the code in controllers I connected them like above.According my programme Master will sent 1 byte data to slave.Slave(123) will receive it and sent the reverse of that No back to master. I m using UART to print the data received by the master(reverse of the No).But I'm always getting eighter 0 or 255.According to the peripheral library SSIDataGet() fn will block the programme untill it receive the data.But in my case before turn on the slave(123) UartPrintf() (which is written after SSIDataGet() fn ) is printing the data(0 or 255).I think the communication is not taking place.Please go through the code and help me.

  • Hello Jithin,

    So much for the data sheet. Did you check the scope if the data is coming with the correct voltage and speed as programmed?

    Regards
    Amit
  • Hello Robert,

    This is a fire-n-forget post. Data/Debug being asked for is not being presented at all.

    Regards
    Amit
  • And (beyond) "fire-n-forget" somehow we sense it's "urgent!" (aren't they all?)

    "Thinking" minus (any) effort to confirm/deny is (really) hoping/guessing - (little) thought is in evidence...