W5200 Sn_CR(0) register is not clearing automatically


#1

Hi

I’m using W5200 and your driver V1.5 with my STM32F103 board.

I have written the initial registers such (GAR, SUBR SIPR etc)
all are ok.

But When I try to initiate sockets by sending following fucntion
socket(s, Sn_MR_TCP , S0_SourcePort, 0)

The w5200 chip starts endless loop

I have debugged in detail. The cpu is going to endless loop in close(s) command
The cpu sends Sn_CR_CLOSE command. But the chip is not operating.
Sn_CR(0) register content is always 0xFF after sending the close command.
It should be cleared to 0x00 automatically


*/
void close(SOCKET s)
{
#ifdef DEF_IINCHIP_DBG
printf(“close()\r\n”);
#endif

IINCHIP_WRITE(Sn_CR(s),Sn_CR_CLOSE);

/* wait to process the command... */
while( IINCHIP_READ(Sn_CR(s)) ) 
	;
/* ------- */
            /* all clear */
	IINCHIP_WRITE(Sn_IR(s), 0xFF);

}


Rgds


#2

Hi, Selaslan

You’re right. After W5200 identifies the command, the Sn_CR register is automatically cleared to 0x00.
Even though Sn_CR is cleared to 0x00, the command is still being processed.
Therefore, you have to check the Sn_IR or Sn_SR registers.

I could not understand.
You says "Sn_CR(0) register content is always 0xFF after sending the close command."
Sn_CR don’t have 0xFF. If you read the Sn_IR after Sn_CR command excute, It has 0xFF.

Please you have to check the Sn_IR or Sn_SR registers.

Best regards,
Irian Kim :smiley: