Weird SPI Behaviour with the W5500 and STM32
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: Weird SPI Behaviour with the W5500 and STM32
by hzrnbgy ·
Should this be 8 bits?
and 40 Mbps on the SPI is too much for the W5500, try making it work at 8 MHz for now
RE: RE: Weird SPI Behaviour with the W5500 and STM32
by TSWiznet ·
You are right, this was legacy. My apologies. I have adjusted my question.
I lowered the baudrate and adjusted to 8 bit size. Still no improvement.
RE: Weird SPI Behaviour with the W5500 and STM32
by TSWiznet ·
I have managed to restructure my code, according to other very old posts i found that the order in which initilaizers are called matters. I have now made the following which works with ping.
RE: Weird SPI Behaviour with the W5500 and STM32
by hzrnbgy ·
I have been working on writing a driver for the W5500 specifically for the STM32F4 that I have. There are some nuisances I discovered that has caused me a lot of wasted time troubleshooting the issue. One of them is the clock speed of the MCU. Anything above 32 MHz CPU causes some corruption on received data from the W5500. I can make it work at 168MHz with 21MHz SPI but it’s not stable and would have data corruption after tens of thousands of packets transmitted and received. Enabling the Instruction and Data Cache (DCACHE and ICACHE) feature of the STM32 also causes issue with SPI communication. Tried adding delay between Slave_Select activation and SPI byte sends doesn’t help either. Even running the CPU at 168MHz and SPI at 1MHz or below don’t work either so I’m not sure what the problem is.
Currently, I have it running at 32MHz CPU and 16MHz SPI with no DCACHE, ICACHE enabled and been able to TX and RX 2.2 million packets of about 3.2 GBytes of data with zero data corruption from the Linux client so far (1.3 Mbps TX/RX)
Just some things to keep in mind when working with the STM32 and W5500 combo.
RE: Weird SPI Behaviour with the W5500 and STM32
by Eugeny ·
My educated and experienced guess says the problem lies in the SPI relative signal timing (hold/setup timing violations).
RE: Weird SPI Behaviour with the W5500 and STM32
by hzrnbgy ·
That’s what I thought too so I tried adding delays between SPI byte operations
I have tried something like this
The datasheet specifies like 3 or 5 ns minimum for most of these “delays”
The thing that I found out is, if the SPI is not working, i received the byte sequence from the SPI_RECV at
0x00, 0x01, 0x02, 0x03
instead of
0x01, 0x02, 0x03, 0x04
So when I’m reading the VERSION register, I get a 0x03 instead of 0x04
RE: Weird SPI Behaviour with the W5500 and STM32
by Eugeny ·
The evil could be in SPI_send and SPI_read - in delays between toggling and reading signals relative to each other. I can’t say more because do not know how they are implemented in your platform.
Which datasheet? 5 ns is 200 MHz, and sounds to be insane for W5500 SPI communication.
RE: Weird SPI Behaviour with the W5500 and STM32
by hzrnbgy ·
I was talking about section 5.5.4 “SPI TIMING” of the Wiznet W5500 V1.1.0 ref guide
I’m using basic baremetal implementation of the SPI peripheral for my STM32F4
This works at anything below 32MHz CPU and upto max SPI of 16MHz. Anything above 32 MHz CPU, I have to put in short delays between byte transfers, and even that is unreliable so I’m not quite sure what else can be done.
RE: Weird SPI Behaviour with the W5500 and STM32
by Eugeny ·
These values are minimal when you connnect your MCU’s input directly to W5500 die-to-die. In reality you have transmission line subject to capacitance and inductance, which will make these times longer. Consider 2x derating for these times if you make hardware right.
Take scope to see what is going on in the SPI bus. Better multi-channel scope to see the relative positioning of the waveforms. The next steps will depend on what you see. Digging into the features of the MCU SPI implementation may be a good idea to see what you can tune (if it is possible at all). You may also search MCU forum or ask question there. It may appear problem is not purely W5500-related.