The 6-byte MAC address provides addressing for the Media Access Control protocol layer of the TCP/IP stack. MAC addresses are permanent addresses tied to hardware. Blocks of MAC addresses are sold to organizations and individuals by the IEEE; if you aren't using a Microchip device with a built-in MAC address, you will need to purchase one of these blocks to assign MAC addresses to your products.
The MAC address is defined in the firmware configuration header "TCPIPConfig.h." There are six macros that must be defined in this file to set the MAC address. They are:
Macro |
Sample Value |
MY_DEFAULT_MAC_BYTE1 |
(0x00) |
MY_DEFAULT_MAC_BYTE2 |
(0x04) |
MY_DEFAULT_MAC_BYTE3 |
(0xA3) |
MY_DEFAULT_MAC_BYTE4 |
(0x00) |
MY_DEFAULT_MAC_BYTE5 |
(0x00) |
MY_DEFAULT_MAC_BYTE6 |
(0x00) |
Each of these macros represents a byte of the MAC address (note that 00:04:A3:xx:xx:xx is the block of MAC addresses reserved for Microchip products). Once you obtain your block of addresses, you will need to specify a unique address for every device you produce. The "TCP/IP Demo App" demonstration project describes a method for using Microchip's MPLAB PM3 programmer to serially program a range of MAC addresses into multiple parts without recompiling your project.
The ENCX24J600, MRF24WB0M, MRF24WG0M and PIC32MX7XX/6XX feature a pre-programmed MAC address (from Microchip's address block). If you are using either of these part families in your project, you can define your MAC address as "00:04:A3:00:00:00" and the stack will automatically use the part's pre-programmed address for your application.
Microchip also provides a family of EEPROMs that include a unique, pre-programmed EUI-48 (MAC) or EUI-64 address. When using one of these devices, you can write your AppConfig initialization code so it will obtain the device's MAC address from one of these EEPROMs instead of the default MAC address macros.