W5500 - Need help with UDP Rx buffer pointer wrap-around
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: W5500 - Need help with UDP Rx buffer pointer wrap-around
by Eugeny ·
Take a look into W5100 datasheet pages 44-45. You must use all 16 bits of the pointer to update RX_RD, while for actual data pointing you must use window-masked pointer.
RE: RE: W5500 - Need help with UDP Rx buffer pointer wrap-around
by Wizboy ·
Thanks Eugeny. I took out my wrap-around logic and implemented the 2K mask (0x07FF) on the offset address when reading as you suggested and it works now :).
A question about the purpose of Sn_RX_WR: can/should the value of this register be used to calculate the new Sn_RX_RD pointer instead of adding the received packet length (e.g., rx_ptr = getSn_RX_WR())? I’m not sure of the value of doing this, but just wondering what Sn_RX_WR is for.
Here is the updated pseudocode:
rx_len = getSn_RX_RSR() // get packet, returns when non-zero rx_len
rx_ptr = getSn_RX_RD() // get Rx pointer
rx_ptr_masked = rx_ptr & 0x07FF // mask assumes 2K RX buffer
buffer = readData(rx_ptr_masked, rx_len) // read data at masked pointer address
rx_ptr += rx_len // calculate new pointer value. Or…could use rx_ptr = getSn_RX_WR()?
setSn_RX_RD(rx_ptr) // update pointer
setRECV() // notify receive complete
RE: W5500 - Need help with UDP Rx buffer pointer wrap-around
by Eugeny ·
No. RX_WR is being used by the chip internally, and can change in any moment, and the value you read may be just invalid (because value in register may change between reads of two bytes). You must do exactly as described in the datasheet, even if it looks not the easiest way to proceed.