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.

F28377S SPI operation for 8-bit word

Hi guys, I'm trying to setup the F28377S SPI module as a slave but to no avail, the master always receive 0xFF. The config snippet is as follow:

void spi_init()
{    
	SpiaRegs.SPICCR.bit.SPISWRESET = 0;
	SpiaRegs.SPICTL.bit.MASTER_SLAVE = 0;		 //Slave mode
	SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
	SpiaRegs.SPICTL.bit.CLK_PHASE = 0;
	SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = 99;
	SpiaRegs.SPICCR.bit.HS_MODE = 0;
	SpiaRegs.SPICCR.bit.SPILBK = 0;
	SpiaRegs.SPICCR.bit.SPICHAR = 8;
	SpiaRegs.SPIPRI.bit.TRIWIRE = 0;                // Disable 3-wire mode
	SpiaRegs.SPIPRI.bit.STEINV = 0;
	SpiaRegs.SPICTL.bit.SPIINTENA = 0;
	SpiaRegs.SPICTL.bit.TALK = 0;
	SpiaRegs.SPICTL.bit.OVERRUNINTENA = 0;
	SpiaRegs.SPICCR.bit.SPISWRESET = 1;		         // Relinquish SPI from Reset
//	SpiaRegs.SPICCR.all =0x009F;

        SpiaRegs.SPIPRI.bit.FREE = 1;                // Set so breakpoints don't disturb xmission
}

And this is the transmit procedure:

for(;;)
   {    
	 sdata = txdata << 8;
     // Transmit data
     spi_xmit(sdata);
     // Wait until data is received
     while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { }
     // Check against sent data
     rdata = SpiaRegs.SPIRXBUF;
   }

The Raspberry Pi is my SPI master and I set the master SPI clock to 500 kHz. Raspberry Pi SPI can only work with 8-bit data.

  • Hi,

    For 16-bit mode, SPICHAR = 0xF so for 8-bit, it should be 0x7 0r decimal 7.
    SpiaRegs.SPICCR.bit.SPICHAR = 7;

    Also please ensure that SPI clock & phase (mode 0-3) is configured correctly if F28377S as a SLAVE device.


    -Aditya