ksz9021RN Unable to Auto-negotiate - Page 1
Forum section: electronics / general

author: tilblackout
author_rank: Contributor
timestamp: October 27, 2023, 08:37:20 am
content: Recently, I've been debugging the Gigabit Ethernet chip KSZ9021RN on the NXP I.MX RT1176 platform. Most of its examples are based on Linux. I've consulted some code from Linux platforms and performed some register initialization for the KSZ9021.However, the KSZ9021 chip always fails to auto-negotiate properly.data sheet of KSZ9021RN:https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/KSZ9021RL-RN-Data-Sheet-DS00003050A.pdfthe schematic is as shown below:HY602401E is a transformer circuit.And R94,R96,R98,R100 are not populated.I have now successfully read the chip's ID (0x22) from register 0x02. Does this mean there are no hardware issues?My initialization process is as follows:1.Successfully read the correct chip ID from register 0x02.2.Software PHY reset: Set bit 15 of register 0x00.3.Set RGMII RX/TX Data Pad Skew:(1) Write register 0x0B as 0x8105, write register 0x0C as 0.(2) Write register 0x0B as 0x8104, write register 0x0C as 0xa0d0.(I am unsure how these skew values should be set and whether they may affect auto-negotiation.)4.Read register 0x1B (Interrupt Control/Status) to clear interrupts.5.Set bit 8 (enable link up interrupt) and bit 10 (enable link down interrupt) of register 0x1B to 1.6.Set bit 14 of register 0x1F to 0 (interrupt pin active low).7.Set bits 5 to 8 of register 0x04 to 1 (10/100M full/half duplex capable).8.Set bit 9 (Restart auto-negotiation process) of register 0x00 to 1 and bit 12 (Auto-Negotiation Enable) to 1.After initializing these registers, I am waiting for bit 2 (Link Status) in register 0x01 to become 'link up.' I have connected an Ethernet cable to the computer on the hardware side, but the value of this register always remains at 0x7949, and the LEDs on both sides of the RJ45 connector do not light up.I would like to know if I have missed any steps, and how I can troubleshoot the issue, whether it's related to software or hardware.I would greatly appreciate your response.------updateIf I turn off the auto negotiation option (the default speed parameter is 10Mbps), the connection can be established normally. However, if I manually set the speed to 100M or 1000M, the connection still cannot be established normally.Does this mean there is a hardware problem? Is it due to an inaccurate crystal oscillator or an inaccurate timing?

author: ataradov
author_rank: Super Contributor
timestamp: October 27, 2023, 03:54:34 pm
content: I'm not familiar with this device specifically, but in the step 8, why are you setting PHY reset? I think it would take priority over the rest of the bit.Usual AN process includes setting Auto-Negotiation Enable (bit 12) and Restart Auto-Negotiation (bit 9).

author: Scrts
author_rank: Frequent Contributor
timestamp: October 30, 2023, 01:21:12 am
content: How are VDD_3V3 and VCC_3V3 connected? Together?I also had problems using MEMS oscillator for this chip. Just use a regular oscillator.Does your power supply provide enough power on both 3.3V and 1.2V rails when negotiation happens?Double check your magnetics wiring and the magnetics itself. It has to be current based, not voltage based.

author: tilblackout
author_rank: Contributor
timestamp: October 30, 2023, 02:15:10 am
content: Quote from: ataradov on October 27, 2023, 03:54:34 pmSorry, I made a mistake. In step 8, I set bit9 and bit12.But it doesn't work.

author: ataradov
author_rank: Super Contributor
timestamp: October 30, 2023, 02:25:16 am
content: Check that the clock is running (although I think it is necessary for registers to work) and also check all the voltages.After that check is there is any activity on the Ethernet connector.

author: tilblackout
author_rank: Contributor
timestamp: October 30, 2023, 02:31:54 am
content: Quote from: Scrts on October 30, 2023, 01:21:12 amYes,VDD_3V3 and VCC_3V3 are connected.But I can read the ID of the chip normally. Can this prove that it's not a problem with the crystal oscillator?Thanks,I'll check that.HY602401E is a transformer circuit.And R94,R96,R98,R100 are not populated.I didn't connect the network cable, and measured the voltage of pins 1/4/7/10. The voltage of 1 and 4 is 1V6, but the voltage of 7 and 10 is 3V3. Is it related to the correct enabling of the gigabit network on the chip?Or it's a hardware issue.

author: tilblackout
author_rank: Contributor
timestamp: October 30, 2023, 07:52:31 am
content: Quote from: ataradov on October 30, 2023, 02:25:16 amIf I turn off the auto negotiation option (the default speed parameter is 10Mbps), the connection can be established normally. However, if I manually set the speed to 100M or 1000M, the connection still cannot be established normally.Does this mean there is a hardware problem? Is it due to an inaccurate crystal oscillator or an inaccurate timing?

author: ataradov
author_rank: Super Contributor
timestamp: October 30, 2023, 03:07:32 pm
content: Then it is likely that something is wrong with the routing or signal integrity. I would start looking at the signals with a scope and double checking that transformers are used correctly.You can measure the crystal and confirm if it is accurate or not. It is an easy test.

author: Scrts
author_rank: Frequent Contributor
timestamp: November 01, 2023, 08:00:22 pm
content: Quote from: tilblackout on October 30, 2023, 02:31:54 amI remember the PHY worked fine for 100/10Mbps with MEMS oscillator, so was communicating to the microcontroller as well, but failed to negotiate for 1Gbps. It fixed once reworked to a regular crystal osc.

author: tilblackout
author_rank: Contributor
timestamp: November 02, 2023, 09:20:33 am
content: Quote from: Scrts on November 01, 2023, 08:00:22 pmI use a passive crystal oscillator.Does it matter?But I can't establish a normal connection at 100M now.

author: Scrts
author_rank: Frequent Contributor
timestamp: November 02, 2023, 03:25:27 pm
content: Quote from: tilblackout on October 30, 2023, 02:31:54 amWhy? Did you try to populate them? The magnetics have to be pre-biased.

author: nctnico
author_rank: Super Contributor
timestamp: November 02, 2023, 03:33:29 pm
content: Quote from: Scrts on November 02, 2023, 03:25:27 pmAgreed. Those resistors need to be in there. The outputs of the ethernet phy are likely current sinking open collector outputs which won't work without the transformer being biased properly.

author: tilblackout
author_rank: Contributor
timestamp: November 06, 2023, 06:31:00 am
content: Quote from: nctnico on November 02, 2023, 03:33:29 pmThe reason why I didn't populate these resistors is that the schematic recommended by the KSZ9021 official does not include these resistors, which may be related to the KSZ9021 chip. And the same KSZ9021 circuit has been successfully run on another product using a Linux chip. I don't know why it doesn't work on the MCU. Just now I tried to populate these four resistors, but it seems to have no effect, it only supports 10Mbps.

author: Scrts
author_rank: Frequent Contributor
timestamp: November 06, 2023, 08:16:00 pm
content: What exact crystal did you use? Can you drop a part number?Also, please be sure that you're not using KSZ9031 by accident.

author: tilblackout
author_rank: Contributor
timestamp: November 08, 2023, 06:25:11 am
content: Quote from: Scrts on November 06, 2023, 08:16:00 pmI just saw the chip on the board, and I'm sure I'm using the KSZ9021.The cystal is DSX321G,https://scanti.com/images/products/kds/DSX321G.pdf

author: tilblackout
author_rank: Contributor
timestamp: November 08, 2023, 06:59:48 am
content: I have previously tested using network cables connected from a switch, and only succeeded in connecting when manually setting the speed to 10Mbps. Today, I tested a network cable directly connected to my computer, and was able to negotiate 10Mbps under automatic negotiation. If I manually set the speed to 100M/1000M, it was also recognized as 10Mbps after a few seconds.-----------------After communicating with Microchip's technical support, it was determined that there was a hardware issue, and they asked me to test the signal integrity first. I'm not sure if it's related to the POE power supply I'm using here.

author: tilblackout
author_rank: Contributor
timestamp: November 13, 2023, 09:40:17 am
content: The issue seems to be located, and the waveform of RX+ is as follows, but it is expected to be a square wave. Which part of the hardware may be faulty?

author: nctnico
author_rank: Super Contributor
timestamp: November 13, 2023, 09:48:05 am
content: This looks more like an auto negotiation pulse.Did you check the signals on the crystal? You should see a sine wave on the pins.Can you share your schematic instead of the one from the eval board?

author: tilblackout
author_rank: Contributor
timestamp: November 14, 2023, 07:18:52 am
content: Thank you for your help. I have successfully connected to the gigabit network by reducing the ripple of the power supply.