墙上的流光 发表于 2021-9-10 17:07:24

gd32的初始化问题

ErrStatus enet_software_reset(void)
{
    uint32_t timeout = 0U;
    ErrStatus enet_state = ERROR;
    uint32_t dma_flag;
   
                uint32_t test_reg1, test_reg2;
   
    /* reset all core internal registers located in CLK_TX and CLK_RX */
      test_reg1 = ENET_DMA_BCTL_SWR;
      test_reg2 = ENET_DMA_BCTL;
    ENET_DMA_BCTL |= ENET_DMA_BCTL_SWR;
    test_reg2= ENET_DMA_BCTL;
    /* wait for reset operation complete */
    do{
      dma_flag = (ENET_DMA_BCTL & ENET_DMA_BCTL_SWR);
      timeout++;
    }while((RESET != dma_flag) && (ENET_DELAY_TO != timeout));

    /* reset operation complete */   
    if(RESET == (ENET_DMA_BCTL & ENET_DMA_BCTL_SWR)){
      enet_state = SUCCESS;
    }
      
    return enet_state;
}
ENET_DMA_BCTL_SWR寄存器总是为不能清0,导致初始化不成功。

魏伟 发表于 2021-9-11 00:20:06

wangy2000 发表于 2021-9-11 07:57:47

mj8abcd 发表于 2021-9-11 16:45:15

页: [1]
查看完整版本: gd32的初始化问题