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
Could there be a problem with the buffer? Or is it possible that your PHYs don't send any pakets to the MAC?
the code looks ok; so I would say, that it should work...
best regards Peter
now I only want to look if the RMI interface would work - and I only set the AT91C_EMAC_RMII bit - and now I receive datas - but what's the reason for that???
Johannes