EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Keil's Ethernet source code for LPC1768: Transmitting ok, but not receiving

Started by capiman26061973 March 4, 2011
Hello,

i am trying to use Keil's Ethernet example source code
in my own project. I am able to transmit own frames,
but i am not able to receive ethernet packets.
No, not really correct, on startup i get 3 corrupt
receive packets (with only 1 bytes). 3 seems to come from
the number of receive descriptors. When i increase it to 4,
i get 4 corrupt packets at startup.
Then no more receive packets.

Has someone successfully used the code ?

What i tried so far or where i have questions:

/* PCLK0MHz ? */
/* Enable Reduced MII interface. */
MAC_MCFG = MCFG_CLK_DIV44 | MCFG_RES_MII;
for (tout = 100; tout; tout--);
MAC_MCFG = MCFG_CLK_DIV44;

Is the divisor important or can i e.g. always use
maximum divisor (DIV64) ?

/* Set the Ethernet MAC Address registers */
MAC_SA0 = (mac[1]<<8) | mac[0];
MAC_SA1 = (mac[3]<<8) | mac[2];
MAC_SA2 = (mac[5]<<8) | mac[4];

Can someone confirm the order of the MAC-address ?
Or must it be the following ?

/* Set the Ethernet MAC Address registers */
MAC_SA0 = (mac[0]<<8) | mac[1];
MAC_SA1 = (mac[1]<<8) | mac[3];
MAC_SA2 = (mac[3]<<8) | mac[5];

But should be not important, because i have enabled all packets
in receive path:

MAC_RxFilterCtrl = RFC_UCAST_EN | RFC_MCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN;

Is there something else i must configure additional
to the example code lpc17xx_emac.c / lpc17xx_emac.h,
e.g. are there register which i can check if they
are correctly set ?

Best regards,

Martin

An Engineer's Guide to the LPC2100 Series

Hi

There are some bugs in this example.

1) Corrupted packets are not filtered and passed to uip which than
stops working properly.

RX_STAT_INFO(Index) - caries error mask.

But if you are not so far....

--- In l..., "capiman26061973" wrote:
>
> Hello,
>
> i am trying to use Keil's Ethernet example source code
> in my own project. I am able to transmit own frames,
> but i am not able to receive ethernet packets.
> No, not really correct, on startup i get 3 corrupt
> receive packets (with only 1 bytes). 3 seems to come from
> the number of receive descriptors. When i increase it to 4,
> i get 4 corrupt packets at startup.
> Then no more receive packets.
>
> Has someone successfully used the code ?
>
> What i tried so far or where i have questions:
>
> /* PCLK0MHz ? */
> /* Enable Reduced MII interface. */
> MAC_MCFG = MCFG_CLK_DIV44 | MCFG_RES_MII;
> for (tout = 100; tout; tout--);
> MAC_MCFG = MCFG_CLK_DIV44;
>
> Is the divisor important or can i e.g. always use
> maximum divisor (DIV64) ?

Max divisor slow down control communication between MAC and PHY.
Otherwise it does no matter. From PHY can you detect carrier presence.

>
> /* Set the Ethernet MAC Address registers */
> MAC_SA0 = (mac[1]<<8) | mac[0];
> MAC_SA1 = (mac[3]<<8) | mac[2];
> MAC_SA2 = (mac[5]<<8) | mac[4];
>
> Can someone confirm the order of the MAC-address ?
> Or must it be the following ?

Order is OK.

>
> /* Set the Ethernet MAC Address registers */
> MAC_SA0 = (mac[0]<<8) | mac[1];
> MAC_SA1 = (mac[1]<<8) | mac[3];
> MAC_SA2 = (mac[3]<<8) | mac[5];

False order. But if MAC[5] == MAC[6] == 0 it will work
as long you don't create accidentally same MAC address for two device in network.

>
> But should be not important, because i have enabled all packets
> in receive path:
>
> MAC_RxFilterCtrl = RFC_UCAST_EN | RFC_MCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN;

Not really, you need the correct address.
Unicast, broadcast and multicast frames have specific address, like
all-zeros, all ones, etc. Broadcast is mostly used. Unicast and multicast is mostly used for network management. For your purpose it is enough to have only RFC_BCAST_EN | RFC_PERFECT_EN.
RFC_PERFERC_EN activates filter which accepts only frames with correct MAC address.

Second when your are connected to switch, you do not receive all frames transmitted over network. Switch has own filter switch lock on your MAC address transmitted from you board.

I suggest you install Wireshark to your PC.
Look for ARP packets. Sent over network (like: Who has IP? x.x.x.x Tell y.y.y.y) Then set up one packet manually: You device address is looking for IP address of your PC. And start transmitting in regular inetrvals. The PC will then respond to your MAC address and switch will relay it correctly.

>
> Is there something else i must configure additional
> to the example code lpc17xx_emac.c / lpc17xx_emac.h,
> e.g. are there register which i can check if they
> are correctly set ?

>
> Best regards,
>
> Martin
>
bets regards

Lubomir


The 2024 Embedded Online Conference