---
title: "Spi communication problem"
url: "https://maker.wiznet.io/forum/13711"
markdown_url: "https://maker.wiznet.io/forum/13711/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Zack1"
created: "2020-02-19T10:57:55+09:00"
last_activity: "2020-03-12T00:59:59+09:00"
language: "en"
views: 922
replies: 4
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Spi communication problem

## Question

Asked by Zack1 on 2020-02-19 in Ethernet Chips.

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;

## Replies

### Reply 1 by Zack1, 2020-02-20

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

### Reply 2 by Zack1, 2020-02-20

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.

### Reply 3 by Zack1, 2020-02-25

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&lt;4;i++)
{
SpiaRegs.SPITXBUF = (spi_data[i]&lt;&lt;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

[![PA03](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/eef3a26b1736e1e20f2dba6c64cc996af779fb39.png) PA031280×824 18 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/eef3a26b1736e1e20f2dba6c64cc996af779fb39.png)

### Reply 4 by Zack1, 2020-02-27

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?

---

Source: https://maker.wiznet.io/forum/13711
