Can't get information from W5500

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:

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:

I have already tried to change SPI mode to 0,2 and 3 according with this table, but nothing change:

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:

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

Thanks for answer!:slightly_smiling_face:
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:


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.

Looks like code


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

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.


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


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.


Thanks, Eugeny. Now it’s working fine :+1: