W5100 Sn_TX_WR

Hi,

First thing - I’m not ‘normal’, I program in Forth.

I’m using Arduino UNO with W5100 Shield.

I’ve researched extensively about the TX pointers and think I fully understand what is required to send data. Basically fetch the current tx_wr pointer, and with $7ff and add the base address ($4000 for s0) - gives the the start address in the chip for writing to the tx buffer. When done, get the original tx_wr pointer, add the size of data to it, and write it back. Then do a send.

Also that the tx pointers get set to apparently random numbers every time the socket is established.

What I’ve found is that when these random numbers exceed 32767 (i.e. become -ve in terms of 16bit signed) then the data actually transmitted isn’t what I’ve written to the buffer and I guess is uninitialised data from anywhere in the chip, and lots of it.

If I write back the tx_wp with top bit AND’ed off, then 1st send is rubbish - but subsequent is all good.

I note that the memory map of the chip is only drawn up to $8000 in the datasheet, and wonder if that’s significant.

Appears to work OK when pointers are (randomly) initialised below $8000

I hope I’m not being thick … If tx_wr reads as (say) $A000 before I write 3 bytes…

3 Bytes go in starting at address (($A123 AND $7FF) + $4000) (Socket 0) … i.e. $4123

tx_wp gets written to $A123

Do a SEND.

tx_rd then catches-up with tx_wr but I get all the junk being sent.

Has anyone else experienced similar?

SOLVED !!

Reason … Back on AVR after months on ARM … Signed maths on 16 bit caught me out — thinking I was on 32bit and it was OK to divide (say) 50,000 by 256 and get the high byte as a result !!

Oh well !

Hi,
I’m glad for you to solve the problem.