W5500 TX Write Pointer calculation


I have a W5500 configured as a server and the PC is the client. I am having some problems with sending data over tcp and I want to make sure that I compute the Write Pointer properly. Since the Datasheet for the W5500 isn’t so explicit, I took the W5200 Datasheet and tried to set the Write Poiner. The code is the following:

// Socket 0 is used
uint32_t ptr      = getSn_TX_WR(socket_number);
uint32_t dst_mask = ptr & get_TxMASK(socket_number);     // get_TxMASK(0) returns 0x1FFF
uint32_t dst_ptr  = get_TxBASE(socket_number) + dst_mask;// get_TxBASE(0) returns 0x8000

Is this the right way to compute the destination pointer(dst_ptr) or am I doing something wrong ?

Thank you !

hello, flonas

W5500 has different memory structure from W5200.

please refer the ioLibrary for W5xxx.

You can check the W5500 memory access.

// refer W5500  memory map
#define WIZCHIP_TXBUF_BLOCK(n) (2+4*n)
// calculate physical memory address and 'addrsel' is for spi interface address and control phase
uint16_t ptr = (WIZCHIP_READ(Sn_TX_WR(n)) >> 8) + WIZCHIP_READ(Sn_TX_WR(n)+1) ;
uint32_t addrsel = ((uint32_t)ptr << 8) + (WIZCHIP_TXBUF_BLOCK(n) << 3);

// copy data to tx memory
WIZCHIP_WRITE_BUF(addrsel, data, len);

// increase sn_tx_wr
ptr += len;

// send command

// send command done

Thank you