Hi,
We have a Ethernet network product that uses TM4C129ENCPDT. These is an issue that we need to find out the cause.
From time to time the device would become unreliable in terms of receiving and transmitting Ethernet packets.
We have a testing device that constantly sends test packet to other device over Ethernet. The tested device will simply bounce back the test packet back so that the testing device can compare the numbers of packets that are sent and received. If the 2 numbers don't match, it means packets are lost.
When the issue happens, we found that there are lots of lost packets during testing.
One interesting thing is that, without resetting the device, i.e., the firmware reset, we can trigger a procedure in the device from outside(through a command). This procedure will reset the Ethernet port. After this, the issue will be cleared and no lost packet will be detected.
It looks like the issue is not related to the firmware, but to the Ethernet controller hardware. My question is, what could go wrong inside the Ethernet MAC that we can do to prevent it from firmware?
The procedure that can cure the issue is as follows:
void
InitializeEthernet()
{
//
// Enable and reset the Ethernet modules.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_EMAC0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_EPHY0);
SysCtlPeripheralReset(SYSCTL_PERIPH_EMAC0);
SysCtlPeripheralReset(SYSCTL_PERIPH_EPHY0);
//
// Wait for the MAC to be ready.
//
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_EMAC0)) {
WdogTemporyFeed();
}
//
// Configure for use with the internal PHY.
//
EMACPHYConfigSet(EMAC0_BASE, (EMAC_PHY_TYPE_INTERNAL | EMAC_PHY_INT_MDIX_EN | EMAC_PHY_AN_100B_T_FULL_DUPLEX));
//
// Reset the MAC to latch the PHY configuration.
//
EMACReset(EMAC0_BASE);
//
// Initialize the MAC and set the DMA mode.
//
EMACInit(EMAC0_BASE, SysClock, EMAC_BCONFIG_MIXED_BURST | EMAC_BCONFIG_PRIORITY_FIXED, 4, 4, 0);
//
// Set MAC configuration options.
//
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);
//
// Initialize the Ethernet DMA descriptors.
//
InitDescriptors(EMAC0_BASE);
//
// Program the hardware with its MAC address (for filtering).
//
EMACAddrSet(EMAC0_BASE, 0, MacAddr);
//
// Enable the Ethernet RX Packet interrupt source.
//
EMACIntEnable(EMAC0_BASE, EMAC_INT_RECEIVE | EMAC_INT_PHY);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeEthernetLED(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1);
GPIOPinConfigure(GPIO_PF0_EN0LED0);
GPIOPinConfigure(GPIO_PF1_EN0LED2);
EMACPHYExtendedWrite(EMAC0_BASE,0,EPHY_LEDCR,EPHY_LEDCR_BLINKRATE_20HZ);
EMACPHYExtendedWrite(EMAC0_BASE,0,EPHY_LEDCFG,EPHY_LEDCFG_LED0_LINK | EPHY_LEDCFG_LED2_RXTX);
// The driver lib is not correct. This bit actually controls the polarity of LED indicator
//
HWREG(EMAC0_BASE + EMAC_O_CC) |= EMAC_CC_ECEXT;
}