Sn_MR register returns 0 after a while

Dear Wiznet Support Team,
we’ve started to implement a webserver using the Wiz820io Modul.
The web server provides a small page which is requested automatically by the browser every second.
The module closes the connetion after transmitting the web page and the browser opens the connection again.
This works quite well, but after a certain time (3-10 minutes) the request of the browser won’t be accepted by the module anymore.
If we then debug the programm we noticed, that during “re-open” of the socket, when we have to write to mode register (SnMR = 0x1 for TCP), it doesn’t hold it’s value.

uint8 socket(SOCKET s, uint8 protocol, uint16 port, uint8 flag)
uint8 ret;
if ((protocol == Sn_MR_TCP) || (protocol == Sn_MR_UDP) || (protocol == Sn_MR_IPRAW) || (protocol == Sn_MR_MACRAW) || (protocol == Sn_MR_PPPOE))

	[color=#FF0000]IINCHIP_WRITE(Sn_MR(s),protocol | flag);[/color]

[color=#FF0000]// reading back SnMR here returns 0 [/color]

	if (port != 0) {
		IINCHIP_WRITE(Sn_PORT0(s),(uint8)((port & 0xff00) >> 8));
		IINCHIP_WRITE((Sn_PORT0(s) + 1),(uint8)(port & 0x00ff));
	} else {
		local_port++; // if don't set the source port, set local_port number.
		IINCHIP_WRITE(Sn_PORT0(s),(uint8)((local_port & 0xff00) >> 8));
		IINCHIP_WRITE((Sn_PORT0(s) + 1),(uint8)(local_port & 0x00ff));
	IINCHIP_WRITE(Sn_CR(s),Sn_CR_OPEN); // run sockinit Sn_CR

	/* wait to process the command... */
	while( IINCHIP_READ(Sn_CR(s)) ) 
	/* ------- */
	ret = 1;
	ret = 0;

printf(“Sn_SR = %.2x , Protocol = %.2x\r\n”, IINCHIP_READ(Sn_SR(s)), IINCHIP_READ(Sn_MR(s)));
return ret;

That means if we read back the SnMR we get 0x0 instead of 0x1.
We checked the SPI address and data values with the oscilloscope everthing is OK and indeed the module returns 0 instead the 0x1 we’ve wrote before to the register.

Do you have any idea according to the reasons of this behaviour?

Thanks a lot!
Best regards


Socket mode register is not written??
Mode register value cannot be changed itself.

Hi hjjeon0608,

thank you for your reply!

→ Socket mode register is not written??
The mode register is written via the following instruction, the value is: (protocol | flag)
[color=#FF0000]IINCHIP_WRITE(Sn_MR(s),protocol | flag);[/color]

So when we directly read back the mode register after writing we expect, that we read back the same value we’ve wrote before. What obviously works in most of the cases but randomly the mode register returns 0.

→ Mode register value cannot be changed itself.
What excactly do you mean with this statment, can you please explain.

Thanks a lot