---
title: "Can't get information from W5500"
url: "https://maker.wiznet.io/forum/13389"
markdown_url: "https://maker.wiznet.io/forum/13389/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "danil m"
created: "2019-07-12T11:51:17+09:00"
last_activity: "2019-07-16T04:21:58+09:00"
language: "en"
views: 807
replies: 6
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Can't get information from W5500

## Question

Asked by danil m on 2019-07-12 in Ethernet Chips.

I’m trying to create TCP-client with using W5500 and ATmega328P. Now I can configurate chip (send data from atmega to w5500 via SPI) and it connect with server building at TCPIP builder. But I can’t read information (chip version, ip, status) from W5500.

For example there you can see diagram when I write CONNECT command in S0_CR, and it work fine:

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/5/51b24bce66c1f95389bc0fef5386f4764a766274.png) image1675×672 40.1 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/5/51b24bce66c1f95389bc0fef5386f4764a766274.png)

## Replies

### Reply 1 by danil m, 2019-07-12

Some addition. Can’t send more than 1 picture.

But if I try to read some information (chip version in this case) from chip I get this:

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/26cc9b591c71c5af122f9d6da4080ea409f70404.png) image1674×679 40 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/26cc9b591c71c5af122f9d6da4080ea409f70404.png)

### Reply 2 by danil m, 2019-07-12

I have already tried to change SPI mode to 0,2 and 3 according with this table, but nothing change:
![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/1/1a8321074e367a2a745c5c7458ec39adbd8472aa.png)

And I have tried to do handle RESET for chip before initialization (RST pin → HIGH, RST pin → LOW, delay, RST pin → HIGH), but in this case SPI don’t function ![:man_shrugging:](https://emoji.discourse-cdn.com/twitter/man_shrugging.png?v=12)

### Reply 3 by Eugeny, 2019-07-12 (in reply to reply 1)

![](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/48.png) danil_m:

> But if I try to read some information (chip version in this case) from chip I get this:
>
> [![image.png](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/26cc9b591c71c5af122f9d6da4080ea409f70404.png) image.png1674×679 40 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/2/26cc9b591c71c5af122f9d6da4080ea409f70404.png)

Where’s data phase? I see three control bytes sent, but you do not proceed reading the first data byte.

### Reply 4 by danil m, 2019-07-13

Thanks for answer!![:slightly_smiling_face:](https://emoji.discourse-cdn.com/twitter/slightly_smiling_face.png?v=12)
I just don’t know what I should to do after sending control phase byte. Is it correct that after writing 0 in R/W byte W5500 just send data on MISO?
I’m using this function for reading data from chip:

![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/e92d00b21b67e00cd40c4cec497d0bc4eed81ee0.png)

As you can see from diagrams I can send correct address bytes and control phase byte, but after it CLK signal stop. I have tried to wait before deselect W5500 and in this case there isn’t signal on CLK line.

### Reply 5 by Eugeny, 2019-07-15

Looks like code

```
buf[3]=SPDR;
```

is having problems. This code is intended to get 8 bits of data into `buf[3]`, but for some reason it does nothing,

Edit: I am not originally familiar with how ot works, but according to [this source](https://github.com/feilipu/avrfreertos/blob/master/freeRTOS82x/lib_iinchip/w5500.c)

```
SPDR = (uint8_t)((addrbsb & 0x00FF0000)>>16);	// load the Address byte 1 to be transmitted
Byte = (uint8_t)((addrbsb & 0x0000FF00)>> 8); 	// pre-load the Address byte 2 to be transmitted
while ( !(SPSR & _BV(SPIF)) );

SPDR = Byte;									// load the Address byte 2 to be transmitted
Byte =  (uint8_t)(addrbsb & 0x000000F8); 		// pre-load the Data Read command
while ( !(SPSR & _BV(SPIF)) );

SPDR = Byte;					// load the Data Read command
Byte = 0x5A;					// pre-load a dummy byte to be transmitted
while ( !(SPSR & _BV(SPIF)) );

SPDR = Byte;					// load a dummy byte to be transmitted
while ( !(SPSR & _BV(SPIF)) );

Byte = SPDR;					// copy received byte in case we get swapped out, and lose SPDR.

portEXIT_CRITICAL();

spiDeselect(Wiznet);			// CS=1, SPI end, give semaphore

WIZCHIP_ISR_ENABLE();

return Byte;
```

you must perform the dummy byte write to SPDR (which value does not matter for reading the data) and obtain read data from the same register `SPDR`. Thus your mistake that you omit writing to SPDR.

### Reply 6 by danil m, 2019-07-16

Thanks, Eugeny. Now it’s working fine ![:+1:](https://emoji.discourse-cdn.com/twitter/+1.png?v=12)

---

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