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.

F28335 SPI RXBuffer Read issue

Other Parts Discussed in Thread: CONTROLSUITE

Hello,

I'm using the SPI module of the F28335 to interface with a WIZ820io W5200 ethernet device. I can set up the WizNet just fine, but my problem arises when I want to read/write packets. I am unable to read incoming packets consistently and I am wondering if the issue has to do with how I am pulling the data from the SPI RXBuffer.

I have it set up for an 8 bit word length. Shown below is my SPI init function and my SPI read/write function. 

void spi_fifo_init(){
	//Initialize SPI FIFO registers
	SpiaRegs.SPIFFTX.all = 0xE040;	//Transmit registers
	SpiaRegs.SPIFFRX.all = 0x204f;	//Read registers
	SpiaRegs.SPIFFCT.all = 0x00;	// Transmit delay = no delay

	SpiaRegs.SPICCR.all =0x0047;	             // Reset on, rising edge, 16-bit char bits
	SpiaRegs.SPICTL.all =0x0006;    		    	// Enable master mode, normal phase,
                                                 // enable talk, and SPI int disabled.
	//SpiaRegs.SPIBRR =0x004A;					 // Baud rate = LSPCLK/(4)
	SpiaRegs.SPIBRR =0x00f0;
	SpiaRegs.SPICCR.all =0x00c7;		         // Relinquish SPI from Reset, 8 bit
        SpiaRegs.SPIPRI.bit.FREE = 1;                // Set so breakpoints don't disturb xmission

}




Uint8 spi_Write(Uint8 msg){
	// loads buffer and sends it out
	Uint16 Tdata = (0xFF00)&(msg<<8);
        SpiaRegs.SPITXBUF = Tdata;
  	while(SpiaRegs.SPIFFRX.bit.RXFFST!=1) { }
	
  	
	Uint8 rdata = (0xFF & (SpiaRegs.SPIRXBUF));
	return rdata;
	

}

  • As datasheet pag17 says,
    Data must be left-justified when written to SPIDAT and SPITXBUF :
    Uint16 Tdata = (msg<<8);
    Data read back from SPIRXBUF is right-justified
    Uint8 rdata = SpiaRegs.SPIRXBUF;
    You can debug this, using the loopback in the SPI Configuration Control Register (SPICCR). Check controlSuite for code example.

    Gastón
  • I probed with a scope and the data I'm sending out on the MOSI line is correct. I can also see data coming in on the MISO Line, but that data doesn't seem to make it out of the buffer (?). For example, I'm trying to read a data packet from the WizNet and following their procedures, I'm reading the recv length first, which according to the MISO line has a value of (for example) 0x18, but when I write try to read that in the code, it just shows zeros.  I'm not sure what is wrong because I am still able to interact with the WIzNet in other ways, such as polling the status register, with no issue. It's just very confusing and if anyone has any idea why I might be having issues reading the correct length of received data, your help would be greatly appreciated. 

  • Hello,

    Quick update: So something changed and now I believe I'm seeing reasonable packet sizes from the WizNet receive buffer, but I'm still having trouble actually reading the data. I seem to be getting the same thing over and over, even if we reset and send different data packets. Has anyone worked with this combination of devices before or does anyone know of a helpful library I could use to get communication between the micro and WizNet officially working?

    Thanks again,

    Caitlin F.