取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
nblianyan
Visitor
Visitor
153 次查看
注册日期: ‎09-14-2021

ZYNQ7000(XC7Z020)器件的MDIO读取错误问题请教

老铁们好,我在使用ZYNQ7000的MAC与以太网PHY进行MDIO的通信时,发现ZYNQ7000无法读取MDIO上的数据,详情如下:

1、测试代码:

while(1)
{
    PHY_write(&MAC_inst, 3, i, i);
    for(j=0;j<1000;j++);
    PHY_read(&MAC_inst, 3, i, &regdd[i]);
    for(j=0;j<1000;j++);
}

    MDIO写操作代码:

unsigned short PHY_write(ZYNQ7000_MAC_CFG_Typedef * MAC_inst, unsigned short PHY_addr, unsigned short PHY_reg, unsigned short data)
{
    unsigned long Overtime_Cnt = 0;
    GEM_Phy_Maint_TypeDef PHY_maint_inst;

    while(MAC_inst->MAC_reg->net_status.bit.phy_mgmt_idle == 0)
    {
        Overtime_Cnt ++;
        if(Overtime_Cnt >= PHY_MDIO_WAIT_TIME)
        {
            return GEM_OPERATE_FAIL;
        }
 }

PHY_maint_inst.val = 0;
PHY_maint_inst.bit.clause_22 = MAC_inst->is_PHY_clause22;
PHY_maint_inst.bit.operation = 0b01;
PHY_maint_inst.bit.data = data;
PHY_maint_inst.bit.must_10 = 0b10;
PHY_maint_inst.bit.phy_addr = PHY_addr;
PHY_maint_inst.bit.reg_addr = PHY_reg;

MAC_inst->MAC_reg->phy_maint.val = PHY_maint_inst.val;

Overtime_Cnt = 0;
while(MAC_inst->MAC_reg->net_status.bit.phy_mgmt_idle == 0)
{
Overtime_Cnt ++;
if(Overtime_Cnt >= PHY_MDIO_WAIT_TIME)
{
return GEM_OPERATE_FAIL;
}
}

return GEM_OPERATE_SUCCESS;
}

MDIO读操作

unsigned short PHY_read(ZYNQ7000_MAC_CFG_Typedef * MAC_inst, unsigned short PHY_addr, unsigned short PHY_reg, unsigned short * data)
{
unsigned long Overtime_Cnt = 0;
GEM_Phy_Maint_TypeDef PHY_maint_inst;

while(MAC_inst->MAC_reg->net_status.bit.phy_mgmt_idle == 0)
{
Overtime_Cnt ++;
if(Overtime_Cnt >= PHY_MDIO_WAIT_TIME)
{
return GEM_OPERATE_FAIL;
}
}

PHY_maint_inst.val = 0;
PHY_maint_inst.bit.clause_22 = MAC_inst->is_PHY_clause22;
PHY_maint_inst.bit.must_10 = 0b10;
PHY_maint_inst.bit.operation = 0b10;
PHY_maint_inst.bit.phy_addr = PHY_addr;
PHY_maint_inst.bit.reg_addr = PHY_reg;

MAC_inst->MAC_reg->phy_maint.val = PHY_maint_inst.val;

Overtime_Cnt = 0;
while(MAC_inst->MAC_reg->net_status.bit.phy_mgmt_idle == 0)
{
Overtime_Cnt ++;
if(Overtime_Cnt >= PHY_MDIO_WAIT_TIME)
{
return GEM_OPERATE_FAIL;
}
}

*data = MAC_inst->MAC_reg->phy_maint.bit.data;
return GEM_OPERATE_SUCCESS;
}

2、使用示波器对MDIO、MDC信号进行抓取,截图如下:

     写操作:MDIO、MDC的写操作信号MDIO、MDC的写操作信号

     读操作:MDIO、MDC读操作MDIO、MDC读操作

   从上述波形图中,可以确定,MAC从PHY芯片(PHY地址为3、寄存器地址为2)进行读操作时,PHY芯片成功的将数据放在了MDIO上。

3、但是,从MAC的PHY Maintenance寄存器读取时,发现该寄存器常为0xFFFFFFFF。截图如下:

捕获.PNG

 

4、综上,现象为MAC成功通过MDIO发出数据,PHY器件也成功通过MDIO发出数据,但是MAC无法从MDIO上读取数据,特此咨询各位老铁,哪里配置的有问题。

0 项奖励
2 回复数
junhawk
Scholar
Scholar
121 次查看
注册日期: ‎05-29-2018

总线上PHY已经读取成功了。

0 项奖励
nblianyan
Visitor
Visitor
107 次查看
注册日期: ‎09-14-2021

谢谢,但我的问题是MAC无法从MDIO读出数据

0 项奖励