Skip to main content
y.rr
Associate II
September 12, 2019
Solved

STM32F767 with KSZ8863 Ethernet PHY and RMII. Clock issue

  • September 12, 2019
  • 1 reply
  • 2555 views

Hello there :)

I'm trying to use a KSZ8863 Ethernet PHY with the STM32F767. I'm using the Nucleo F767ZI Board where i unsoldered the jumpers to the onbord PHY. The KSZ8863 is then connected via the Morpho connectors.

I just used the Code generated by the CubeIDE with rtos and lwip.

By now I can configure the PHY via MIIM (MDIO, MDC) with no issue.

but I have no communikation with the Ethernet.

Looking at the RMII interface via logic-analyzer i can see the 50MHz clock. And the data send from the Phy to the STM32 with corresponding frequency.

But when i look at the Date send from the STM32 to the Phy it looks like the µC sends with a to low frequency. (if im right with 2.5MHz) . So it looks like the STM32 uses a wrong clock.

So far the only thing I could find is that

SYSCFG->PMC |= (SYSCFG_PMC_MII_RMII_SEL);

selects the used interface (and with that the clock?).

(See STM32F767 datasheet page 1776 / 42.4.4)

In the Figure 549 Clock Scheme, there is the Sync. divider. bit i cant find anything more about that.

So what am I missing? I'm stuck..

Some help would be very nice :)

Cheers

    Best answer by y.rr

    ok

    as usual, shortly after asking around I found the issue :)

    The HAL Driver does not detect the speed of the PHY and therefore uses 10M.

    So to solve that in the stm32f7xx_hal_eth.c in line 443 change to 100M

    because the KSZ8863 is a switch and always needs 100M at the RMII to work, one can replace the speed selection in Line 440:

    /* Configure the MAC with the speed fixed by the auto-negotiation process */
     if((phyreg & PHY_SPEED_STATUS) == PHY_SPEED_STATUS)
     { 
     /* Set Ethernet speed to 10M following the auto-negotiation */
     (heth->Init).Speed = ETH_SPEED_100M;
     }
     else
     { 
     /* Set Ethernet speed to 100M following the auto-negotiation */ 
     (heth->Init).Speed = ETH_SPEED_100M;
     }

    with simply

    /* Set Ethernet speed to 100M following the auto-negotiation */ 
     (heth->Init).Speed = ETH_SPEED_100M;

    So my question is answerd and maybe it will help others solving it :)

    Cheers

    1 reply

    y.rr
    y.rrAuthorBest answer
    Associate II
    September 12, 2019

    ok

    as usual, shortly after asking around I found the issue :)

    The HAL Driver does not detect the speed of the PHY and therefore uses 10M.

    So to solve that in the stm32f7xx_hal_eth.c in line 443 change to 100M

    because the KSZ8863 is a switch and always needs 100M at the RMII to work, one can replace the speed selection in Line 440:

    /* Configure the MAC with the speed fixed by the auto-negotiation process */
     if((phyreg & PHY_SPEED_STATUS) == PHY_SPEED_STATUS)
     { 
     /* Set Ethernet speed to 10M following the auto-negotiation */
     (heth->Init).Speed = ETH_SPEED_100M;
     }
     else
     { 
     /* Set Ethernet speed to 100M following the auto-negotiation */ 
     (heth->Init).Speed = ETH_SPEED_100M;
     }

    with simply

    /* Set Ethernet speed to 100M following the auto-negotiation */ 
     (heth->Init).Speed = ETH_SPEED_100M;

    So my question is answerd and maybe it will help others solving it :)

    Cheers

    Associate
    January 15, 2025

    KSZ8863 has two PHYs, but when I initialize Eternet, do I have to enter the setting value as MDIO in the PHY register for both?

    We are currently working on the project with Stm32f207VET6 and KSZ8863, and we have enabled Full-Duplex, Auto-Nego, and 100BaseTX with hardware pin strapping, which can communicate on both sides of the RJ45 Port, but not on the STM32 side through the port from outside.