AnsweredAssumed Answered

Questions of MPC5777C FEC setting

Question asked by Taekyoung Kim on Feb 7, 2017
Latest reply on Dec 7, 2017 by Thiago Duarte

Hi.

 

I try to enable FEC with MII interface setting, but nothing works so far.

I used 'AN4577_Using the Fast Ethernet Controller on the Qorivva MPC564xBC' document as a reference.

 

There are three questions about

1. FEC I/O setting

2. FEC Clock setting

3. isConnected() function (miiRead function)

 

Questions are below

1. FEC I/O setting - please check I/O setting

 

#define OBE    0x0200

#define IBE    0x0100

#define ODE    0x0020

#define SRC    0x0004

#define WPE    0x0002

#define WPS    0x0001

 

#define PA_GPIO 0x0000

#define PA_PRIM 0x0400

#define PA_ALT1 0x0800

#define PA_ALT2 0x0C00

#define PA_ALT3 0x1000

 

// initFecIo - initialise pads for FEC use in the SIU

void initFecIo(void)

{

        // MPC5777C - FEC MII-Lite mode IO setting

        SIU.PCR[99].R          = PA_ALT2 | OBE | IBE | SRC | WPE;              // FEC_MDIO

        SIU.PCR[109].R         = PA_ALT3 | OBE | WPE;                                 // FEC_MDC

 

        SIU.PCR[252].R         = PA_PRIM | ODE        | SRC;                         // FEC_TX_EN

        SIU.PCR[248].R         = PA_PRIM | ODE        | SRC;                         // FEC_TXD0

        SIU.PCR[251].R         = PA_PRIM | ODE        | SRC;                         // FEC_TXD1

        SIU.PCR[98].R          = PA_ALT2 | ODE        | SRC;                          // FEC_TXD2

        SIU.PCR[101].R         = PA_ALT3 | ODE        | SRC;                        // FEC_TXD3

        SIU.PCR[474].R         = PA_PRIM | IBE        | WPE;                        // FEC_TX_CLK

                                            

        SIU.PCR[100].R         = PA_ALT3 | IBE        | SRC | WPE;                  // FEC_RX_CLK

        SIU.PCR[249].R         = PA_PRIM | IBE        | WPE;                        // FEC_RX_DV

        SIU.PCR[250].R         = PA_PRIM | IBE        | SRC | WPE;                  // FEC_RXD0

        SIU.PCR[253].R         = PA_PRIM | IBE        | SRC | WPE;                  // FEC_RXD1

        SIU.PCR[110].R         = PA_ALT3 | IBE        | SRC | WPE;                  // FEC_RXD2

        SIU.PCR[107].R         = PA_ALT3 | IBE        | SRC | WPE;                  // FEC_RXD3

}

 

2. FEC Clock setting

  - According to 'MPC5777C_EVB_USER_GUIDE' document, on Board FEC 50MHz CLK is enable with J524 jumper setting. 

   

  - With that jumper setting, if I set the 'MII Speed Control Register(FEC_MSCR)' with '0xA', it results in an 'FEC_MDC frequency 2.5MHz. Is that right?

 

3. isConnected() function 

  - It's kind of stuck in 'while (!isConnected())'

  - In my case, the miiRead return data is always '0x7849', so the 'result = (data & 0x0004) ? 1 : 0' is always '0'.

  - What is the meaning of register address value of '0x0001' in isConnected() function?

  - How can I pass and return expected data from miiRead() function? Please guide me.

 

// isConnected - returns 1 is connected, otherwise 0
int isConnected(void)
{
   uint16_t data;
   int result = 0;

   if (miiRead(0x0001, &data))
   {
      result = (data & 0x0004) ? 1 : 0;
   }
   return result;
}

 

int miiRead(int regAddr, uint16_t *data)

{

   ...

   FEC.MMFR.R = 0x60020000 | ((phyAddr & 0x1F) << 23) | ((regAddr & 0x1F) << 18);

}

 

I couldn't upload full source code for the security reasons, please refer 'AN4577SW' sample code.

If there are any advice, feedback or sample code, please let me know. 

 

Thank you for your patience.

Outcomes