Mac address on ENC28 Module not provided

Hi,

ist there no MAC-address provided to the ENC28-Module when purchased from GHI?
I’ve got some cerberus-boards with enc28-mods attached. If connected to my network with dhcp enabled they all get the same Ip-address. Do i have to get an address for every module?

Yes, you have to assign your own MAC address. Here’s some code I’m currently using.


private static readonly byte[] _macAddress = new byte[] { 0x00, 0x75, 0x65, 0xde, 0xac, 0xaa };
       

        private void InitializeNetwork_Dhcp()
        {
            try
            {
                var nis = NetworkInterface.GetAllNetworkInterfaces();

                if (nis == null || nis.Length == 0)
                {
                    throw new IndexOutOfRangeException("No network interface was found.  Make sure you have the ethernet firmware installed and a NIC attached.");
                }
                _ni = nis[0];
                _ni.PhysicalAddress = _macAddress;
                _ni.EnableDhcp();                

                // There's a bug in the current SDK.  If connection becomes available after startup then IPAddress does not seem to get populated.
                while (_ipAddress == "0.0.0.0")
                {
                    _ipAddress = _ni.IPAddress == "0.0.0.0" ? IPAddress.GetDefaultLocalAddress().ToString() : _ni.IPAddress;
 #if DEBUG
                    Debug.Print("Waiting for IP address..." + IPAddress.GetDefaultLocalAddress());
 #endif
                    Thread.Sleep(1000);
                }
 #if DEBUG
                Debug.Print("IP Address:" + _ipAddress);
 #endif
                UpdateDisplay("IP: " + _ipAddress);
            }
            catch (Exception exception)
            {
                throw new ArgumentException("Could not resolve host via DNS.", exception);
            }
        }

2 Likes

This is what I use if I need a MAC address:

1 Like

Thx Mike, that’s what I was looking for :slight_smile:

@ fp - Welcome to the community!

Thank you guys! I will try to change the mac-address with MFDeploy first.

The default mac-address of my cerberus boards is 00-04-a3-00-00-00. Is the first part the address-room of GHI, or could it happen, that I choose an address which is already taken by another device in the network?

ENC28’s don’t have allocated MAC addresses. Use the link Mike provided above, grab some addresses for your use and go crazy. I don’t think Cerb family chips have inbuilt Ethernet, meaning you’ll need to use code to set your MAC on each device (not MFDeploy).

Sure, it works with MFDeploy. Each one of my devices now gets a different ip-address.
I’ve used the link from mike to generate the addresses. But i want to avoid that there is another device in my network from another manufacturer, which has got the same mac-address.