AnsweredAssumed Answered

Issue with MDIO (k60DN512)

Question asked by Chaitannya Mahatme on Jan 13, 2015
Latest reply on May 13, 2016 by Trilok JT

Hello Everyone,

 

I am using K60DN512 device with Lan8720A phy device.

I have initialized the Ethernet MAC, but there is no data on MDIO pin (I have checked on logic analyser)

I have done following initialization.

 

GPIO

SIM ->SCGC5 |= SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK;

 

    //Configure RMII0_RXER (PTA5)

    PORTA ->PCR[5] = PORT_PCR_MUX(4) | PORT_PCR_PE_MASK;

    //Configure RMII0_RXD1 (PTA12)

    PORTA ->PCR[12] = PORT_PCR_MUX(4);

    //Configure RMII0_RXD0 (PTA13)

    PORTA ->PCR[13] = PORT_PCR_MUX(4);

    //Configure RMII0_CRS_DV (PTA14)

    PORTA ->PCR[14] = PORT_PCR_MUX(4);

    //Configure RMII0_TXEN (PTA15)

    PORTA ->PCR[15] = PORT_PCR_MUX(4);

    //Configure RMII0_TXD0 (PTA16)

    PORTA ->PCR[16] = PORT_PCR_MUX(4);

    //Configure RMII0_TXD1 (PTA17)

    PORTA ->PCR[17] = PORT_PCR_MUX(4);

 

    //Configure RMII0_MDIO (PTB0)

    PORTB ->PCR[0] = PORT_PCR_MUX(4) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK;

    //Configure RMII0_MDC (PTB1)

    PORTB ->PCR[1] = PORT_PCR_MUX(4);


GPIO is configured as alternate function 4, as mentioned in datasheet.

Next disabled the IRQ

//Disable Ethernet MAC interrupts

    NVIC_DisableIRQ(ENET_Transmit_IRQn);

    NVIC_DisableIRQ(ENET_Receive_IRQn);

    NVIC_DisableIRQ(ENET_Error_IRQn);

Next initialized the MAC

//Enable ENET peripheral clock

    SIM ->SCGC2 |= SIM_SCGC2_ENET_MASK;

 

    //GPIO configuration

    mk60EthInitGpio(interface);

    //Reset ENET module

    ENET ->ECR = ENET_ECR_RESET_MASK;

    //Wait for the reset to complete

    while (ENET ->ECR & ENET_ECR_RESET_MASK)

        ;

 

    //Reveive control register

    ENET ->RCR = ENET_RCR_MAX_FL(1518) | ENET_RCR_RMII_MODE_MASK

            | ENET_RCR_MII_MODE_MASK;

    //Transmit control register

    ENET ->TCR = 0;

    //Configure MDC clock frequency

    ENET ->MSCR = ENET_MSCR_MII_SPEED(19);

 

Next read the first SFR of the Phy device.

uint32_t value = ENET_MMFR_ST(1) | ENET_MMFR_OP(2) | ENET_MMFR_TA(2);

    //PHY address

    value |= ENET_MMFR_PA(phyAddr);

    //Register address

    value |= ENET_MMFR_RA(regAddr);

 

    //Clear MII interrupt flag

    ENET ->EIR = ENET_EIR_MII_MASK;

    //Start a read operation

    Bit1_SetVal(NULL);

    ENET ->MMFR = value;


In the last line, the value comes out to be 0x60020000 (TA = 10 ... This field must be programmed to 10 to generate a valid MII management frame.), when it executes the value of MMFR  is 0x60030000 (TA=11). Why is this happening.

I think all the values are initialized correctly. When I checked on logic analyser, there is no output. However as soon as I execute the command, the MII interrupt flag of EIR is set.

I tried changing the value of TA to 10 (In debug mode, through the register view), but it simply doesn't work.


Is there something wrong with the initialization. I have not connected the CAT cable, but I feel that shouldn't make any difference.

 

 


Outcomes