This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT: Custom configuration of Ethernet PHY

Part Number: TM4C129ENCPDT

Hi,

am using TM4C129ENCPDT microcontroller, and the integrated PHY supports 10Base-T and 100Base-TX signaling, full and half duplex, auto negotiating mode. I used the following configuration to initialize the ethernet successfully and its worked without any issue: 

{
// Enable the ethernet peripheral.
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_EMAC0);
MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_EMAC0); //Performs a software reset of a peripheral
// Enable the internal PHY if it's present and we're being
// asked to use it.
if((EMAC_PHY_CONFIG & EMAC_PHY_TYPE_MASK) == EMAC_PHY_TYPE_INTERNAL)
{

// We've been asked to configure for use with the internal
// PHY. Is it present?

if(MAP_SysCtlPeripheralPresent(SYSCTL_PERIPH_EPHY0))
{
//
// Yes - enable and reset it.
//
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_EPHY0);
MAP_SysCtlPeripheralReset(SYSCTL_PERIPH_EPHY0);
}
else
{
//
// Internal PHY is not present on this part so hang here.
//
while(1)
{
}
}
}
// Wait for the MAC to come out of reset.
while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_EMAC0))
{
}


// Configure for use with whichever PHY the user requires.
EMACPHYConfigSet(EMAC0_BASE, EMAC_PHY_CONFIG);


// Initialize the MAC and set the DMA mode.
MAP_EMACInit(EMAC0_BASE, ui32SysClkHz,
EMAC_BCONFIG_MIXED_BURST | EMAC_BCONFIG_PRIORITY_FIXED,
4, 4, 0);


// Set MAC configuration options.
MAP_EMACConfigSet(EMAC0_BASE, (EMAC_CONFIG_FULL_DUPLEX |
EMAC_CONFIG_CHECKSUM_OFFLOAD |
EMAC_CONFIG_7BYTE_PREAMBLE |
EMAC_CONFIG_IF_GAP_96BITS |
EMAC_CONFIG_USE_MACADDR0 |
EMAC_CONFIG_SA_FROM_DESCRIPTOR |
EMAC_CONFIG_BO_LIMIT_1024),
(EMAC_MODE_RX_STORE_FORWARD |
EMAC_MODE_TX_STORE_FORWARD |
EMAC_MODE_TX_THRESHOLD_64_BYTES |
EMAC_MODE_RX_THRESHOLD_64_BYTES), 0);
// Program the hardware with its MAC address (for filtering).
MAP_EMACAddrSet(EMAC0_BASE, 0, (uint8_t *)pui8MAC);

}

but I have problem when I tried to apply custom configuration like change speed mode during the program running, Could you please advice me with the correct sequence and functions to apply new configuration and change the ethernet speed and mode by EMACPC bits ANEN and ANMODE? 

Regards,

  • Hi,

     What exactly do you want to change? If you look at the below lines, the PHY configuration is as follows. It is in 100B full-duplex. 

    #define EMAC_PHY_CONFIG (EMAC_PHY_TYPE_INTERNAL | EMAC_PHY_INT_MDIX_EN | \
    EMAC_PHY_AN_100B_T_FULL_DUPLEX)

    EMACPHYConfigSet(EMAC0_BASE, EMAC_PHY_CONFIG);

  • Hi,

    Actually I designed a webpage to configure and change ip address and ethernet configuration  of my application. So I need a way to reconfigure and apply the new ethernet configuration for example change speed from 100 to 10 without apply software reset as I read in the datasheet at page 1590 there is a way to apply the custom configuration during running the app, but when follow the steps its didn't  work with me, I appreciate your help.

    Regards,

  • Please refer to EMACPHYConfigSet function. As you can see after a change to the PHY configuration, the 

    //*****************************************************************************
    //
    //! Selects the Ethernet PHY in use.
    //!
    //! \param ui32Base is the base address of the Ethernet controller.
    //! \param ui32Config selects the PHY in use and, when using the internal
    //! PHY, allows various various PHY parameters to be configured.
    //!
    //! This function must be called prior to EMACInit() and EMACConfigSet() to
    //! select the Ethernet PHY to be used. If the internal PHY is selected, the
    //! function also allows configuration of various PHY parameters. Note that
    //! the Ethernet MAC is reset during this function call because parameters used
    //! by this function are latched by the hardware only on a MAC reset. The call
    //! sequence to select and configure the PHY, therefore, must be as follows:

    //! \verbatim
    //! // Enable and reset the MAC.
    //! SysCtlPeripheralEnable(SYSCTL_PERIPH_EMAC0);
    //! SysCtlPeripheralReset(SYSCTL_PERIPH_EMAC0);
    //! if(<using internal PHY>)
    //! {
    //! // Enable and reset the internal PHY.
    //! SysCtlPeripheralEnable(SYSCTL_PERIPH_EPHY0);
    //! SysCtlPeripheralReset(SYSCTL_PERIPH_EPHY0);
    //! }
    //!
    //! // Ensure the MAC is completed its reset.
    //! while(!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_EMAC0))
    //! {
    //! }
    //!
    //! // Set the PHY type and configuration options.
    //! EMACPHYConfigSet(EMAC0_BASE, <config>);
    //!
    //! // Initialize and configure the MAC.
    //! EMACInit(EMAC0_BASE, <system clock rate>, <bus config>,
    //! <Rx burst size>, <Tx burst size>, <desc skip>);
    //! EMACConfigSet(EMAC0_BASE, <parameters>);
    //! \endverbatim

    snip....

    void
    EMACPHYConfigSet(uint32_t ui32Base, uint32_t ui32Config)
    {
    //
    // Write the Ethernet PHY configuration to the peripheral configuration
    // register.
    //
    HWREG(ui32Base + EMAC_O_PC) = ui32Config;

    //
    // If using the internal PHY, reset it to ensure that new configuration is
    // latched there.
    //
    if((ui32Config & EMAC_PHY_TYPE_MASK) == EMAC_PHY_TYPE_INTERNAL)
    {
    SysCtlPeripheralReset(SYSCTL_PERIPH_EPHY0);
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EPHY0))
    {
    //
    // Wait for the PHY reset to complete.
    //
    }

    //
    // Delay a bit longer to ensure that the PHY reset has completed.
    //
    SysCtlDelay(10000);
    }