Managing RX buffer pointers
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: Managing RX buffer pointers
by Eugeny ·
Mike,
Please refer to W5100 datasheet wiznet.co.kr/wp-content/uplo … v1.2.6.pdf for detailed explanation of pointer management - starting with Chapter 5 “Functional description”. W5500 is similar to W5100 in design, thus most rules will apply.
You already have register called Sn_RX_RSR, which has the same information you need.
This is correct - to have Sn_RX_RD pointer change you should issue RECV command. Until you do it, RD pointer will read old value.
Even though there’s a window for data - for example 2kB which means relative offset 0-7ff within the socket’s buffer, you should use 16-bit pointers. For example, if Sn_RX_RD is equal to 0x9f76, if you received 0x2e5 bytes, updated pointer you write back is 0xa25b.
Datasheet is clear about it:
Sn_RX_WR (Socket n RX Write Pointer Register) [R] [0x002A-0x002B] [0x0000]
No, 2K is 0x800, thus mask is 0x7ff. Read theory in W5100 datasheet, and you will understand.
RE: Managing RX buffer pointers
by MikiB ·
Thankyou for you response to my question.
I wish I could say everything worked fine, but no change.
This is what I’m doing to set the receive buffer read pointer:
void reset_RXBUFF_PNTRS(){
output_low(SPI_ENABLE);
spi_write(0x00);
spi_write(SOCR_RX_RD0); //0x28
spi_write(SOC0_REG|SPI_CNT_CNT_WR|SPI_OP_MODE1); //0x08|0x04|0x01 or 0x0D
spi_write(SOCK_RX_WR_BF_PNT_MSB); //example 1
spi_write(0x00);
spi_write(SOCR_RX_RD1); //0x29
spi_write(SOC0_REG|SPI_CNT_CNT_WR|SPI_OP_MODE1); //0x08|0x04|0x01 or 0x0D
spi_write(SOCK_RX_WR_BF_PNT_LSB); //example 110
spi_write(SOCK_RX_RD_BF_PNT_MSB); //0
spi_write(SOCK_RX_RD_BF_PNT_LSB); //0
spi_write(SOC0_RX_BF|SPI_CNT_CNT_RD|SPI_OP_MODE1); //0x18|0x00|0x01 or 0x1D
RXDATA_BYTE=spi_read(0); //RECV command
output_high(SPI_ENABLE);
delay_us(10);
}
This is what I do to read the pointers:
void read_sock0_RX_buff_pointer(){
output_low(SPI_ENABLE);
spi_write(0x00);
spi_write(SOCR_RX_RD0); //0x28
spi_write(SOC0_REG|SPI_CNT_CNT_RD|SPI_OP_MODE1); //0x08|0x00|0x01 or 0x09
SOCK_RX_RD_BF_PNT_MSB=spi_read(0);
spi_write(0x00);
spi_write(SOCR_RX_RD1); //0x29
spi_write(SOC0_REG|SPI_CNT_CNT_RD|SPI_OP_MODE1);
SOCK_RX_RD_BF_PNT_LSB=spi_read(0);
output_high(SPI_ENABLE);
SOCK_RX_RD_BF_PNT=(SOCK_RX_RD_BF_PNT_MSB*256); //build 16 bit address from two bytes.
SOCK_RX_RD_BF_PNT=(SOCK_RX_RD_BF_PNT+SOCK_RX_RD_BF_PNT_LSB);
}
Socket 0 receive buffer read pointer stays at zero regardless what I do.
Thanks in advance.
RE: Managing RX buffer pointers
by MikiB ·
Ahah! This is what was meant by a RECV command:
When I finally did it, the Sn_RD_RX buffer pointer finally updated.
Thanks for the help. When you understand the instruction and do it, things work.
Just curious, obviously RECV doesn’t mean receive. What does it mean?
RE: Managing RX buffer pointers
by Eugeny ·
It makes chip send acknowledge for already received data, requesting more data from remote device. I simplify a bit, but you get the idea.
RE: Managing RX buffer pointers
by kejuqeju ·
Hello there…
is there any way to reset the Sn_RX_WR to 0 ? because eventually Sn_RX_WR will exceed the maximum buffer size (default is 2K which is 0x07FF)
i know if i close/disconnect the socket and reconnect it, the pointers will reset to 0, but i don’t want to do that. I want to keep the connection alive. Please give me suggestion.
RE: RE: Managing RX buffer pointers
by Leytronix ·
Hello,
I am running into the exact same problem. Did you find a solution to set Sn_RX_WR to 0?
Kind regards,
Tjerk bij de Leij
RE: Managing RX buffer pointers
by Leytronix ·
Hi Wiznet,
Can you please respond to my question?
Thanks,
Tjerk
RE: Managing RX buffer pointers
by Sandor Banoczy ·
Hello Leytronix
You can set Socket n RX Write Pointer 0x00 only in case if you send OPEN command.
After you handled your interrupts etc., write 0x01 in reg Socket n Command 0x401+(0x0100 x n)
RE: Managing RX buffer pointers
by Leytronix ·
Hi Sandor,
Great, this is exactly I was looking for!! I see after resending the OPEN command the socket is closed for a short time and immediately re-opened after that.
Cheers,
Tjerk
RE: RE: Managing RX buffer pointers
by Leytronix ·
Hi Sandor,
In our application it is not acceptable to close the socket from our side. Isn’t there workaround to clear the Rx write pointer without re-opening the socket?
Thanks,
Tjerk
RE: Managing RX buffer pointers
by kejuqeju ·
Hello Tjerk
i decided not to reset Sn_RX_WR to 0 in order not to change the connection status.
instead i must calculate the size difference between the new pointer and the last pointer to know the size of the received data
it was rather complicated to do it, but it works fine until now.
RE: Managing RX buffer pointers
by Leytronix ·
Hi Keju,
Yes, it is quite a bit of work but I now also finally have it working correctly
Cheers,
Tjerk