Norbert Mayer

MCF52235EVB Ethernet doesn´t work

Discussion created by Norbert Mayer on Jun 12, 2007
Latest reply on Dec 11, 2007 by JASMIN GOUPIL
Hello

i know that there are various post on the same theme, but i´´m really helpless.
i´m working on the evalboard and just want to send an ethernetpacket.
in my opinion i did everything what is necessary. i compared my code with examples and talked to friends of mine but without success.
i really hope that you can spend a plenty of time to view at my sourcecode. i used the standard support files and the cfinit to make sure everything is correct, but after setting the TDAR nothing happens.
maybe the problem is the MMFR but i have no idea.

thx for any clues

here is the c code. i know its a lot but....i left out the nonessential parts

static unsigned char  mac[6] = { 0x00, 0x6B, 0x5D, 0x40, 0xF8, 0xDC };
static unsigned char dest[6] = { 0x00, 0x60, 0x08, 0x47, 0xEE, 0x56 };

void nbuf_init ()
{
    uint8 i;

    TxNBUF = (NBUF *)((uint32)(unaligned_txbd + 16) & 0xFFFFFFF0);
    RxNBUF = (NBUF *)((uint32)(unaligned_rxbd + 16) & 0xFFFFFFF0);
    TxBuffer = (uint8 *)((uint32)(unaligned_txbuffer + 16) & 0xFFFFFFF0);
    RxBuffer = (uint8 *)((uint32)(unaligned_rxbuffer + 16) & 0xFFFFFFF0);

    for (i = 0; i < NUM_RXBDS; i++)
    {
        RxNBUF[i].status = RX_BD_E;
        RxNBUF[i].length = 0;
        RxNBUF[i].data = &RxBuffer[i * RX_BUFFER_SIZE];
    }
    RxNBUF[NUM_RXBDS - 1].status |= RX_BD_W;

    for (i = 0; i < NUM_TXBDS; i++)
    {
        TxNBUF[i].status = TX_BD_L | TX_BD_TC;
        TxNBUF[i].length = 0;
        TxNBUF[i].data = &TxBuffer[i * TX_BUFFER_SIZE];
    }
    TxNBUF[NUM_TXBDS - 1].status |= TX_BD_W;

    iTxbd = iRxbd = 0;

    return;
}

int main()
{
    int i = 0;

    // Mask all interrupts
    asm {
        move.w   #0x2700,sr
    }
      
    MCF_FEC_ECR = MCF_FEC_ECR_RESET;
    while (MCF_FEC_ECR & MCF_FEC_ECR_RESET);
  
    MCF_FEC_EIMR = 0;
    MCF_FEC_EIR = 0xFFFFFFFF;
  
    MCF_FEC_RCR = MCF_FEC_RCR_MAX_FL(0x5ee) |
                  MCF_FEC_RCR_MII_MODE      |
                  MCF_FEC_RCR_PROM            |
                  MCF_FEC_RCR_DRT;

    MCF_FEC_TCR = 0;

    MCF_FEC_EIMR = 0xFFF80000;
    //MCF_FEC_EIMR_RXF   ;

    MCF_FEC_FRSR = 0x00000500;
    MCF_FEC_TFWR = 0;
    MCF_FEC_GAUR = 0;
    MCF_FEC_GALR = 0;
    MCF_FEC_IAUR = 0;
    MCF_FEC_IALR = 0;
    MCF_FEC_PALR = 0x5d40f8dc;
    MCF_FEC_PAUR = 0x006b0000;
  
    nbuf_init();
    MCF_FEC_EMRBR = ((uint16)RX_BUFFER_SIZE)*3;
    MCF_FEC_ERDSR = nbuf_get_start(Rx);
    MCF_FEC_ETDSR = nbuf_get_start(Tx);

    MCF_FEC_ECR = MCF_FEC_ECR_ETHER_EN;
  
    MCF_FEC_RDAR = 1;
   
    MCF_FEC_MSCR = MCF_FEC_MSCR_MII_SPEED(0xD);

    MCF_PHY_EPHYCTL1 = 0;

    MCF_PHY_EPHYCTL0 = MCF_PHY_EPHYCTL0_DIS100 |
                       MCF_PHY_EPHYCTL0_DIS10  |
                       MCF_PHY_EPHYCTL0_LEDEN;

    MCF_PHY_EPHYCTL0 &= ~MCF_PHY_EPHYCTL0_ANDIS;

    MCF_PHY_EPHYCTL0 |= MCF_PHY_EPHYCTL0_EPHYEN;

    MCF_PHY_EPHYCTL0 &= ~(MCF_PHY_EPHYCTL0_DIS100 |
                          MCF_PHY_EPHYCTL0_DIS10);

    cpu_pause(50000000)
 
    MCF_FEC_MMFR = MCF_FEC_MMFR_ST(0x1)      |
                  MCF_FEC_MMFR_OP(0x1)      |
                  MCF_FEC_MMFR_TA(0x2)      |
                  MCF_FEC_MMFR_DATA(0x2100);

    while ((MCF_FEC_EIR & MCF_FEC_EIR_MII) == 0);

    MCF_FEC_EIR |= MCF_FEC_EIR_MII;     init_ethernet_PHY ();
   
    init_interrupt_controller ();
   
    fec_init(&mein_nif);
    for(i=0; i<=5; i++)
        mein_nif.hwa[i] = mac[i];  
    nif_bind_protocol(&mein_nif, FRAME_ARP, stack_fechandler, "ARP_PROTOCOL" );
    nif_bind_protocol(&mein_nif, FRAME_IP, stack_fechandler, "IP_PROTOCOL" );

    MCF_INTC0_INTFRCL = 0x08000000; // tried to get an interrupt but no reaction...just went on in sourcecode

    //1. Paket
    eth_stub_init();
    eth_stub_txalloc(&mein_nif);
    for(i=0; i<=5; i++)
        eth_tx_frame.destination[i] = dest[i];
    for(i=0; i<=5; i++)
        eth_tx_frame.source[i] = mac[i];  
    eth_tx_frame.protocol = FRAME_IP;
    eth_tx_frame.frame_size = 0x64;
    eth_stub_writeheader(&mein_nif, &eth_tx_frame);  
    for(i=0; i<=100; i++)
        eth_stub_write(&mein_nif, 0xCC); //just some data to send
    eth_stub_send(&mein_nif, 0x64);

hope this is enough to find something

Outcomes