HPM6360 RMII 接口网络不稳定问题

网络接口默认IO配置代码:

void init_enet_pins(ENET_Type *ptr)
{
    if (ptr == HPM_ENET0) {
        HPM_IOC->PAD[IOC_PAD_PA16].FUNC_CTL = IOC_PA16_FUNC_CTL_ETH0_MDC;
        HPM_IOC->PAD[IOC_PAD_PA15].FUNC_CTL = IOC_PA15_FUNC_CTL_ETH0_MDIO;

        HPM_IOC->PAD[IOC_PAD_PA18].FUNC_CTL = IOC_PA18_FUNC_CTL_ETH0_RXD_0;
        HPM_IOC->PAD[IOC_PAD_PA17].FUNC_CTL = IOC_PA17_FUNC_CTL_ETH0_RXD_1;
        HPM_IOC->PAD[IOC_PAD_PA19].FUNC_CTL = IOC_PA19_FUNC_CTL_ETH0_RXDV;

        HPM_IOC->PAD[IOC_PAD_PA20].FUNC_CTL = IOC_PA20_FUNC_CTL_ETH0_TXD_0;
        HPM_IOC->PAD[IOC_PAD_PA21].FUNC_CTL = IOC_PA21_FUNC_CTL_ETH0_TXD_1;
        HPM_IOC->PAD[IOC_PAD_PA23].FUNC_CTL = IOC_PA23_FUNC_CTL_ETH0_TXEN;

        HPM_IOC->PAD[IOC_PAD_PA22].FUNC_CTL = IOC_PAD_FUNC_CTL_LOOP_BACK_MASK | IOC_PA22_FUNC_CTL_ETH0_REFCLK;
    }
}

该代码发现 需要额外串联 匹配的电阻,不同的PHY串联值可能不同,导致网络访问不稳定,对该部分进行修改:

/**
  * @brief  init enet pins
  * @param  void
  * @retval void
  */
void init_enet_pins(ENET_Type *ptr)
{
    // IOC_PAD_PAD_CTL_SPD_SET(200Mhz) IOC_PAD_PAD_CTL_DS_SET(37Ohm)  
    uint32_t pad_ctl = IOC_PAD_PAD_CTL_SPD_SET(3) | IOC_PAD_PAD_CTL_DS_SET(7);

    if (ptr == HPM_ENET0) {
        HPM_IOC->PAD[IOC_PAD_PA24].FUNC_CTL = IOC_PA24_FUNC_CTL_GPIO_A_24; // reset pin

        HPM_IOC->PAD[IOC_PAD_PA15].FUNC_CTL = IOC_PA15_FUNC_CTL_ETH0_MDIO;
        HPM_IOC->PAD[IOC_PAD_PA16].FUNC_CTL = IOC_PA16_FUNC_CTL_ETH0_MDC;

        HPM_IOC->PAD[IOC_PAD_PA17].FUNC_CTL = IOC_PA17_FUNC_CTL_ETH0_RXD_1;
        HPM_IOC->PAD[IOC_PAD_PA18].FUNC_CTL = IOC_PA18_FUNC_CTL_ETH0_RXD_0;
        HPM_IOC->PAD[IOC_PAD_PA19].FUNC_CTL = IOC_PA19_FUNC_CTL_ETH0_RXDV;

        HPM_IOC->PAD[IOC_PAD_PA20].FUNC_CTL = IOC_PA20_FUNC_CTL_ETH0_TXD_0;
        HPM_IOC->PAD[IOC_PAD_PA21].FUNC_CTL = IOC_PA21_FUNC_CTL_ETH0_TXD_1;
        HPM_IOC->PAD[IOC_PAD_PA23].FUNC_CTL = IOC_PA23_FUNC_CTL_ETH0_TXEN;

        HPM_IOC->PAD[IOC_PAD_PA22].FUNC_CTL = IOC_PA22_FUNC_CTL_ETH0_REFCLK | IOC_PAD_FUNC_CTL_LOOP_BACK_MASK;

        HPM_IOC->PAD[IOC_PAD_PA17].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA18].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA19].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA20].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA21].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA22].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA23].PAD_CTL = pad_ctl;

        // MDIO/MDC IOC_PAD_PAD_CTL_SPD_SET(50Mhz) IOC_PAD_PAD_CTL_DS_SET(37Ohm)  
        // IOC_PAD_PAD_CTL_PE_SET(pull enable) IOC_PAD_PAD_CTL_PS_SET(pull up)
        // IOC_PAD_PAD_CTL_PRS_SET(47kOhm)
        pad_ctl = IOC_PAD_PAD_CTL_SPD_SET(0) | IOC_PAD_PAD_CTL_DS_SET(7) | 
                  IOC_PAD_PAD_CTL_PE_SET(1) | IOC_PAD_PAD_CTL_PS_SET(1) | 
                  IOC_PAD_PAD_CTL_PRS_SET(1);
        HPM_IOC->PAD[IOC_PAD_PA15].PAD_CTL = pad_ctl;
        HPM_IOC->PAD[IOC_PAD_PA16].PAD_CTL = pad_ctl;
    }
}

这样适配不同PHY的时候通过内部配置 IO速度, 驱动能力等参数,即可灵活的测试网络的稳定性。

 

posted @ 2024-01-14 10:30  求隐  阅读(90)  评论(0编辑  收藏  举报