Fez Cobra II + Enc28 = slow ping

Anyone can explain me why the ethernet (Enc28 module connected to my Fez cobra II ECO board) is so slow?

(see first image, duration up to 400 ms)

No ethernet switch problem, pinging another device in my LAN result as follow:

(see second image, duration <1 ms)

Lastest firmware updated.

I’ve a simple test program:

    public class Program
    {
        static EthernetENC28J60 _enc;
        static bool _hasAddress;
        private static bool _available;

        public static void Main()
        {
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;

            _enc = new EthernetENC28J60(SPI.SPI_module.SPI2, G120.P1_10, G120.P2_11, G120.P1_9);
            _enc.Open();
            _enc.EnableStaticIP("192.168.2.203", "255.255.255.0", "192.168.2.6");
            _enc.EnableStaticDns(new[] { "192.168.1.1" });

            while (!_hasAddress || !_available)
            {
                Debug.Print("Initializing");
                Thread.Sleep(100);
            }

            while (true)
            {
                Thread.Sleep(1000);
            }
        }

        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Debug.Print("Network available: " + e.IsAvailable.ToString());
            _available = e.IsAvailable;
        }
        static void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
        {
            Debug.Print("The network address has changed.");
            _hasAddress = _enc.IPAddress != "0.0.0.0";
        }
    }

@ andre.m - Yes the reply time is high.
The configuration is simple: cobra->switch->PC (icmp reply time high)
PC->switch->switch->other PC (icmp reply time <1ms so I’m sure that the problem is not the switch between cobra and PC)

Firmware version 4.3.7.10

Gateway setted (192.168.2.6) but not used in this case because a simple lan connection

The code above is the only code that run on the board (a simple test program)

@ Cybernox - Are you testing with the debugger attached?

Yes, that’s important!
If you don’t have VisualStudio debugger running, disconnect the USB cable from the board.
A connected USB cable without any debugger connected slows down the board.
This is a bug in NETMF, which should be fixed in 4.4.x

@ Cybernox -
Hi, I can’t confirm your observation, but your constructor does not work for me.
The following code works for the ENC28 module on Cobra II WiFi Socket 6.
Ping Response time 3 ms for the first ping, then 1 ms (Debugger attached)


// Example for Ethernet ENC28 Module on FEZ Cobra II WiFi on Gageteer Socket 6

//References:
// GHI.Networking
// GHI.Pins
// GHIElectronics.Gadgeteer.FEZCobraIIEco
// Microsoft.Spot.Hardware
// Microsoft.SPOT.Net

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.Net.NetworkInformation;
using GHI.Networking;
using GHI.Pins;

namespace Cobra_II_NETMF_ENC28
{
    public class Program
    {
        static EthernetENC28J60 _enc;
        static bool _hasAddress;
        private static bool _available;
        public static void Main()
        {
            NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;

            // this constructor does not work (seems to be for Cobra II Net Mainboard)
            //_enc = new EthernetENC28J60(SPI.SPI_module.SPI2, G120.P1_10, G120.P2_11, G120.P1_9);

            // these two constructors work
            //_enc = new EthernetENC28J60(SPI.SPI_module.SPI2, (Cpu.Pin)(32 + 17)
            //, (Cpu.Pin)(64 + 21), (Cpu.Pin)(32 + 14), 8000);
            _enc = new GHI.Networking.EthernetENC28J60(Microsoft.SPOT.Hardware.SPI.SPI_module.SPI2
                , GHI.Pins.FEZCobraII.Socket6.Pin6, GHI.Pins.FEZCobraII.Socket6.Pin3
                , GHI.Pins.FEZCobraII.Socket6.Pin4);
            _enc.Open();
            _enc.EnableStaticIP("192.168.1.52", "255.255.255.0", "192.168.1.1");
            _enc.EnableStaticDns(new[] { "192.168.1.1" });

            while (!_hasAddress || !_available)
            {
                Debug.Print("Initializing");
                Thread.Sleep(100);
            }
            while (true)
            {
                Thread.Sleep(1000);
            }
        }

        static void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
        {
            Debug.Print("Network available: " + e.IsAvailable.ToString());
            _available = e.IsAvailable;
        }

        static void NetworkChange_NetworkAddressChanged(object sender, EventArgs e)
        {
            Debug.Print("The network address has changed.");
            _hasAddress = _enc.IPAddress != "0.0.0.0";
            Debug.Print("My IP is: " + _enc.IPAddress);
        }
    }
}

Problem solved! There was a mistake in ENC28 initialization code.
I’ve take the initialization code from [url]https://www.ghielectronics.com/docs/318/fez-cobra-ii-developers-guide[/url] but it’s wrong
After analizing the required pins of the ENC28 module connector (see [url]https://www.ghielectronics.com/catalog/product/333[/url]) and the schematic diagram of Fez Cobra 2 ([url]http://www.ghielectronics.com/downloads/schematic/FEZ_Cobra_II_SCH.pdf[/url]) I found that the correct initialization code is:


Now I can confirm that the ICMP reply times are the same of ones reported by @ RoSchmi

Thank you all
1 Like