WIZnet Developer Forum

W5500 Sn_SR is returning wrong values

Hi to everyone. I hope that you can help me with this “issue”. I am new to the world of c and micro controllers.
I am working with:
W5200 and Atmega328p
W5500 and Atmega328p

This is the scenario:
I am using netcat on my windows computer so I can try with W5500 a TCP connection.
I am using the ioLibrary provided by Wiznet.

I am able to establish a connection with the W5200 with out any issues but when I try the same with the w5500 for some reason it drops the connection.
Everything seems that is working, I can establish the connection but after some X sec it drops the connection. To handle the connection I am checking the Sn_SR.

What I found is that after the connection is established( 0x17 according to the datasheet) for some reason, some times when I read this register it gives me numbers that do not exist on the data sheet, for example: 0x80, 0xc9,0xe4, 0x00(this is = to SOCK_CLOSED).

The numbers 0x80, 0x1e I do not worry about but when I read 0x00 then I think that the socket was closed for some reason so I reinitialize it and I try to connect to the server again but the server thinks that is still connected because the connection was actually never dropped.

This is how I found out about those numbers:
uint8_t status = getSn_SR(tcp_socket);
if( status != 0x17 ) printf(“why I get this!!!? 0x%x\r\n”,status );

***If I do not check for the 0x17 I will never read the other values because the 0x17 is the number it normally appears and I am checking this value as fast as I can.
*** this is a basic example but I get hundreds of 0x17: 0x17,0x17,0x17,0x00,0x17,0x17,0x17,0x80,0x17,0x17

Maybe this is not even related but is what it makes sense to me.
Also I base my code on the loopback.c and .h files that are in the ioLibrary.

Sounds like board is faulty, OR you select wrong memory location, OR your SPI protocol is broken, OR timing requirements are not met (in terms of access to the chip). 80, c9 and e4 are invalid values for SR.
Make simple test: without any connection, or even without initializing the chip, read register set in loop as fast as you can, and compare each set read. If you will start getting different values in the sets, you have problems with accessing the chip.

Thanks for your reply (Eugeny).

This words direct me to the issue “without any connection”. For some reason the programmer was interfering with my spi line. I simple unplug the programmer and now it works. The programmer I was using was AVR ISP mkII. I tried with Atmel-ICE and the same issue appear.At the end the programmer that works for me was JTAGICE3. This could be a Issue on the board but for now JTAGICE3 is working for me.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.