Autonegotiation fails after sometime Using LAN8742 Ethernet PHY & STM32F429ZI.
Hi everyone, I'm using STM32F429ZI with LAN8742A PHY. Once I start the MCU Ethernet communication works properly, After sometime netif link goes down and ping stops.
Only when I resets the MCU communication starts.
After debugging further it is observed that, Whenever link status updates it goes into ethernetif_Update_config callback function. But autonegotiation processes not completing there and goes into error.(refer below code.)
void ethernetif_update_config(struct netif *netif)
{
__IO uint32_t tickstart = 0;
uint32_t regvalue = 0;
if(netif_is_link_up(netif))
{
/* Restart the auto-negotiation */
if(heth.Init.AutoNegotiation != ETH_AUTONEGOTIATION_DISABLE)
{
/* Enable Auto-Negotiation */
HAL_ETH_WritePHYRegister(&heth, PHY_BCR, PHY_AUTONEGOTIATION);
/* Get tick */
tickstart = HAL_GetTick();
/* Wait until the auto-negotiation will be completed */
do
{
HAL_ETH_ReadPHYRegister(&heth, PHY_BSR, ®value);
/* Check for the Timeout ( 1s ) */
if((HAL_GetTick() - tickstart ) > 5000)
{
/* In case of timeout */
goto error;
}
} while (((regvalue & PHY_AUTONEGO_COMPLETE) != PHY_AUTONEGO_COMPLETE));
Any suggestions to avoid Autonegotiation timeout in this callback?
