Manual Link Speed: wrong duplex mode, long establishment

I have multiple problems related to link speed with W5500.

  1. The displayed link speed is wrong. PHYCFG register e.g. reads value 205. This means the link speed is 10M and Full Duplex. The TPLink switch that the device is connected to, reports 10M Half Duplex, though.
  2. The link (DHCP etc.) takes too long to establish - more than 10 seconds. It only takes that long if I do PHY configuration via software. The PMODE pins are set to auto negotiate, all capable. If I leave it up to PMODE, then the link is established in a few seconds.

My dampening resistors are all 3 Ohm.

If I do a PHY software configuration with Auto-Negotiate, then:

  • PHYCFGR reads 255. Means: 100M, Full Duplex
  • TPLink Switch also shows 100M, Full Duplex
  • Link is established fast. About 10 seconds faster for DHCP + a local TCP connection to be established than the manual link speed setting.

I suspect that the manual 10M link speed somehow has severe troubles, and that after a timeout the link is re-established with different settings.
On the switch side, all ports are set to Auto.

If I set the switch to force 10M Full Duplex, and the W5500 to auto-negotiate, then:

  • the switch displays 10M Full Duplex
  • W5500 shows 10M Half Duplex (phyCFGR = 249)
  • Link establishment takes almost 20s

I have a different board where PMODE is set as follows:
PMODE0 is connected to 3V3 and
PMODE1/PMODE2 are connected to GND
(10M Full Duplex)

Interestingly this board, most of the time, starts up quickly (<5 seconds).
It shows a 10M Full Duplex connection (PHYCFGR = 189) while the switch is displaying a 10M Half Duplex connection.

So it seems that when link speed settings are done by PMODE hardware pins (only), this lag and the communication errors are not there. But when done by software, there is a big lag.

P.S.: Sometimes the RxBadPkt count goes up on the switch.

First, you assume that switch you use is innocent and can’t bring problems. This may not hold true. Under Windows or Linux you may not notice such problems because they hide what they do under the hood, and we may not know what they actually do to remedy situation. Contrary, W5x00 are simple and will do most things you ask them to do.

Second, I would suggest disable PHY, set necessary flags, and then reenable PHY as a test, ensuring delay (e.g. 1 second) for every stage. This will physically show the switch/router the disconnect of the endpoint and may alter its behavior.

Third, replace the cable, try different switch’s port and try different switch to get more insight into what may be possible within your setup. And yes, bad cables sometimes may give very strange problems.

Trying to force 10M Full Duplex from the W5500’s side, I tried

  • different cables
  • different W5500 devices
  • 1 8Port TPLink switch, 1 TPLink Router Archer C7 v5

The result is always the same: that the Router/Switch shows 10M Half, the W5500 shows 10M Full Duplex.

The only thing I haven’t tried from your suggestions, is to disable the PHY, configure it, and reenable it again. I will try that too, although I do not think it will fix the issue, because as I mentioned I have a device with PMODE pins set, where I don’t even alter the PHY configuration. Even that device shows the same behaviour: mismatch on duplex mode.

Another test: connect W5500 to the PC, connect PC with its another port (e.g. WiFi) to router, set PC into bridge mode (so that W5500 can see the router), and see that is going on the network using PC as well as properties of the connection.

What module do you use, is there a circuit diagram/board layout?

It’s a custom board.
The dampening resistors are 3 Ohms, not 3.3 as in the circuit diagram.

Yesterday I was able to get rid of the time lag problem at startup, the sequence used is basically:

  1. wait for PHY to be ready (link = on)
  2. configure link speed by software (C library will do a PHY reset…)
  3. wait for PHY to be ready (link = on) + 200ms
  4. configure PHY power down (C library will do a PHY reset…)
  5. wait 100ms (or until link = off, haven’t tried this…)
  6. do manual PHY link speed configuration: 10M, full duplex
  7. same as 3.

But it does not fix the duplex mismatch issue.

3 Ohm resistors must not make any difference. Anyway you can always replace then with jumpers.
Do not forget about proper hardware reset timing and software reset handling.
In your workflow not sure what steps 4-7 are for. 1-3 should be enough?

If I do not power down PHY, there is a big time lag.
And the Wiznet library is written in such a way, that powerdown checks first if PHY link speed is set by software…so I first need to set linkspeed, even if I plan to power down after that…

I shortened it a bit now by not using the library function for powering down PHY.
But all of this does not fix duplex mismatch. Regardless of what I do there is always a mismatch in the duplex setting.

I have an answer to the observed duplex mismatch behaviour now.

The answer B is correct, when auto-negotiation is turned off on one end, the other end cannot detect the correct duplex mode because there is not way to be able to do that. Please remember that when a switch port does not sense any auto-negotiation from the other end port, it would default to half-duplex when operating on 10/100 ports, and I think that what happend when you hardcoded the duplex on N4 port, N8 port defaulted to half-duplex due to the lack of auto-negotiation. There is an exception to that on Catalyst switches when operates on gigaethernet ports, since those switches support only full-duplex on gigaethernet ports, the port would default always to full-duplex.

So basically: when auto negotiation is turned off (which you must do with W5500 to force 10M), then the switch will always fall back to Half Duplex.
Also described in Autonegotiation – Wikipedia

Falls sich eine Gegenstelle nicht im Autonegotiation-Modus befindet (abgeschaltet oder nicht unterstützt), kann die andere Gegenstelle die Übertragungsgeschwindigkeit über Parallel Detection ermitteln. Eine Bestimmung des Duplex-Modus ist dabei nicht möglich; somit wird stets der Halb-Duplex Modus ausgewählt. Die Gegenstelle ohne Autonegotiation muss in diesem Fall fest auf Halb-Duplex eingestellt werden, andernfalls ist das Ergebnis ein duplex mismatch (eine Seite Voll-Duplex, die andere Seite Halb-Duplex). Typische Auswirkung hiervon ist eine zwar funktionierende, jedoch sehr langsame Verbindung.

Also described here: PHY Link Configuration

So what’s the solution?

  1. Either configure both switch and W5500 to the same settings without auto-negotiation: 10M Full in my case
  2. Or set the W5500 to 10M Half, and let the switch detect the link speed and fall back to Half Duplex. Then no settings need to be done on the switch.