Here is my code for Internal loop back test. I used ENET_PDD.h for physical driver functions and definitions. Prior to this test I read PHY Address and set MAC address. Please let me know whats going wrong with code flow and help me in sorting out the problem. I tried attaching the whole project but, I'm unable to attach.
uint8_t PerformBIT_EthernetTest(void)
{
LDD_ETH_TBufferDesc BufferDescListPtr[2];
uint8* BufferListPtr[2];
uint8 tx_buf[120],rx_buf[120];
uint8_t dummy[100], Status = 0;
int i;
uint8_t temp[] = {"\n\r\v 3. Testing Ethernet.."};
uint8_t ErrorMsg[] = {"\n\n\r\t Ethernet Test Failed"};
uint32 *reg_ptr1,reg_value1;
BufferDescListPtr[0].DataPtr = tx_buf;
BufferDescListPtr[0].Size = 100;
BufferListPtr[0] = rx_buf;
TxStr(temp);
tx_buf[0]=0xff; // broad cast frame address = ff:ff:ff:ff:ff:ff
tx_buf[1]=0xff;
tx_buf[2]=0xff;
tx_buf[3]=0xff;
tx_buf[4]=0xff;
tx_buf[5]=0xff;
tx_buf[6]=0x00;
tx_buf[7]=0x01;
tx_buf[8]=0x02;
tx_buf[9]=0x03;
tx_buf[10]=0x04;
tx_buf[11]=0x05;
for (i=12;i<100;i++) tx_buf[i]=0x55; // fill data area with 0x55
//for (i=12;i<100;i++) rx_buf[i]=0xaa; // fill data area with 0xaa
Status=1;
ENET_PDD_EnableInternalLoopback(ENET_BASE_PTR, PDD_ENABLE);
do
{
Status = ETH1_ReceiveFrame(eth_handler, BufferListPtr, 1);
} while(Status != ERR_OK);
eth_rx_set =0;
do
{
ETH1_SendFrame(eth_handler, BufferDescListPtr, 1);
} while(Status != ERR_OK);
eth_tx_set = 0;
for (i=0;i<100;i++)
{
Delay(1000);
if(eth_tx_set)
break;
}
for (i=0;i<100;i++)
{
Delay(1000);
if(eth_rx_set)
break;
}
if (eth_tx_set && eth_rx_set )
{
Status=0;
for(i=12;i<90;i++) // compare recived data
{
if (tx_buf[i] != rx_buf[i])
{
Status=0;
break;
}
}
}
else
{
Status = 1;
TxStr(ErrorMsg);
}
return Status;
}