No activity on STM32F407 PHY SMI interface.
Hi
I am trying to probe data going between the STM32F407 MAC and LAN8720A. I have a 50MHz clock from MCO1 to the PHY and seems to be working as the LED's are recognizing the network. I believe the clock signal is idle until there is data transfer between them but when I do a write (or read) I do not see and signal on the MDIO or MDC lines. As I am only interestes in the SMI at the moment I have configured the alternate function (ETH) 0b1011 for PA2 and PC1 as follows:
GPIOA->MODER |= (1 << 5); // Set PA2 as alternate function - MDIO
GPIOC->MODER |= (1 << 3); // Set PC1 as alternate function - MDC GPIOA->AFR[0] |= (0xB << 8); // AF11 - 0b1011 = 0xB GPIOC->AFR[0] |= (0xB << 4);The write is as follows:
uint32_t ETH_WritePHYRegister(uint16_t PHYAddress, uint16_t PHYReg, uint16_t PHYValue)
{ volatile uint32_t tmpreg = 0; uint32_t tmpDataReg = 0; __IO uint32_t timeout = 0; tmpreg = ETH_MACMIIAR; // keeps previous clock setting /* Keep only the CSR Clock Range CR[2:4] bits value */ tmpreg &= 0b00000000000000000000000000011100;/* Prepare the MII register address value */
tmpreg |=(((uint32_t)PHYAddress<<11) & ETH_MACMIIAR_PA); /* Set the PHY device address */ // ETH_MACMIIAR_PA = 0x0000F800 tmpreg |=(((uint32_t)PHYReg<<6) & ETH_MACMIIAR_MR); /* Set the PHY register address */ tmpreg |= ETH_MACMIIAR_MW; /* Set the write mode */ // ETH_MACMIIAR_MW = 0x2 tmpreg |= ETH_MACMIIAR_MB; /* Set the MII Busy bit */ // ETH_MACMIIAR_MB = 0x1 /* Give the value to the MII data register */ ETH_MACMIIDR = PHYValue; /* Write the result value into the MII Address register */ ETH_MACMIIAR = tmpreg; /* Check for the Busy flag */ do { timeout++; tmpreg = ETH_MACMIIAR; } while (timeout < 5); //} while ((tmpreg = 0b10011) && (timeout < (uint32_t)PHY_WRITE_TO)); /* Return ERROR in case of timeout */ if(timeout == PHY_WRITE_TO) // PHY_WRITE_TO = 0x0000FFFFU {return ETH_ERROR; // 1
}/* Return SUCCESS */
return ETH_SUCCESS; // 0
}I expect when I get to '
ETH_MACMIIAR = tmpreg;' that I would see some activity on the MDC and MDIO lines but there is nothing happening. Is there something additional required to initiate a write??
Thanks.
