Problem with code for establishing ethernet

Status
Not open for further replies.

babud

Newbie level 1
Joined
Jul 12, 2008
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Hello every one,
I am working on Silabs Ethernet DK(F120TB+AB4). I have enabled TCP,HTTP and code generated. After the set up,when I run the code i’m not able to get the web page “HELLO WORLD”. And system status LED (green) not glow.when I ping the embedded system message comes “request timed out” .I tried to resolve the problem by placing BREAK points and noticed the function mn_ether_init(AUTO_NEG, 0, 0) is blocking(not returned), if returned, I checked the return value ,it giving “-116”(ether_send_error).
I am giving the code where I STUCK.
//-----------------------------------------------------------------------------
// establish_network_connection
//-----------------------------------------------------------------------------
//
// This function calls mn_ether_init() to initialize the CP2200 and attach to
// the network.
//
// If there is a network connection, the function returns 1.
//
// In the call to mn_ether_init(), NUM_AUTONEG_ATTEMPTS is set to 0, so the
// function will not return until it successfully auto-negotiates.
//
// mn_ether_init() will not be a blocking call if NUM_AUTONEG_ATTEMPTS is set
// to a value greater than 0.
//
int establish_network_connection()
{
int retval;

do
{
// mn_ether_init() initializes the Ethernet controller.
// AUTO_NEG indicates that the controller will auto-negotiate.
retval = mn_ether_init(AUTO_NEG, 0, 0);

// If there is no link, poll link_status until it sets or the
// CP2200 resets and then call mn_ether_init() again.
if (retval == LINK_FAIL)
{
while(!link_status && !ether_reset);
}

// If retval is less than zero and is not LINK_FAIL, there is a
// hardware error.
else if (retval < 0)
{
// Verify that the Ethernet controller is connected and powered properly.
// Verity that the EMIF has been configured at a speed compatible with the
// Ethernet controller.
while(1);
I STUCKED HERE. AND CONTROL STAYS IN THIS LOOP.
}

}while(retval < 0);

return (1);

}

I’m simply receiving and transmitting packets and not enabled any other peripherals
( UART’s,SMBUS,SPI).
I’m not able to resolve this problem. Pls someone help me..
Thankq u all.
Babu
 

Re: ethernet

the while(1) part seems fishy to me, If it is just the initialization program you might not need the while(1) part cuz you just initialize your network adapter settings once when you turn it on. if is a loop that received and transmits packets, then you have add function that when packet exists to send or be received do the appropriate thing and loops again. You might need an interruption to break the loop to do something else, and then return to the loop. I know my answer is not specific, but I am working on something like yours and I'm using ENC28J60 ethernet adapter and it works properly.
 

Re: ethernet

could you please check this next paragraph; It copied from

**broken link removed** V0.6
**broken link removed** V0.5

4.5.3 mn_ether_init

Description: Resets and initializes the Ethernet controller.
If the CP220x is selected as the Ethernet Controller, the following tasks are performed:
? The CP2200 is reset, and reset initializations are performed.
? Specific CP220x registers are read to verify presence of the Ethernet Controller.
? CP2200 Interrupts are enabled.
? The MAC address is programmed.
? The device is configured for half or full duplex operation, or auto-negotiation is started.
? The global link_status bit is set to indicate a good link or cleared to indicate that the device is not plugged into a network. The link_status bit is only valid after mn_ether_init() has been called for the first time. After this, it is always valid as long as Interrupt 0 and global interrupts are enabled.
? The global ether_reset bit is cleared. This bit will be set any time the CP220x enters, then exits the reset state. If ether_reset is ever set, the link status bit becomes invalid until mn_ether_init() is called. User code should not perform any network operations until the Ethernet controller is re-initialized. If this bit is frequently set, then check the board and verify that the power supply meets the current demands of the Ethernet controller.
? The global link_lost bit is set to indicate that the CP220x has lost link. It remains set if the link returns. This bit is cleared when mn_ether_init() succeeds.

Prototype: int mn_ether_init(byte, byte, byte);

Example Call: status = mn_ether_init(duplex_mode, num_autoneg_attempts, loopback);

Parameters: 1. duplex_mode—Selects Full-Duplex, Half-Duplex, or Auto-Negotiation. Can be one of the following values:
? FULL_DUPLEX—The Ethernet controller is configured to full-duplex mode.
? HALF_DUPLEX—The Ethernet controller is configured to half-duplex mode.
? AUTO_NEG—Auto-Negotiation selects between full-duplex and half-duplex modes.
2. num_autoneg_attempts—Specifies the number of times to attempt autonegotiation. If set to 0,
and autonegotiation is enabled, it will not return until autonegotiation is successful.
3. loopback—Set to TRUE to enable internal loopback. Set to FALSE to disable internal loopback.

Return Value: If successful, returns FULL_DUPLEX or HALF_DUPLEX. Otherwise, returns one of the following negative error codes:
? INVALID_DUPLEX_MODE — A duplex mode other than the three allowed values was passed in parameter 1.
? INVALID_MAC_ADDRESS — Returned if the MAC address is FF:FF:FF:FF:FF:FF.
? LINK_FAIL — A valid link was not detected. The global link_status bit can now be polled to determine when the Ethernet controller has been plugged into a network.
? ETHER_INIT_ERROR — A hardware error has occurred.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…