I am interfacing ARM Controller LPC2378 with DP83848C Ethernet Physical Layer Transceiver. I have downloaded a code for ethernet related to the above interface called -EasyWEB- from NXP. While compiling the program, it was not showing any error. But while running the program in my board it was Hanging. As soon as it reach -MAC_COMMAND- to execute the instruction in -Init_EMAC- function, the program Hangs over there:
void Init_EMAC(void)
{
/* Power Up the EMAC controller. */
PCONP = PCONP | 0x40000000;
/* Enable P1 Ethernet Pins. */
if ( MAC_MODULEID == OLD_EMAC_MODULE_ID )
PINSEL2 = 0x50151105; else
PINSEL2 = 0x50150105; PINSEL3 = ( PINSEL3 & ~0x0000000F ) | 0x00000005;
/* Reset all EMAC internal modules. */
MAC_MAC1 = MAC1_RES_TX|MAC1_RES_MCS_TX|MAC1_RES_RX| MAC1_RES_MCS_RX|MAC1_SIM_RES| MAC1_SOFT_RES;
MAC_COMMAND = CR_REG_RES | CR_TX_RES | CR_RX_RES;
:
Since the code was hanging in -MAC_COMMAND, I modified the code. I brought the Command register before the Power Control (PCONP) register to Reset the Rx, Tx and RegReset bit. Then the program was working properly. I was able to write and read to/from DP83848C, I was able to get the correct PHY ID. But I was not able to Initialise Tx and Rx DMA Descriptors. While in the function -rx_descr_init- it gets hanged in the instruction -MAC_RXSTATUS-.
unsigned int regv, tout, id1, id2;
/* Enable Reduced MII interface. */
for (tout = 100; tout; tout--); // A Short Delay
PINSEL2 = 0x50151105;
else
PINSEL2 = 0x50150105;
PINSEL3 = ( PINSEL3 & ~0x0000000F ) | 0x00000005;
: :
void rx_descr_init (void)
unsigned int i;
for (i = 0; i < NUM_RX_FRAG; i++)
RX_DESC_PACKET(i) = RX_BUF(i);
RX_DESC_CTRL(i)= RCTRL_INT | (ETH_FRAG_SIZE-1);
RX_STAT_INFO(i) = 0;
RX_STAT_HASHCRC(i) = 0;
}
/* Set EMAC Receive Descriptor Registers. */
MAC_RXDESCRIPTOR = RX_DESC_BASE;
MAC_RXSTATUS = RX_STAT_BASE;
Can you please give me a solution for this, and please explain me why it gets hang in that places.
thats been posted by me only Naveen Cali
Can Anyone Plz Help me Out
The problem is hidden in the wrong pin initialization. This is the downside of freeweare.
Here is the solution, simply replace your code with this one:
void Init_EMAC(void) { // Keil: function modified to access the EMAC // Initializes the EMAC ethernet controller unsigned int regv,tout,id1,id2; /* Enable P1 Ethernet Pins. */ PINSEL2 = 0x50150105; PINSEL3 = (PINSEL3 & ~0x0000000F) | 0x00000005; /* Power Up the EMAC controller. */ PCONP |= 0x40000000; /* Reset all EMAC internal modules. */
I hope this will speare some nervs.
Bye, Miha
Nothing to do with freeware.
A lot to do with the NXP23xx errata "Ethernet.1".
A little bit strange that the NXP-recommended workaround with autodetect of the MAC didn't work.