lpcware

[Resolve] MAC_MII_DATA always read as 0

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by averyanov on Tue Jan 13 08:39:07 MST 2015
I try to read Status Register from PHY chip.
But MAC_MII_DATA contain 0.

I have logic analyzer that connect to MDIO line.  And i see correct data(Attached images)
Code for reading from phy
static int lpc43_phyread(uint16_t phydevaddr, uint16_t phyregaddr, uint16_t *value)
{
  volatile uint32_t timeout;
  uint32_t regval;

  regval  = lpc43_getreg(LPC43_ETH_MACMIIA);
  regval &= ETH_MACMIIA_CR_MASK;

  regval |= (((uint32_t)phydevaddr << ETH_MACMIIA_PA_SHIFT) & ETH_MACMIIA_PA_MASK);
  regval |= (((uint32_t)phyregaddr << ETH_MACMIIA_MR_SHIFT) & ETH_MACMIIA_MR_MASK);
  regval |= ETH_MACMIIA_GB;

  lpc43_putreg(regval, LPC43_ETH_MACMIIA);

  for (timeout = 0; timeout < PHY_READ_TIMEOUT; timeout++)
    {
      if ((lpc43_getreg(LPC43_ETH_MACMIIA) & ETH_MACMIIA_GB) == 0)
        {
          *value = (uint16_t)lpc43_getreg(LPC43_ETH_MACMIID);
          return OK;
        }
    }
}

[img]http://www.lpcware.com/system/files/images/screenshot.thumbnail.png[/img]

Attachments

Outcomes