1
\$\begingroup\$

I used a modified code from an example for SPI communication "spiloopback" from Texas Instruments, where I tried to write data in the registers of W5500 and then read those data.

enter image description here

uint8_t masterRxBuffer1[SPI_MSG_LENGTH];
uint8_t masterTxBuffer1[SPI_MSG_LENGTH] = {0x00, 0x26, 0x14, 0xFF, 0xFF, 0xFF, 0x00,0x00};
uint8_t masterRxBuffer2[SPI_MSG_LENGTH];
uint8_t masterTxBuffer2[SPI_MSG_LENGTH] = {0x00, 0x26, 0x16, 0x00, 0x00, 0x00, 0x00,0x00};
uint8_t slaveRxBuffer1[SPI_MSG_LENGTH];
uint8_t slaveTxBuffer1[SPI_MSG_LENGTH];
uint8_t slaveRxBuffer2[SPI_MSG_LENGTH];
uint8_t slaveTxBuffer2[SPI_MSG_LENGTH];

Block Select Bits = 00010
MODE = 00
Offset Address = 0x0026
Written data = 3 x 0xFF

In the oscilloscope:

  • 1st signal = clock
  • 2nd signal = MOSI
  • 3rd signal = CS/SS
  • 4th signal = MISO

It worked somewhat but it was very inconsistent, by that I mean that every time I reset the board I get a different read and I don't know why.

enter image description here

enter image description here

enter image description here

W5500 datasheet

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The Read command doesn't seem to correspond with the write command.

enter image description here

Write Command: 0x14

  • BSB[4:0] = 00010 (Selects Socket 0 TX Buffer)
  • RWB = 1 (Write)
  • OM[1:0] = 00 (Variable Data Length Mode, N-Bytes Data Phase (1 ≤ N))

Read Command: 0x16

  • BSB[4:0] = 00010 (Selects Socket 0 TX Buffer)
  • RWB = 1 (Write)
  • OM[1:0] = 10 (Fixed Data Length Mode , 2 Byte Data Length (N = 2))

I imagine the correct Read Command to be: 0x10

  • BSB[4:0] = 00010 (Selects Socket 0 TX Buffer)
  • RWB = 0 (Read)
  • OM[1:0] = 00 (Variable Data Length Mode, N-Bytes Data Phase (1 ≤ N))*

Image taken from the Datasheet.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.