Skip to main content
Graduate
November 27, 2023
Solved

Init Ethernet on STM32H7 error

  • November 27, 2023
  • 4 replies
  • 2253 views

Hi, I'm trying to create my first project with ethernet on STM32H7. I tried to give an example with a nulceo with a similar chip and I succeeded, now I'm moving on to my custom board.

I configured the system with STM32CubeIDE, generated the code and just tried to launch the program, what happens is that during initialization, at this point:

 

 /* Dummy read to sync with ETH */
 (void)SYSCFG->PMCR;

 /* Ethernet Software reset */
 /* Set the SWR bit: resets all MAC subsystem internal registers and logic */
 /* After reset all the registers holds their respective reset values */
 SET_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR);

 /* Get tick */
 tickstart = HAL_GetTick();

 /* Wait for software reset */
 while (READ_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR) > 0U)
 {
 if (((HAL_GetTick() - tickstart) > ETH_SWRESET_TIMEOUT))
 {
 /* Set Error Code */
 heth->ErrorCode = HAL_ETH_ERROR_TIMEOUT;
 /* Set State as Error */
 heth->gState = HAL_ETH_STATE_ERROR;
 /* Return Error */
 return HAL_ERROR;
 }
 }

 

I get the return HAL_ERROR; error and the program stops.
Can you help me understand where the problem is?
I attach the ioc file that I used to generate the code, if you think the problem may be in the hardware part, I can also send the electrical diagram and layout.

Thanks in advance.

IOC File: https://drive.google.com/file/d/1BTQGlH5RxBeBbijaUmBP7SGDBpZXNBO-/view?usp=drive_link

    This topic has been closed for replies.
    Best answer by FMass.1

    I think I've found the problem. The problem was the Ethernet connector I was using, basically the connector has LEDs that can be used in both polarities:

    FMass1_0-1701354061560.png

    And this was going to disturb the polarization of pin 2, and consequently the clock was not arriving well at the PHY. After changing the connector, the LEDs light up well, I no longer have the initial error.

    4 replies

    Technical Moderator
    November 28, 2023
    FMass.1Author
    Graduate
    November 28, 2023

    Yes, I read this page and other similar ones, but they didn't help me.

    FMass.1AuthorAnswer
    Graduate
    November 30, 2023

    I think I've found the problem. The problem was the Ethernet connector I was using, basically the connector has LEDs that can be used in both polarities:

    FMass1_0-1701354061560.png

    And this was going to disturb the polarization of pin 2, and consequently the clock was not arriving well at the PHY. After changing the connector, the LEDs light up well, I no longer have the initial error.