Write / Read in 2 bytes socket registers / W6100, io6Library /

Probably the question is very stupid, but I didn’t find anything, even Google didn’t help.

It’s about the io6Library.

1/ Why, when writing or reading in 2 bytes socket registers, the operation is done byte by byte in two operations?

For example: Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR and similar for TX…

2/Why are they read twice and compared each time?

The only thing I can think of is that they have changed in the meantime. Or is there any other reason?

For example: getSn_RX_RSR()

  1. In case of Sn_RX_RSR, Sn_RX_RD, Sn_RX_WR register, it has the data value of 16bits.
    For example,
    image
    When S0_RX_RD0 and S0_RX_RD1 register read, it indicates 0x06 and 0x00.
    Actually, the reading data of S0_RX_RD is 0x0600.

2.When measuring the data size on the network, it verifies once more for accurate data.

2 - OK

1 - That was my question. Why should we read twice one byte and not read two consecutive bytes, from address Sn_RX_RD0 . In one SPI read, with start address 0x0228, to read 2 bytes. The two bytes will be the same 0x06(first) and 0x00(second). Instead of use WIZCHIP_READ two times, to use WIZCHIP_READ_BUF (for example) with len =2 and AddrSel =0x0228(figuratively speaking, start address.)

You are right and It works if you run it as you say.
You can use the WIZCHIP_READ_BUF function with len = 2.

That is all. Thanks. You may consider this topic complete and close it.

===

I need to convert the library to work with pic32mz. Probably about 80% will have to change. I’m not an ARM specialist, but it did strike me as a weird realization, at least for me.

Another thing that impressed me is that if the speed of the SPI is reduced, the transfer stops working. I don’t know if there is a bug in the processor or a logical error in the code. So at least it’s on the W6100-EVB. Base frequency of SPI is 18MHz (SPI_BaudRatePrescaler_2).

If in spiInitailize () change

SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_2;

to

SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_16 ;

or more, W6100-EVB stop working.

It turns out that the CS pin rises before sending is complete and the last bytes are actually destroyed. As speed is slower, the signal CS rises earlier to incomplete data transmission.
Maybe someone will find it useful while exploring the software and trying to connect logic analyzer.