---
title: "W5500 stuck on Socket Close Function - while( getSn_CR(sn) )"
url: "https://maker.wiznet.io/forum/15202"
markdown_url: "https://maker.wiznet.io/forum/15202/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "ClariceStarling"
created: "2024-04-19T20:43:08+09:00"
last_activity: "2024-04-23T13:43:30+09:00"
language: "en"
views: 224
replies: 21
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5500 stuck on Socket Close Function - while( getSn_CR(sn) )

## Question

Asked by ClariceStarling on 2024-04-19 in Ethernet Chips.

Hello,

I am using the W5500 chip as a module and connected it to the Nuvoton M032 chip. I checked the SPI connections. No matter what I do, I can’t get past the following line. The code keeps getting stuck on this line → **while( getSn_CR(sn) );**
This line is inside this function
socket() → close() → while( getSn_CR(sn) );

For this reason, I cannot create a TCP Server or client application.

When I examine the return value of this function, it gives the following values: 0x01, 0x02 and continues to give 0x01.

**Server Program:** Hercules
**PC IP:** 192, 168, 1, 106
**Port:** 7000

My codes are as follows.

**Thanks.Best regards.**

```
#include "main.h"

#include "wizchip_conf.h"
#include "socket.h"

uint8_t WIZNET_SPI_Read_Byte(void)
{
	/* Check SPI0 busy status */
	while (USPI_IS_BUSY(SD_SPIx));
	
	/* Read received data */
	return (USPI_READ_RX(SD_SPIx) & 0xFF);
}

void WIZNET_SPI_Write_Byte(uint8_t data)
{
	/* Write Byte */
	USPI_WRITE_TX(SD_SPIx, data);

	/* Check SPI0 busy status */
	while (USPI_IS_BUSY(SD_SPIx)); 
}

uint8_t serverIP[4] = { 192, 168, 1, 106 };
uint16_t serverPort = 7000;

int main(void)
{
	SYSTEM_Initialize();
	
	SPI_Init(SD_SPIx, SPI_CLK_FREQ);
	
	WIZNET_RESET_LOW();
	Delay_ms(5);
	WIZNET_RESET_HIGH();

	SPI_CS_High();
	reg_wizchip_cs_cbfunc(SPI_CS_Low, SPI_CS_High);
	reg_wizchip_spi_cbfunc(WIZNET_SPI_Read_Byte, WIZNET_SPI_Write_Byte);
	
	uint8_t memsize[2][8] = { {2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2} };
	uint8_t tmp;
		
	if(ctlwizchip(CW_INIT_WIZCHIP, (void*)memsize) == -1)
	{
		//myprintf("WIZCHIP Initialized fail.\r\n");
		LED_On();
		while(1);
	}
	/* PHY link status check */
	do {
		if(ctlwizchip(CW_GET_PHYLINK, (void*)&tmp) == -1)
		{
			//printf("Unknown PHY Link status.\r\n", 1, 10);
			while(1);
		}
	} while (tmp == PHY_LINK_OFF);
	
	wiz_NetInfo netInfo = { .mac  = { 0x2C, 0xF7, 0xF1, 0x08, 0x00, 0x9A },		// Mac address
									.ip 	= { 192, 168, 1, 31 },								// IP address
									.sn 	= { 255, 255, 255, 0 },								// Subnet mask
									.gw 	= { 192, 168, 1, 1 },
									.dns  = { 0, 0, 0, 0 },
									.dhcp = NETINFO_STATIC };						

	wizchip_setnetinfo(&netInfo);
	wizchip_getnetinfo(&netInfo);	
							
	while (1)
	{  			
		ret = socket(sn, Sn_MR_TCP, serverPort, 0x00);  // STUCK HERE !
		LED_On();
        }
}
```

[![error](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/7/72c9ae14f147100f79b0c25a594017db5b60920d.png) error1236×388 21 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/7/72c9ae14f147100f79b0c25a594017db5b60920d.png)

[![hercules](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/c/c362750754f0893b7bfd464d2805c1b71e5a1a7f.png) hercules765×670 41.9 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/c/c362750754f0893b7bfd464d2805c1b71e5a1a7f.png)

[![setup](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/c/ce8704b3833c0b4fc8a948a7cbb60a8960c24517.jpeg) setup1200×1600 318 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/c/ce8704b3833c0b4fc8a948a7cbb60a8960c24517.jpeg)

## Replies

### Reply 1 by Eugeny, 2024-04-20

Prove that SPI communication functions properly by reading VERSIONR register and getting 0x01, 0x02, 0x03 and 0x04.

### Reply 2 by ClariceStarling, 2024-04-20 (in reply to reply 1)

This is the SPI timing for tihs code its okay for chip version! But what is the problem ![:frowning:](https://emoji.discourse-cdn.com/twitter/frowning.png?v=12)

```
SYSTEM_Initialize();
	
	SPI_Init(SD_SPIx, SPI_CLK_FREQ);
		
	WIZNET_RESET_HIGH();
	Delay_ms(250);
		
		
	SPI_CS_Low();
	
	USPI_WRITE_TX(SD_SPIx, 0x00);
	while (USPI_IS_BUSY(USPI0));
		
	USPI_WRITE_TX(SD_SPIx, 0x39);
	while (USPI_IS_BUSY(USPI0));
	
	USPI_WRITE_TX(SD_SPIx, 0xFF);
	while (USPI_IS_BUSY(USPI0));
	version[0] = (USPI_READ_RX(USPI0) & 0xFF);	
	
	USPI_WRITE_TX(SD_SPIx, 0x00);
	while (USPI_IS_BUSY(USPI0));
	version[1] = (USPI_READ_RX(USPI0) & 0xFF);

	USPI_WRITE_TX(SD_SPIx, 0x00);
	while (USPI_IS_BUSY(USPI0));
	version[2] = (USPI_READ_RX(USPI0) & 0xFF);	
	
	USPI_WRITE_TX(SD_SPIx, 0x00);	
	while (USPI_IS_BUSY(USPI0));
	version[3] = (USPI_READ_RX(USPI0) & 0xFF);
		
	SPI_CS_High();
```

[![Timing](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/a67e8ff5391c5c6017e57f3e1317fae3a5efe2f2.png) Timing1574×543 26.9 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/a/a67e8ff5391c5c6017e57f3e1317fae3a5efe2f2.png)

### Reply 3 by Eugeny, 2024-04-20

![](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/48.png) ClariceStarling:

> [![error](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/7/72c9ae14f147100f79b0c25a594017db5b60920d.png) error1236×388 21 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/7/72c9ae14f147100f79b0c25a594017db5b60920d.png)

What is the value of `sn` here? Not the one you may think of, but real value reported by the MCU?

### Reply 4 by ClariceStarling, 2024-04-20 (in reply to reply 3)

sn = 0;

But reading the version of chip

register level code returns 0x04. It ok as you can see in my previous message (Logic Analyzer)

But this function returns 0x01 → chipVersion = getVERSIONR();

Is this a SPI function problem ?

### Reply 5 by Eugeny, 2024-04-20

![](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/48.png) ClariceStarling:

> But this function returns 0x01 → chipVersion = getVERSIONR();

Then look at what is going on the bus when you perform this call. Did you select the right chip within the library?

### Reply 6 by ClariceStarling, 2024-04-20

Yes there is W5500. Its ok.

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/8/89e5909893f4c401fec9ec3a4c2d130923460ee1.png) image1013×392 19.6 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/8/89e5909893f4c401fec9ec3a4c2d130923460ee1.png)

### Reply 7 by ClariceStarling, 2024-04-20

Oh my god what is this function?

```
#include "main.h"

#include "wizchip_conf.h"
#include "socket.h"

uint8_t WIZNET_SPI_Read_Byte(void);
void WIZNET_SPI_Write_Byte(uint8_t data);

uint8_t chipVersion = 0;

int main(void)
{
	SYSTEM_Initialize();
	
	SPI_Init(SD_SPIx, SPI_CLK_FREQ);
		
	WIZNET_RESET_LOW();
	Delay_ms(250);
	WIZNET_RESET_HIGH();
	Delay_ms(250);
	SPI_CS_High();
		
	reg_wizchip_cs_cbfunc(SPI_CS_Low, SPI_CS_High);
	reg_wizchip_spi_cbfunc(WIZNET_SPI_Read_Byte, WIZNET_SPI_Write_Byte);

	chipVersion = getVERSIONR();

	while (1)
	{  				
		
	}
}

/**
 * @brief
 * @param
 * @retval
 */
void SYSTEM_Initialize(void)
{
	General_Init();
}

uint8_t WIZNET_SPI_Read_Byte(void)
{
	/* Check SPI0 busy status */
	while (USPI_IS_BUSY(SD_SPIx));
	
	/* Read received data */
	return (USPI_READ_RX(SD_SPIx) & 0xFF);
}

void WIZNET_SPI_Write_Byte(uint8_t data)
{
	/* Write Byte */
	USPI_WRITE_TX(SD_SPIx, data);

	/* Check SPI0 busy status */
	while (USPI_IS_BUSY(SD_SPIx));
}
```

this function cannot read the last byte ( **chipVersion = getVERSIONR();** )

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/d/de9e69bdc5f9682d24eb94eb439b6650a370b99c.png) image1560×537 25.7 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/d/de9e69bdc5f9682d24eb94eb439b6650a370b99c.png)

### Reply 8 by Eugeny, 2024-04-20 (in reply to reply 7)

Your definition is framed within `#ifndef`. You are not guaranteed to have exactly this value defined if it was defined somewhere else beforehand. Dig into library and put diagnostic outputs into its flow to prove it does required thing.

### Reply 9 by ClariceStarling, 2024-04-20

I did but there is no change

### Reply 10 by Eugeny, 2024-04-20

If you’d do this (second thing I said) you’d know how `getVERSIONR();` works for you, what it does, and where’s a problem.

### Reply 11 by ClariceStarling, 2024-04-20

Something feels wrong in the library.
I think the SPI buffer is not being cleared.
That’s why I cleaned it by reading after each sending process.

```
uint8_t  WIZCHIP_READ(uint32_t AddrSel)
{
   uint8_t ret;
   uint8_t spi_data[3];

   WIZCHIP_CRITICAL_ENTER();
   WIZCHIP.CS._select();

   AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_);

   if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) 	// byte operation
   {
	   WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
		ret = WIZCHIP.IF.SPI._read_byte(); // ADDED
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >>  8);
		ret = WIZCHIP.IF.SPI._read_byte(); // ADDED
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >>  0);
		ret = WIZCHIP.IF.SPI._read_byte(); // ADDED
   }
   else																// burst operation
   {
		spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
		spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
		spi_data[2] = (AddrSel & 0x000000FF) >> 0;
		WIZCHIP.IF.SPI._write_burst(spi_data, 3);
   }
	WIZCHIP.IF.SPI._write_byte(0); // ADDED - WRITE DUMMY FOR READ (GENERATE SPI CLOCK)
   ret = WIZCHIP.IF.SPI._read_byte();

   WIZCHIP.CS._deselect();
   WIZCHIP_CRITICAL_EXIT();
   return ret;
}
```

I can connect now!
But a new problem arose.

When I send data with the send function after the connection process, the data is sent only once. When I want to send it later, the send function returns the following value
#define SOCKERR_SOCKSTATUS (SOCK_ERROR - 7) ///&lt; Invalid socket status for socket operation.

```
#include "main.h"

#include "wizchip_conf.h"
#include "socket.h"

uint8_t WIZNET_SPI_Read_Byte(void);
void WIZNET_SPI_Write_Byte(uint8_t data);

uint8_t serverIP[4] = { 192, 168, 1, 106 };
uint16_t serverPort = 5002;

uint8_t chipVersion = 0;
uint8_t memsize[2][8] = { {2, 2, 2, 2, 2, 2, 2, 2}, {2, 2, 2, 2, 2, 2, 2, 2} };
uint8_t tmp;
uint8_t sn = 3;

uint8_t socketStatus = 0xFF;
int8_t connectionStatus = -1;
int32_t sendStatus = -1;
	
uint8_t sendBuff[2] = {'S', 'A'};
	
int main(void)
{
	SYSTEM_Initialize();
	
	SPI_Init(SD_SPIx, SPI_CLK_FREQ);
		
	WIZNET_RESET_LOW();
	Delay_ms(250);
	WIZNET_RESET_HIGH();
	Delay_ms(250);
	SPI_CS_High();
		
	reg_wizchip_cs_cbfunc(SPI_CS_Low, SPI_CS_High);
	reg_wizchip_spi_cbfunc(WIZNET_SPI_Read_Byte, WIZNET_SPI_Write_Byte);

	chipVersion = getVERSIONR();
	
	// Init WIZNET W5500
	if(ctlwizchip(CW_INIT_WIZCHIP, (void*)memsize) == -1)
	{
		//myprintf("WIZCHIP Initialized fail.\r\n");
		while(1);
	}
	
	// PHY link status check
	do {
		if(ctlwizchip(CW_GET_PHYLINK, (void*)&tmp) == -1)
		{
			//printf("Unknown PHY Link status.\r\n", 1, 10);
			while(1);
		}
	} while (tmp == PHY_LINK_OFF);

	wiz_NetInfo netInfo = { .mac  = { 0x2C, 0xF7, 0xF1, 0x08, 0x00, 0x9A },		// Source Mac Address
									.ip 	= { 192, 168, 1, 31 },								// Source IP Address
									.sn 	= { 255, 255, 255, 0 },								// Subnet mask
									.gw 	= { 192, 168, 1, 1 }, 								// Gateway IP Address
									.dns  = { 0, 0, 0, 0 }, 									// DNS server IP Address		
									.dhcp = NETINFO_STATIC };									// 1 - Static, 2 - DHCP
	
	wiz_NetInfo	getInfo;
									
	wizchip_setnetinfo(&netInfo);
	wizchip_getnetinfo(&getInfo);
				
	while (socketStatus != sn)
	{
		socketStatus = socket(sn, Sn_MR_TCP, serverPort, SF_TCP_NODELAY);
	}
	
	while (connectionStatus != SOCK_OK)
	{
		connectionStatus = connect(sn, (uint8_t *)serverIP, serverPort);
	}
						
	while (1)
	{  				
		sendStatus = send(sn, sendBuff, 2);
		
		if (sendStatus < 0) 
		{
			close(sn);
			LED_On();
		}
		
		Delay_ms(500);
	}
}

/**
 * @brief
 * @param
 * @retval
 */
void SYSTEM_Initialize(void)
{
	General_Init();
}

uint8_t WIZNET_SPI_Read_Byte(void)
{
	/* Check SPI0 busy status */
	while (USPI_IS_BUSY(SD_SPIx));

	/* Read received data */
	return (USPI_READ_RX(SD_SPIx) & 0xFF);
}

void WIZNET_SPI_Write_Byte(uint8_t data)
{
	/* Write Byte */
	USPI_WRITE_TX(SD_SPIx, data);

	/* Check SPI0 busy status */
	while (USPI_IS_BUSY(SD_SPIx));
}
```

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/3/38390bf458575a725cf8fe0490c7989dd86e7045.png) image1175×540 22.1 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/3/38390bf458575a725cf8fe0490c7989dd86e7045.png)

### Reply 12 by Eugeny, 2024-04-20

![](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/48.png) ClariceStarling:

> When I want to send it later

What does it mean “later”? What status the socket has when this “later” happens?

### Reply 13 by ClariceStarling, 2024-04-20

sorry for wrong explanation ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
It sends data only once, but when I try to send it a second time, it gives the -7 error.

### Reply 14 by Eugeny, 2024-04-20

What is the socket status when you try doing it? May happen socket is already in the state when sending is not allowed/possible.

### Reply 15 by ClariceStarling, 2024-04-20

For this code socketStatus = 0;

```
while (socketStatus != sn)
	{
		socketStatus = socket(sn, Sn_MR_TCP, serverPort, SF_TCP_NODELAY);
	}
	
	while (connectionStatus != SOCK_OK)
	{
		connectionStatus = connect(sn, (uint8_t *)serverIP, serverPort);
	}
						
	while (1)
	{  
		socketStatus = getSn_SR(sn);	
		
		sendStatus = send(sn, sendBuff, 2);
		
		if (sendStatus < 0) 
		{
			LED_On();
		}
		
		Delay_ms(500);
	}
```

### Reply 16 by Eugeny, 2024-04-20

Read about the flow described in the W5100 datasheet.

### Reply 17 by ClariceStarling, 2024-04-20

I use W5500

Did you mean this product? <https://docs.wiznet.io/img/products/w5100/W5100_DS_V128E.pdf>

Which page i can read?

### Reply 18 by Eugeny, 2024-04-20

Chapter 5.

### Reply 19 by ClariceStarling, 2024-04-21

I read the relevant section, but I didn’t fully understand how to proceed. Can you give a hint? ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)

### Reply 20 by ClariceStarling, 2024-04-21

I think problem solved ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
There is a another SPI issue.
I added another line (w5500.c) to READ function and problem solved.

```
uint8_t  WIZCHIP_READ(uint32_t AddrSel)
{
   uint8_t ret;
   uint8_t spi_data[3];

   WIZCHIP_CRITICAL_ENTER();
   WIZCHIP.CS._select();

   AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_);

   if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) 	// byte operation
   {
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
	   WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >>  8);
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >>  0);
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
   }
   else																// burst operation
   {
		spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
		spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
		spi_data[2] = (AddrSel & 0x000000FF) >> 0;
		WIZCHIP.IF.SPI._write_burst(spi_data, 3);
   }
	WIZCHIP.IF.SPI._write_byte(0); // WRITE DUMMY VALUE FOR READ (GENERATE SPI CLOCK)
   ret = WIZCHIP.IF.SPI._read_byte();

   WIZCHIP.CS._deselect();
   WIZCHIP_CRITICAL_EXIT();
   return ret;
}
```

### Reply 21 by ClariceStarling, 2024-04-23 (in reply to reply 20)

I found the solution, but another problem arose and I fixed it too. The problem is that the recv function returns an incorrect value. I could receive as much data as I wanted, but the received data was incorrect. A similar problem exists in the recv function. For this, editing the WIZCHIP_READ function is not enough. Because the recv function uses the WIZCHIP_READ_BUF function instead of WIZCHIP_READ. By editing this, the other problem was also solved.

The whole solution was as follows.

```
uint8_t  WIZCHIP_READ(uint32_t AddrSel)
{
   uint8_t ret;
   uint8_t spi_data[3];

   WIZCHIP_CRITICAL_ENTER();
   WIZCHIP.CS._select();

   AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_);

   if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) 	// byte operation
   {
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
	   WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >>  8);
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >>  0);
		ret = WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
   }
   else																// burst operation
   {
		spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
		spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
		spi_data[2] = (AddrSel & 0x000000FF) >> 0;
		WIZCHIP.IF.SPI._write_burst(spi_data, 3);
   }
	WIZCHIP.IF.SPI._write_byte(0); // WRITE DUMMY VALUE FOR READ (GENERATE SPI CLOCK)
   ret = WIZCHIP.IF.SPI._read_byte();

   WIZCHIP.CS._deselect();
   WIZCHIP_CRITICAL_EXIT();
   return ret;
}

void     WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
{
   uint8_t spi_data[3];
   uint16_t i;

   WIZCHIP_CRITICAL_ENTER();
   WIZCHIP.CS._select();

   AddrSel |= (_W5500_SPI_READ_ | _W5500_SPI_VDM_OP_);

   if(!WIZCHIP.IF.SPI._read_burst || !WIZCHIP.IF.SPI._write_burst) 	// byte operation
   {
		WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x00FF0000) >> 16);
		WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x0000FF00) >>  8);
		WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR
		WIZCHIP.IF.SPI._write_byte((AddrSel & 0x000000FF) >>  0);
		WIZCHIP.IF.SPI._read_byte(); // READ FOR SPI BUFFER CLEAR

		for(i = 0; i < len; i++)
		{
			WIZCHIP.IF.SPI._write_byte(0); // WRITE DUMMY VALUE FOR READ (GENERATE SPI CLOCK)
			pBuf[i] = WIZCHIP.IF.SPI._read_byte();
		}
   }
   else																// burst operation
   {
		spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
		spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
		spi_data[2] = (AddrSel & 0x000000FF) >> 0;
		WIZCHIP.IF.SPI._write_burst(spi_data, 3);
		WIZCHIP.IF.SPI._read_burst(pBuf, len);
   }

   WIZCHIP.CS._deselect();
   WIZCHIP_CRITICAL_EXIT();
}
```

---

Source: https://maker.wiznet.io/forum/15202
