2020-04-02 04:16 AM
Hey,
i got a specific Problem with the STM32H7 Ethernet, sometimes when performing
SET_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR);
/* Get tick */
tickstart = HAL_GetTick();
/* Wait for software reset */
uint8_t force_reset = 0;
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;
break;
}
}
The error gets detectet, so ETH_DMAMR_SWR doesnt get activated within this timeout period. Is there aother way to reset the ETH Controller except from restarting the whole mcu?
I tried __HAL_RCC_ETH1MAC_FORCE_RESET but it didnt work out.
2020-04-02 05:03 AM
okay much more interesting:
/* Get tick */
tickstart = HAL_GetTick();
/* Wait for software reset */
uint8_t force_reset = 0;
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 */
force_reset = 1;
break;
}
}
tickstart = HAL_GetTick();
if(force_reset)
{
// tickstart = HAL_GetTick();
__HAL_RCC_ETH1MAC_FORCE_RESET();
HAL_Delay(100);
__HAL_RCC_ETH1MAC_RELEASE_RESET();
HAL_Delay(100);
SET_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR);
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;
}
}
}
when optimising AND uncomment the tickstart, the whole programm wont run correctly. Anyone expirienced things like that?
2020-04-02 05:10 AM
there seems something wrong with data alligmnent. cant imagine, it could be something written on the flash. any experiences?
as far as i can tell, usually adding non related code in flash should not interfere with the programs ability to function, which is clearly the case here.
2023-10-27 12:04 AM - edited 2023-10-27 12:05 AM
I have run into the same issue with my STM32H753 MCU(https://community.st.com/t5/stm32-mcus-products/stm32h753-ethernet-initialization-failure/td-p/602033)
Were you able to fix this issue?
2024-10-30 04:34 AM
Same issue here on a H747 DISC0. Same c-code as yesterday, starting my program today and constantly running into this behaviour.
This line of code triggers the Hardfault_Handler()
SET_BIT(heth->Instance->DMAMR, ETH_DMAMR_SWR);
But when debugging I noticed that this function is called already by MX_ETH_Init (I guess so). So the SET_BIT function was called already and is running into the HardFault_Handler, when called the second time.
After commenting out "HAL_ETH_Init(&heth)" in my main.c, I didn't run into the error any more :)
Still wondering why I didn't run into the HardFault_Handler yesterday, when HAL_ETH_Init" was called twice (1x MX Init + 1x main.c)
Hope this will help anyone :)
Cheers