WIZnet Developer Forum

Receive Buffer Management for w5500 and w5200

Hello;

I have both w5500 and w5200 chipset. I’m transferring data over the UDP protocol. Receive buffers were normally defined as 2048 bytes in the library. How can I reduce the buffer because I want to work in real time. Could you help?

See Section 3.3 of the manual, on page 32 for detailed information about setting Tx and Rx buffer sizes for each socket. But you don’t need to adjust buffer sizes to process data in real time; you can detect the presence of data in a socket’s Rx buffer and read anything from a single byte to the entire buffer contents regardless of buffer size.

If you are using WIZnet’s ioLibrary, the buffer size is initialized through ctlwizchip().

uint8_t memsize[2][8] = { { 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2 } };

	if (ctlwizchip(CW_INIT_WIZCHIP, (void*) memsize) == -1) {
		printf("WIZCHIP Initialized fail.\r\n");
		while (1);
	}

Thanks for your answer.

I am listening to messages in a certain period. When the connection level gets worse during wireless communication, the buffer becomes full when I cannot read. So it can’t work in real time. I think that if I reduce the rx buffer size of the card I will overcome the problem.

I am using the arduino library. I try to reduce buffer sharing by increasing the number of sockets, but the card does not receive data. The definition of buffer in the library is as follows.

//
#define TX_RX_MAX_BUF_SIZE 2048
#define TX_BUF 0x1100
#define RX_BUF (TX_BUF + TX_RX_MAX_BUF_SIZE)

#define TXBUF_BASE 0x8000
#define RXBUF_BASE 0xC000

writeMR(1<<RST);

for (int i=0; i<MAX_SOCK_NUM; i++) {
write((0x4000 + i * 0x100 + 0x001F), 2);
write((0x4000 + i * 0x100 + 0x001E), 2);
}
for (int i=0; i<MAX_SOCK_NUM; i++) {
SBASE[i] = TXBUF_BASE + SSIZE * i;
RBASE[i] = RXBUF_BASE + RSIZE * i;
}
}
//

//
private:
static const uint8_t RST = 7; // Reset BIT
static const int SOCKETS = 8;
static const uint16_t SMASK = 0x07FF; // Tx buffer MASK
static const uint16_t RMASK = 0x07FF; // Rx buffer MASK
public:
static const uint16_t SSIZE = 2048; // Max Tx buffer size
private:
static const uint16_t RSIZE = 2048; // Max Rx buffer size
uint16_t SBASE[SOCKETS]; // Tx buffer base address
uint16_t RBASE[SOCKETS]; // Rx buffer base address
//

If your system is receiving data from some source that’s producing it faster than you can process it, making your receive buffer smaller will make your problem worse rather than better. You can think of the receive buffer as a handy place to keep data until your software gets around to reading it into memory and processing it. Making the receive buffer smaller will back up the sender and delay making data available to your code. It won’t slow down the rate at which data is created.

If you describe the application you’re implementing in more detail, including how data is generated and delivered to your system I may be able to help more. I don’t understand your comment about wireless data, since both W5500 and W5200 support wired Ethernet.

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