Spi communication problem

hello,
i am trying to interface W5500 with TI’s tms320f28335.
I did all the initialisations as per the data sheet. And tried to read back the Version register but am getting wrong values every time.
The initialisation code and the Data transmittind command is as shown.
void spi_init()
{
SpiaRegs.SPICCR.all =0x0007; // Reset on, falling edge, 8-bit char bits
SpiaRegs.SPICTL.all =0x00E; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpiaRegs.SPIBRR =0x001F;
SpiaRegs.SPICCR.all =0x0087; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don’t disturb xmission
}
void_sendFrame
{
GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1;
sdata = 0x00;
spi_xmit(sdata);

 sdata = 0x39;
 spi_xmit(sdata);

 sdata = 0x00;
 spi_xmit(sdata);

 sdata =0x00;
 spi_xmit(sdata);

 GpioDataRegs.GPBSET.bit.GPIO57=1;

}
rdata = 0x00;
rdata = SpiaRegs.SPIRXBUF;

Hi!

Did you check SPI signal with osilloscope?
How to fast SPI clock?

You get some useful information on this forum.
Search “w5100 & spi”.

Thank you.

yes i did check all the SPI signals with the Scope.
Am getting all the signals as required.

If SPI signal is all good, there may be otehr issue.

Did you check another signals such as Xtal, Phy Link, Reset?

And try to test again with low speed SCLK.

Thank you.

I am getting the version register value as
0x01 on the first try
0x02 on the second and
0x03 on the third.
and 0x04 on the 4rth…
i have read in this forum that sending 0x01 , 0x02, 0x03, is normal behaviour.
but why 0x28 unsted of 0x04.

OK. I understand.
It is normal from step 1 to step 3, but step4 is not good.

can you try to test as following code?

void_sendFrame
{
   GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1;

   sdata = 0x00;
   spi_xmit(sdata);
   sdata = 0x39;
   spi_xmit(sdata);
   sdata = 0x00;
   spi_xmit(sdata);
   sdata =0x00;
   spi_xmit(sdata);
   rdata = SpiaRegs.SPIRXBUF;

  GpioDataRegs.GPBSET.bit.GPIO57=1;
}

and,
check to other reg register such as RCR and RTR.

Thank you.

midnightcow,
Really thanks for the help sir,
With that above code the data was not being send for some reason i dont know.
Now i changed the code for transmitting part as mentioned below.

void send_frame
{
Uint16 spi_data[4]={0,};
Uint8 i;
spi_data[0] = 0x00;
spi_data[1] = 0x39;
spi_data[2] = 0x00;
spi_data[3] = 0x00;
GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1; //cs low
for (i=0;i<4;i++)
{
SpiaRegs.SPITXBUF = (spi_data[i]<<8);
}

rdata =SpiaRegs.SPIRXBUF;
GpioDataRegs.GPBSET.bit.GPIO57 = 1; //cs high
}

void spi_init()
{
SpiaRegs.SPICCR.all =0x0007; // Reset on, falling edge, 8-bit char bits
SpiaRegs.SPICTL.all =0x000E; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpiaRegs.SPIBRR =0x001F;
SpiaRegs.SPICCR.all =0x0087; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don’t disturb xmission
}

I did probe the spi Bus and the screenshot of the same is attached herewith

Am reading the version register correctly now,
But i have some doubt.
I got the the value 0x04 on the 4th read only.
So this happens for every other register?
That this dummy byte of 0x01 0x02 0x03 comes?

Sorry, I checked ti later.

The dummy bytes such as 0x01, 0x02, 0x03, 0x04 represents some states of SPI transactions.

0x01 : Operaton State
0x02: High addresss state
0x03 : Low address state
0x04: Data Write state

In read case, You can get a real data to be read instead of 0x04.
For more detail, refer to data sheet.

Thank you.