[From QnA]W5200 Sn_CR command execution

I am having issues getting the W5200 (on the Elecrow Arduino shield) to perform correctly.

The W5200 datasheet v1.3 states that Sn_CR register should achieve 0x00 once a command is digested.
In fact the entire example code is written based on the test of this result being 0x00, following each command. In my case this does not happen.

The Sn_CR register contains the bytecode of the last transaction, indefinitely.

When I test the Sn_CR register following any command, it holds the command byte as was written.

Also, the Sn_SR byte doesn’t always change.

A simple example is to Open a UDP socket, wait some time, and then close it. The socket (Sn_SR) never goes into open status. It remains in ARP status.

Then, when I issue the close command to Sn_CR the command remains to be read from the the register. It never resets to 0x00. And the Sn_SR never goes back to 0x00 (closed).

Any thoughts as to why this might be happening?

Dear customer.
Thanks for your interest in W5200.
I think you write wrong address.
Please, try to read Chip version register.
It is because our example source code is designed by using offset address from base address.
So if you set wrong base address, you write or read wrong registers.
Thanks.
WIZnet.

Thank you for the hint. Quite simple really.

SPDR = (uint8_t)(addr & 0xFF00) >> 8;

is not the same as:

SPDR = (uint8_t)((addr & 0xFF00) >> 8);

Regards.