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.

TM4C123GH6PM: SSI Master Slave connection.

Part Number: TM4C123GH6PM

I am trying to configure SS0 in master mode and SS3 in slave mode.

then the SSI3 module receives data, if data matches with what is sent then a green led gets turned ON.

I ran the code in debug mode, i found by inspection that my code gets stuck in a loop where it waits for the data to be received by SSI3 slave module.

It does run sometimes but the text "Hey" is not received, I am receiving junk values.

Hardware Connection:

SSI0 Clk connected to SSI3 clk

SSI0Fss connected to SSI3Fss

SSI0Tx connected to SSI3Rx

SSI0Rx connected to SSI3Tx

below is the code for your reference.

#include<stdint.h>
#include<string.h>
#include<stdbool.h>
#include<hw_types.h>
#include<hw_memmap.h>
#include<hw_ints.h>
#include<pin_map.h>

#include<gpio.h>
#include<sysctl.h>
#include<ssi.h>

#include<hw_ssi.h>
#include<fpu.h>

#define PORTD_LOCK (*(unsigned long *)(GPIO_PORTD_BASE|0x0520))
#define PORTD_CR    (*(unsigned long    *)(GPIO_PORTD_BASE|0x0524))
#define PORTA_LOCK (*(unsigned long *)(GPIO_PORTA_BASE|0x0520))
#define PORTA_CR    (*(unsigned long    *)(GPIO_PORTA_BASE|0x0524))

void SSI_init(void);
void gpioInit(void);
int main(void)
{   char *pcChars = "Hey";
      char *rcvd;
    uint32_t *c,*junk;
    uint32_t t,s;
    int i;
        int32_t i32Idx;
    bool isEq=true;
    c=&t;
    junk=&s;


     gpioInit();
    //SSI0 module has been configured in master mode
    //SSI3 module has been configured in slave mode
    SSI_init();

    //
// Send some data.
//
i32Idx = 0;
while(pcChars[i32Idx])
{

    SSIDataPut(SSI0_BASE, pcChars[i32Idx]);
    SSIDataGet(SSI0_BASE,junk);

    SSIDataPut(SSI3_BASE,0xFF);
    SSIDataGet(SSI3_BASE,c);
    rcvd[i32Idx]=t;
i32Idx++;


}

for(i=0;i<sizeof(pcChars);i++)
{
    if(pcChars[i]!=rcvd[i])
    { isEq=false;
    }
}

if(isEq==true)
{
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,0x08);
}
return 0;
}

void SSI_init(void)
{

    // Configure the device to run at 80 MHz from the PLL using a 4 MHz crystal
    // as the input.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |SYSCTL_OSC_MAIN);
//
// Enable the SSI0 peripheral
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Wait for the SSI0 module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_SSI0))
{
}

SSIDisable(SSI0_BASE);

//unlock ports before use as SSI
PORTA_LOCK=0x4C4F434B;
PORTA_CR=0x3C;
// Set up pin muxing for SSI module
GPIOPinConfigure(GPIO_PA2_SSI0CLK);
GPIOPinConfigure(GPIO_PA3_SSI0FSS);
GPIOPinConfigure(GPIO_PA4_SSI0RX);
GPIOPinConfigure(GPIO_PA5_SSI0TX);

//setup pin type
GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5);

// Configure the SSI0.
SSIClockSourceSet(SSI0_BASE,SSI_CLOCK_SYSTEM);
SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(),SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER, 3300000, 8);
//
// Enable the SSI module.
//
SSIEnable(SSI0_BASE);

//
// Enable the SSI3 peripheral
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//
// Wait for the SSI module to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_SSI3))
{
}
//
// Configure the SSI.
//
SSIDisable(SSI3_BASE);

//unlock ports before use as SSI

PORTD_LOCK=0x4C4F434B;
PORTD_CR=0x0F;

// Set up pin muxing for SSI module
GPIOPinConfigure(GPIO_PD0_SSI3CLK);
GPIOPinConfigure(GPIO_PD1_SSI3FSS);
GPIOPinConfigure(GPIO_PD2_SSI3RX);
GPIOPinConfigure(GPIO_PD3_SSI3TX);

//setup pin type
GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

//configure SSI3 slave
SSIClockSourceSet(SSI3_BASE,SSI_CLOCK_SYSTEM);
SSIConfigSetExpClk(SSI3_BASE, SysCtlClockGet(),SSI_FRF_MOTO_MODE_0,SSI_MODE_SLAVE, 3300000, 8);
//
// Enable the SSI module.
//
SSIEnable(SSI3_BASE);
}

void gpioInit()
{

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
        {
        }

GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE,GPIO_PIN_3);

}

  • Hello Vikram,

    I am trying to understand exactly what you are wanting to achieve by sending the data from SSI3 to SSI0. Is there something you want to achieve beyond just SSI Loopback? There is a way to do SSI Loopback on a single SSI port, if that would meet your needs, I could share an example for you to use.

    Looking at your code you are doing Put and Get operations for the same SSI module next to each other so that looks more like a loopback operation than anything.
  • actually I was trying to check the SPI module on the MCU. My main idea was to interface a Nokia 510 LCD to it. I have successfully interfaced it now.