This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

At91 ethernet - can't receive

Hello,

I'm trying to work with the eternet at the AT91RM9200 - but until now I'm not able to receive any packets...

I don't know why it is not working - I can read the PHY registers - that's works fine (MDIO_StartupPHY)...

#define AT91C_EMAC_TDLIST_BASE     0x20010000
EMAC_pRX_descriptor p_rxBD = (EMAC_pRX_descriptor)AT91C_EMAC_TDLIST_BASE;
char RxPacket[NB_ETH_RX_PACKETS * ETH_PACKET_SIZE];

EMAC_RXBUF_ADDR_BASE_MASK = 0xFFFFFFFC
EMAC_RXBUF_ADD_WRAP = 0x02

typedef struct {
    unsigned int   RxBufAddr;                                           /* Address of RX buffer.                               */
    unsigned int   RxBufStatus;                                         /* Status of RX buffer.                                */
}  EMAC_RX_descriptor, *EMAC_pRX_descriptor;
   unsigned int i;
        char *pRxPacket;
        int status;
        AT91PS_EMAC pEmac = AT91C_BASE_EMAC;


        pRxPacket = (char *)RxPacket;

        // init descriptor. This descriptor must be WORD aligned
        for(i=0; i< NB_ETH_RX_PACKETS; ++i)
        {
                p_rxBD[i].RxBufAddr = ((unsigned int)(pRxPacket + (i * ETH_PACKET_SIZE))) & EMAC_RXBUF_ADDR_BASE_MASK;
                p_rxBD[i].RxBufStatus = 0;
        }

        //set wrap bit at the end of the list descriptor
//      p_rxBD[NB_ETH_RX_PACKETS - 1].RxBufAddr |= EMAC_RXBUF_ADD_WRAP;
        p_rxBD[i].RxBufAddr = ((unsigned int)(pRxPacket + (i * ETH_PACKET_SIZE))) & EMAC_RXBUF_ADDR_BASE_MASK | EMAC_RXBUF_ADD_WRAP;


        AT91F_EMAC_CfgPMC();
        AT91F_EMAC_CfgPIO();

        status = MDIO_StartupPhy(pEmac);

        pEmac->EMAC_SA1L = ((int)localMACAddr[2] << 24) | ((int)localMACAddr[3] << 16) | ((int)localMACAddr[4] << 8) | localMACAddr[5];
        pEmac->EMAC_SA1H = ((int)localMACAddr[0] << 8) | localMACAddr[1];

        //receive buffer queue pointer
        pEmac->EMAC_RBQP = (unsigned int) p_rxBD;

        //clear receive status register
        pEmac->EMAC_RSR  &= ~(AT91C_EMAC_OVR | AT91C_EMAC_REC | AT91C_EMAC_BNA);


        pEmac->EMAC_CTL |= AT91C_EMAC_CSR;
        pEmac->EMAC_CFG  |= AT91C_EMAC_CAF;                                                                  AT91C_BASE_EMAC->EMAC_CFG = (AT91C_BASE_EMAC->EMAC_CFG & ~(AT91C_EMAC_CLK)) | AT91C_EMAC_CLK_HCLK_32;

        pEmac->EMAC_CTL  |= (AT91C_EMAC_TE | AT91C_EMAC_RE);

I hope anybody could help me to find the little mistake in this code...

best regards
Johannes

Parents Reply Children
No data