我用stm32f407vet6+LAN8720A调试以太网遇到软件复位失败问题,单步调试发现在复位MAC内部寄存器时对以太网总线模式寄存器(ETN_DMABMR)软件复位SR位置1后,硬件未自动清除该位,导致软件,导致代码进入while死循环。
这问题在用官网代码上也复位不成功。代码如下:
/* 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 */
(heth->Instance)->DMABMR |= ETH_DMABMR_SR;
/* Get tick */
tickstart = HAL_GetTick();
/* Wait for software reset */
while (((heth->Instance)->DMABMR & ETH_DMABMR_SR) != (uint32_t)RESET)
{
/* Check for the Timeout */
if((HAL_GetTick() - tickstart ) > ETH_TIMEOUT_SWRESET)
{
heth->State= HAL_ETH_STATE_TIMEOUT;
/* Process Unlocked */
__HAL_UNLOCK(heth);
/* Note: The SWR is not performed if the ETH_RX_CLK or the ETH_TX_CLK are
not available, please check your external PHY or the IO configuration */
return HAL_TIMEOUT;
}
}
这是我REFCLK引脚的频率图
更多回帖