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.

SSI as slave receiving data

Other Parts Discussed in Thread: TM4C123GH6PM

I am trying to receive data from an SPI master (specifically a Raspberry Pi SBC) using a TM4C123GH6PM as an SPI slave. Data is being placed on the SPI3 MOSI pin, a clock is present on the SPI3 CLK pin and an active LOW frame select signal is present on SPI nFSS.

On every nFSS event I am getting an interrupt and the SSIDataGet function stops blocking. However, regardless of the data communicated, the data received is always zero.

The eventual plan is to use DMA to receive the data into an internal buffer. However for now I decided to just get it working using interrupts and polling, to prove the SPI module can receive data.

The initialisation routine I am using:

void init_ssi3()
{
	SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
	SSIDisable(SSI3_BASE);
	GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0);
	GPIOPinConfigure(GPIO_PD0_SSI3CLK);
	GPIOPinConfigure(GPIO_PD1_SSI3FSS);
	GPIOPinConfigure(GPIO_PD2_SSI3RX);
	GPIOPinConfigure(GPIO_PD3_SSI3TX);
	SSIConfigSetExpClk(SSI3_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_SLAVE, RASPI_SPI_RATE, 8);
	SSIIntEnable(SSI3_BASE, SSI_RXFF);
	SSIIntRegister(SSI3_BASE, SSI3InterruptRequest);
	SSIEnable(SSI3_BASE);
}

RASPI_SPI_RATE is set to a nominal 500kHz (value 500000). The master is transmitting at ~430kHz. I have tried setting the SPI rate to 430000 Hz but this makes no difference. However I would like the clock rate to be non critical i.e. the master will be clocking the slave and that rate may vary if the CPU is under more or less load.

Scope screenshots are attached; Cyan is clock, Yellow is MOSI, Purple is nFSS and Blue is MISO (slave not transmitting). 

As a data point - I have tried transmitting upon receiving an interrupt however nothing happens. It does not block or transmit data. If the nFSS or clock is missing the function blocks so it does appear to depend on this being present.

Thanks for any suggestions,

  • Hello Tom,
    Does your IRQ routine run at the point of nFSS going low? If so the received data could well be zero as from your timing nFSS goes low before any data is received. Are you waiting for an SPI byte to be received in the IRQ routine? Would also running a very simple version of the code that drops through if anything but 0x00 is received help you troubleshoot? Then I'd tie the MOSI line high while I troubleshot to rule the data and it's timing out of the equation.
  • Hello Tom,

    As I read your post: there are 2 issues.

    1. Slave is not transmitting any data to the master in MISO
    2. Slave is not receiving any data from the master on MOSI, even though the data is being sent (as shown in the snapshot)

    The initialization is fine, but how are you sending the data or receiving the same?

    Regards
    Amit
  • I set up an LED pin (sinking current) to go LOW on interrupt. It does occur after the first byte. Blue trace on below scope trace. I have noticed it is intermittent - perhaps because the main code is also reading data.

    However I did notice bringing my fingers near the IC caused the data to toggle to 0xff occasionally - I am now investigating a possible soldering error or an IO misconfiguration.

  • "However I did notice bringing my fingers near the IC caused the data to toggle to 0xff occasionally "

    Does sound like something floating about. Sounds like you're looking for something relatively high impedance. Tom have you tried slightly loading the CLK & DATA lines with something like 100K to GND so it makes it easier to see any floating bus issues on the scope?

  • Solved. It was pretty easy once I looked under the eye mag. The data in pin wasn't soldered at all to the board. Seems to be working now. It's usually the easiest things :)

    Thanks for all advice.
  • Glad you have it working Tom.