DP83815,DP83816. AN-1351 MAC Address Programming for DP83816 MacPHYTER-II and DP83815. MacPHYTER. Literature Number: SNLA070



Similar documents
LM5030 LM5030 Application: DC - DC Converter Utilizing the Push-Pull Topology

Application Note AN107

LM556 LM556 Dual Timer

Design Note DN304. Cebal CCxxxx Development Tools USB Driver Installation Guide By Åsmund B. Bø. Keywords. 1 Introduction

LM709 LM709 Operational Amplifier

54LS174,54LS175,DM54LS174,DM54LS175, DM74LS174,DM74LS175

AMC1100: Replacement of Input Main Sensing Transformer in Inverters with Isolated Amplifier

APPLICATION NOTE BUILDING A QAM MODULATOR USING A GC2011 DIGITAL FILTER CHIP

Data sheet acquired from Harris Semiconductor SCHS078C -- Revised October 2003

Importing a SPICE NetList Into TINA9-TI

LM388 LM W Audio Power Amplifier

Providing Continuous Gate Drive Using a Charge Pump

Analysis of Power Supply Topologies for IGBT Gate Drivers in Industrial

SDLS068A DECEMBER 1972 REVISED OCTOBER Copyright 2001, Texas Instruments Incorporated

DS8907 DS8907 AM/FM Digital Phase-Locked Loop Frequency Synthesizer

ZigBee Sensor Monitor SWRU157D 2008 Low-Power RF

Ultrasonic Sensing Basics for Liquid Level Sensing, Flow Sensing, and Fluid

Using C to Access Data Stored in Program Memory on the TMS320C54x DSP

Evaluating the complex configuration options of the Texas Instruments advanced fuel gauges can be

White Paper on Decision of Make vs. Buy of ISM RF Module Written by Bruce Ulrich October 2006

AN-1963 IEEE 1588 Synchronization Over Standard Networks Using the

LM1851 LM1851 Ground Fault Interrupter

LM138,LM338. LM138/LM338 5-Amp Adjustable Regulators. Literature Number: SNVS771A

SDLS940A MARCH 1974 REVISED MARCH Copyright 1988, Texas Instruments Incorporated

Data sheet acquired from Harris Semiconductor SCHS067B Revised July 2003

Data sheet acquired from Harris Semiconductor SCHS087D Revised October 2003

TRF7960 Evaluation Module ISO Host Commands

AN-1405 DP83848 Single 10/100 Mb/s Ethernet Transceiver Reduced Media Independent Interface (RMII ) Mode

TI and ibiquity Introduce Industry s Lowest Cost Single-Chip AM/FM and HD Radio Baseband John Gardner Digital Radio Marketing Manager

Design Note DN041. Using CC253X or CC254X with Dipole PCB Antennas. Keywords. 1 Introduction. By Espen Wium CC2530 CC2531 CC2533 CC2540 CC2541

Design Note DN004. Folded Dipole Antenna for CC25xx By Audun Andersen. Keywords. 1 Introduction CC2500 CC2550 CC2510 CC2511

DC/DC LED Lighting Developer s Kit Hardware

LMS8117A LMS8117A 1A Low-Dropout Linear Regulator

Application Report. 1 Description of the Problem. Jeff Falin... PMP Portable Power Applications ABSTRACT

TVP5146 SCART and OSD

Data sheet acquired from Harris Semiconductor SCHS020C Revised October 2003

TVP51471M1 VBI Quick Start

TL081 TL081 Wide Bandwidth JFET Input Operational Amplifier

AN-225 IC Temperature Sensor Provides Thermocouple Cold-Junction

Wireless Subwoofer TI Design Tests

AN-1733 Load Transient Testing Simplified

Using Code Coverage and Multi-event Profiler in Code Composer Studio v2.3 for Robustness and Efficiency Analyses


with Ultra-Fast Transient Response and High Light-Load Efficiency

MM58274C MM58274C Microprocessor Compatible Real Time Clock

Multi-Transformer LED TV Power User Guide. Anderson Hsiao

RF37S114 Tag-it HF-I Type 5 NFC, ISO/IEC Transponder, 4 mm 4 mm

Thumbus2300. User's Guide. 1 Introduction. 1.1 Features. 1.2 Kit Contents

AN-1900 LM3150 Evaluation Boards

Smart Codec Features in TMS320DM365

AN-311 Theory and Applications of Logarithmic Amplifiers

Texas Instruments. FB PS LLC Test Report HVPS SYSTEM AND APPLICATION TEAM REVA

Calculating Gain for Audio Amplifiers

Transcoding with TI s DaVinci Technology Drives Video Market Evolution

Application Report. 1 Introduction. 2 Resolution of an A-D Converter. 2.1 Signal-to-Noise Ratio (SNR) Harman Grewal... ABSTRACT

Data sheet acquired from Harris Semiconductor SCHS049C Revised October 2003


Programming the On-Chip Flash Memory in a Stellaris Microcontroller. Application Note. Copyright Texas Instruments

Design Note DN002. Practical Sensitivity Testing By Morten Engjom. Keywords. 1 Introduction. Receiver Testing Sensitivity

AN-1862 Reducing Radiated Emissions in Ethernet 10/100 LAN Applications

CD4071B Quad 2-Input OR Gate CD4072B Dual 4-Input OR Gate CD4075B Triple 3-Input OR Gate

TrxEB RF PER Test Software Example. User s Guide SWRU296

Using C to Access Data Stored in Program Space Memory on the TMS320C24x DSP

6 Output With 1 kω in Series Between the Output and Analyzer Output With RC Low-Pass Filter (1 kω and 4.7 nf) in Series Between the Output

LM2900,LM3301,LM3900. LM2900/LM3900/LM3301 Quad Amplifiers. Literature Number: SNOSBV6

TVP5146 VBI Quick Start

µa7800 SERIES POSITIVE-VOLTAGE REGULATORS

How To Fix An Lmx9838 Bluetooth Serial Port Module With Bluetooth (Bluetooth 2) From A Bluetooth Bluetooth 4.2 Device With A Bluembee 2.2 Module

LM5025,LM5026,LM5034 Operation and Benefits of Active-Clamp Forward Power Converters

ORDERING INFORMATION. TOP-SIDE MARKING PDIP N Tube SN74LS07N SN74LS07N PACKAGE. SOIC D Tape and reel SN74LS07DR

Controlling TAS5026 Volume After Error Recovery

SN54165, SN54LS165A, SN74165, SN74LS165A PARALLEL-LOAD 8-BIT SHIFT REGISTERS

LMC835 LMC835 Digital Controlled Graphic Equalizer

Optical Implementation Using IEEE-1394.b

Filter Design in Thirty Seconds

Designing Gain and Offset in Thirty Seconds

AN-1826 Extending the Reach of a FPD-Link II Interface With Cable Drivers and Equalizers

Demystifying digital signal processing (DSP) programming: The ease in realizing implementations with TI DSPs

The main goal of this tutorial is to get familiar with SmartRF Studio 7: Learn how it works and what it can do.

AN-662 COP800 Based Automated Security/Monitoring System. Literature Number: SNOA146

LM2747,LM3100,LM5035 Synchronous Rectification in High-Performance Power Converter Design

Bluetooth Low Energy CC2540 Mini Development Kit User s Guide

DP8573A DP8573A Real Time Clock (RTC)

Demystify DSI I/F. Application Report ABSTRACT

LM3444 MR16 Boost Reference Design for Non-Dimming & Dimming LED Applications

Standard Linear & Logic Semiconductor Marking Guidelines

V OUT. I o+ & I o- (typical) 2.3A & 3.3A. Package Type

High-voltage reinforced isolation:

PACKAGE OPTION ADDENDUM

RETRIEVING DATA FROM THE DDC112

LM4540 LM4540 AC '97 Codec with National 3D Sound

CUSTOM GOOGLE SEARCH PRO. User Guide. User Guide Page 1

EEPROM PROGRAMMING FOR PCIe UARTs

HF Antenna Cookbook. Technical Application Report March Radio Frequency Identification Systems

Application Report AN01286 May 2012

How To Close The Loop On A Fully Differential Op Amp

Motor Speed Measurement Considerations When Using TMS320C24x DSPs

August 2001 PMP Low Power SLVU051

description V CC A CLR BO CO LOAD C D B Q B Q A DOWN UP Q C Q D GND D OR N PACKAGE (TOP VIEW) SDFS031A D3693, JANUARY 1991 REVISED OCTOBER 1993

LM3203,LM3204,LM3205 Optimizing RF Power Amplifier System Efficiency Using DC-DC Converters

Transcription:

DP83815,DP83816 AN-1351 MAC Address Programming for DP83816 MacPHYTER-II and DP83815 MacPHYTER Literature Number: SNLA070

MAC Address programming for DP83816 MacPHYTER II and DP83815 MacPHYTER 1.0 Scope This Application Note explains what a MAC (Media Access Control) Address is, how to obtain one, and finally how to program it into the DP83816 MacPHYTER TM II and DP83815 MacPHYTER TM devices. For programming the address, there are two possible methods which the document covers. But first let s define what a MAC Address is. 2.0 MAC Address definition A MAC (Media Access Control) address is the unique hardware or physical address of a device connected to a network. The MAC address uniquely identifies each node on a network. Specifically, in Ethernet, the MAC address is known as the Ethernet Address, which is the unique ID serial number of the Ethernet device in one's computer. MAC Addresses are used in a Local Area Network (LAN) by computers to communicate with each other. More generally this is a standardized data link layer (layer 2) address that is required for every port or device that connects to a LAN. Other devices in the network use these addresses to locate specific ports in the network and to create and update routing tables and data structures. MAC addresses are 6 bytes long and are controlled by the IEEE. They consist of a 48-bit hexadecimal (hex) number (12 characters), of the form XX-XX-XX-XX-XX-XX, where the X's are either digits or letters from A-F. The 24 most significant bits of the address are also known as the Organizationally Unique Identifier (OUI) or "company_id". When requesting a MAC address, most organizations will have a fixed unique OUI assigned to them. This is then concatenated with another 24 bits to form a unique MAC address also known as a hardware address, MAC-layer address or physical address. The National Semiconductor Corporation (NSC) 24-bit assigned OUI in hex format is: 08-00-17 An example of a NSC MAC Address in hex format is: 08-00-17-0B-62-35 3.0 Obtaining a MAC Address To obtain a MAC address for your organization, please refer to the following IEEE links: http://standards.ieee.org/regauth/oui/forms/ http://standards.ieee.org/regauth/oui/index.shtml National Semiconductor is a registered trademark of National Semiconductor Corporation. MacPHYTER is a trademark of National Semiconductor Corporation. National Semiconductor Application Note 1351 November 2004 4.0 Programming the MAC Address On the DP83816 and DP83815, the MAC address can be programmed into the device using either one of two methods. In the first method, the MAC address is first programmed into the EEPROM which is then loaded into the device. In the second method, the MAC address is programmed directly into the device by using its RFCR (Receive Filter/ Match Control Register - offset 48h) and RFDR (Receive Filter/Match Data Register - offset 4Ch) registers. The use of either method depends on the target application of the device (see Section 5.0). 4.1 USING THE EEPROM The 1st method involves converting the MAC address into a certain format, so that it can be loaded from the EEPROM into the device. After the MAC Address is converted, it is programmed into the EEPROM s corresponding register bits, shown in Table 1. When an EEPROM load occurs, the address is read and placed into the Perfect Match Register (PMATCH) of the device, also shown in Table 1. TABLE 1. EEPROM register address / bit(s) PMATCH bit(s) 0006h / bit [0] PMATCH [0] 0007h / bits [15:0] PMATCH [1:16] 0008h / bits [15:0] PMATCH [17:32] 0009h / bits [15:1] PMATCH [33:47] An EEPROM load automatically takes place when the device is powered up. Additionally, a reload or a manual load of the EEPROM can be forced or initiated by setting bit 2 of PTSCR (PCI Test Control Register - offset 0Ch). Section 4.1.1 explains how the conversion is done. 4.1.1 MAC address conversion Consider the following MAC Address in hex format: 08-00-17-0B-62-35 where Octet 0 or the Most Significant Byte (MSB) is 08h, and Octet 5 or the Least Significant Byte (LSB) is 35h, as shown in Table 2. TABLE 2. Octet 0 Octet 1 Octet 2 Octet 3 Octet 4 Octet 5 08 00 17 0B 62 35 MAC Address programming for DP83816 MacPHYTER II and DP83815 MacPHYTER AN-1351 2004 National Semiconductor Corporation www.national.com

AN-1351 Table 3 shows the MAC address octets converted into binary by listing out each bit value. TABLE 3. Octet bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Octet 0 0 0 0 0 1 0 0 0 Octet 1 0 0 0 0 0 0 0 0 Octet 2 0 0 0 1 0 1 1 1 Octet 3 0 0 0 0 1 0 1 1 Octet 4 0 1 1 0 0 0 1 0 Octet 5 0 0 1 1 0 1 0 1 In Table 4, the orientation of the bits is swapped in each octet as such: TABLE 4. Octet bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Octet 0 0 0 0 1 0 0 0 0 Octet 1 0 0 0 0 0 0 0 0 Octet 2 1 1 1 0 1 0 0 0 Octet 3 1 1 0 1 0 0 0 0 Octet 4 0 1 0 0 0 1 1 0 Octet 5 1 0 1 0 1 1 0 0 Finally all the bits are shifted to the left by 1 and mapped to the PMATCH (PM) register as shown in Table 5: TABLE 5. PM bits bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 [0] 0 [1:8] 0 0 1 0 0 0 0 0 [9:16] 0 0 0 0 0 0 0 1 [17:24] 1 1 0 1 0 0 0 1 [25:32] 1 0 1 0 0 0 0 0 [33:40] 1 0 0 0 1 1 0 1 [41:47] 0 1 0 1 1 0 0 An excel sheet that does the above conversion calculations can be requested online through the following link: http://www.national.com/feedback/newfeed.nsf/techsupport?openform Alternatively, NSC s DOS Console Diagnostic utility, used to program the EEPROM registers including the MAC address, can be downloaded at: http://www.national.com/appinfo/networks/files/diag_exec.zip 4.1.2 EEPROM Programming To program the EEPROM, one of two methods are available. Either using an EEPROM programmer or using the DP83816 (or DP83815) itself to do the programming. In the DP83816 (or DP83815), the MEAR (EEPROM Access Register - offset 08h) controls the EEPROM pins on the device. MEAR[3] (EESEL: EEPROM Chip Select bit) controls the value of the EESEL pin (pin 128). MEAR[2] (EECLK: EEPROM Serial Clock bit) controls the value of the EECLK pin (pin 2). MEAR [1] (EEDO: EEPROM Data Out bit) returns the current state of the EEDO pin (pin 138). MEAR [0] (EEDI: EEPROM Data In bit) controls the value of the EEDI pin (pin 1). An example of using those bits is as follows: write 00000008h to MEAR ** Chip select high write 00000008h to MEAR ** CLK LOW and Data in 0 write 0000000Ch to MEAR ** CLK HIGH and Data out 0 write 00000009h to MEAR ** CLK LOW and Data in 1 write 0000000Eh to MEAR ** CLK HIGH and Data out 1 write 00000000h to MEAR ** Chip select low Please refer to sec. 4.2.3 in the datasheet for more details on the MEAR register. Appendix A contains sample C++ code showing how the EEPROM is accessed through the device. This is a subset of the Diag utility code available at the following web link: http://www.national.com/appinfo/networks/macphyter2.html under DOS Console Diagnostic (Object and Source files). The octets are then converted back to hex format and assigned into the proper EEPROM locations as shown in Table 6: EEPROM register address / bits TABLE 6. PMATCH bit(s) 0006h / bit [0] PMATCH [0] 0 0007h / bits [15:0] PMATCH [1:16] 2001 0008h / bits [15:0] PMATCH [17:32] D1A0 0009h / bits [15:0] (assuming bit 0 = 0) PMATCH [33:47] Converted MAC Address 8D58 4.1.3 Reference EEPROM Please use the FM93C46 EEPROM, referenced in the DP83815 and DP83816 datasheets, or a similar part. This EEPROM has a MICROWIRE Synchronous Bus interface and uses a special instruction set to communicate with the device. www.national.com 2

4.2 USING RFCR AND RFDR The 2nd method uses the RFCR and RFDR registers to write the MAC address into the device as shown in the example below: 1) Consider the same MAC Address in hex format: 08-00-17-0B-62-35 where Octet 0 or the Most Significant Byte (MSB) is 08h, and Octet 5 or the Least Significant Byte (LSB) is 35h, as shown in Table 2. TABLE 7. Octet 0 Octet 1 Octet 2 Octet 3 Octet 4 Octet 5 08 00 17 0B 62 35 5.0 Summary The first method, using an EEPROM, is targeted for applications that use generic, non-unique software found in most applications that usually do not require any software modifications. The second method, using the RFCR and RFDR registers, targets applications/systems that require unique software codes for each device. Since the IEEE standards require every single node to have a unique MAC address, the application will define the optimal programming method to be used. AN-1351 2) To program the address into the PMATCH register: write 0000h to RFCR (offset 48h) (this selects the appropriate internal receive filter for Octets 1-0) write 0008h (Octets 1-0) to RFDR (offset 4Ch) write 0002h to RFCR (offset 48h) (this selects the appropriate internal receive filter for Octets 3-2) write 0B17h (Octets 3-2) to RFDR (offset 4Ch) write 0004h to RFCR (offset 48h) (this selects the appropriate internal receive filter for Octets 5-4) write 3562h (Octets 5-4) to RFDR (offset 4Ch) 3) To read the address from the device: write 0000h to RFCR (offset 48h) read RFDR (offset 4Ch), this will give Octets 1-0 of the MAC address (flip them to read Octets 0-1) write 0002h to RFCR (offset 48h) read RFDR (offset 4Ch), this will give Octets 3-2 of the MAC address (flip them to read Octets 2-3) write 0004h to RFCR (offset 48h) read RFDR (offset 4Ch), this will give Octets 5-4 of the MAC address (flip them to read Octets 4-5) Note that the MAC address is read out as such: 00-08-0B-17-35-62 and each set of octets has to be properly flipped so the actual address, 08-00-17-0B-62-35, can be obtained. Since the RFCR also controls the receive filter, once the MAC address programming is complete, the RFCR needs to be re-configured with the correct settings for the receive operation to function properly. 3 www.national.com

AN-1351 *********************** * * EEPROM.C * * This is a collection of routines to interface to the EEPROM * for the MacPhyter Chip * ********************** Appendix A // Include files #include <dos.h> #include <time.h> #include <sys\timeb.h> #include <stdio.h> #include <conio.h> #include <memory.h> #include <time.h> #include "GLOBAL.H" #include "NICSTUFF.H" #include "PCIBIOS.H" // Function prototypes #include "FUNCTION.H" UINT16 eepromdefaultvalue[11] = ; 0xD008, // 0000h, Subsystem Vendor ID 0x0400, // 0001h, Subsystem Device ID 0x2CD0, // 0002h, Minimum Grant, Maximum Latency 0xCF82, // 0003h, Configuration/Power Management Stuff 0x0000, // 0004h, SecureOn Password 0x0000, // 0005h, SecureOn Password 0x0000, // 0006h, SecureOn Password 0x0000, // 0007h, Ethernet ID 0x0000, // 0008h, Ethernet ID 0x0000, // 0009h, Ethernet ID 0xA098 // 000Ah, WOL, Receive Filter/Match www.national.com 4

UINT32 OUID; // Organizationally Unique Identifier UINT32 startmacaddr; UINT32 endmacaddr; UINT32 currentmacaddr; AN-1351 // Globals extern unsigned short RegBase; extern unsigned short batchmode; extern UINT16 flip_16 (UINT16 us); * Function: DisplayEEPROM * Purpose:display EEPROM contents * Returns: void void DisplayEEPROM() int i=0; WORD value; for( i=0; i<0xc; i++ ) ReadEEWord( RegBase + MEAR, i, &value ); printf( "\n%01x= %04X ", i, value ); printf( "\n\n" ); * Function: ReadMACAddress * Purpose: load readable form of the MAC address * Returns: void void ReadMACAddress( UINT16 *nicaddress ) UINT32 i; UINT16 mask; 5 www.national.com

AN-1351 UINT16 word1 = 0; UINT16 word2 = 0; UINT16 word3 = 0; UINT16 word4 = 0; // // Read 16 bit words 6-9 from the EEProm. They contain the hardwares MAC // address in a rather cryptic format. // ReadEEWord( RegBase + MEAR, 0x06, &word1 ); ReadEEWord( RegBase + MEAR, 0x07, &word2 ); ReadEEWord( RegBase + MEAR, 0x08, &word3 ); ReadEEWord( RegBase + MEAR, 0x09, &word4 ); // // Decode the cryptic format into what we can use a word at a time. // nicaddress[ 0 ] = word1 & 1; nicaddress[ 1 ] = word2 & 1; nicaddress[ 2 ] = word3 & 1; i = 15; mask = 0x2; while ( i-- ) if ( word2 & 0x8000 ) nicaddress[ 0 ] = mask; word2 = word2 << 1; mask = mask << 1; i = 15; mask = 0x2; while ( i-- ) if ( word3 & 0x8000 ) nicaddress[ 1 ] = mask; www.national.com 6

word3 = word3 << 1; mask = mask << 1; AN-1351 i = 15; mask = 0x2; while ( i-- ) if ( word4 & 0x8000 ) nicaddress[ 2 ] = mask; word4 = word4 << 1; mask = mask << 1; * Function:WriteMACAddress * Purpose:Write readable form of the MAC address to EEPROM * Returns: 1 if FAIL, 0 if Succees int writemacaddress( unsigned *nicaddress ) UINT32 mask; UINT32 l; int nbits = 9; unsigned value, sixoff, nineoff, checksum = 0, word1, word2, word3; unsigned sword[4]; ReadEEWord( RegBase + MEAR, 0x06, &sixoff ); sixoff &= ~1; ReadEEWord( RegBase + MEAR, 0x09, &nineoff ); nineoff &= 1; word1 = nicaddress[ 0 ]; word2 = nicaddress[ 1 ]; word3 = nicaddress[ 2 ]; writeeeenable(); 7 www.national.com

AN-1351 value = sixoff; if( word1 & 1 ) value = 1; sword[0] = value; WriteEEWord( RegBase + MEAR, 0x06, value ); value = 0; l = 15; mask = 0x2; while( l-- ) if( word1 & 0x8000 ) value = mask; mask <<= 1; word1 <<= 1; if( word2 & 1 ) value = 1; sword[1] = value; WriteEEWord( RegBase + MEAR, 0x07, value ); value = 0; l = 15; mask = 0x2; while( l-- ) if( word2 & 0x8000 ) value = mask; mask <<= 1; word2 <<= 1; if( word3 & 1 ) value = 1; sword[2] = value; WriteEEWord( RegBase + MEAR, 0x08, value ); value = nineoff; l = 15; mask = 0x2; while( l-- ) if( word3 & 0x8000 ) value = mask; mask <<= 1; www.national.com 8

word3 <<= 1; AN-1351 sword[3] = value; WriteEEWord( RegBase + MEAR, 0x09, value ); writeeedisable(); for( l=0; l<4; l++ ) ReadEEWord( RegBase + MEAR, 6+l, &value ); if( value!= sword[l] ) printf( "\neeprom programming failed! Enter Alternate MAC address.\n" ); break; if (doeechecksum()) return 1; if (batchmode) return writemacfile(); return 0; int writeid( int ssid, BYTE vendev ) int idoffset = 0; // Calculate the offset: if (vendev == 'D') idoffset = 1; writeeeenable(); WriteEEWord( RegBase + MEAR, idoffset, ssid ); writeeedisable(); 9 www.national.com

AN-1351 return doeechecksum(); * Function: WriteEEWord * Purpose: write a 16-bit value into the specified eeprom location * Returns: void void WriteEEWord( unsigned short pmear, UINT32 wordoffset, UINT16 value ) UINT32 mask; UINT32 l; int nbits = 9; UINT32 invalue = (UINT32) value; outpd( RegBase + MEAR, 0 ); /* clock out CS low */ outpd( RegBase + MEAR, EECLK ); invalue = ((UINT32)( 0x0140 wordoffset) << 16 ) invalue; nbits = 25; mask = ((UINT32)1) << (nbits-1); while (nbits--) /* assert chip select, and setup data in */ l = ( invalue & mask )? EECS EEDI : EECS; outpd( RegBase + MEAR, l ); outpd( RegBase + MEAR, l EECLK ); mask >>= 1; www.national.com 10

// IOW32( mear, 0 ); /* terminate write */ outpd( RegBase + MEAR, 0 ); // terminate operation AN-1351 /* wait for operation to complete */ outpd( RegBase + MEAR, EECS ); /* assert CS */ outpd( RegBase + MEAR, EECS EECLK ); for (l = 0; l < 10; l++) if( inpd( RegBase + MEAR ) & EEDO ) break; outpd( RegBase + MEAR, 0 ); /* clock out CS low */ outpd( RegBase + MEAR, EECLK ); * Function: checksumcheck * Purpose: Use the EEBIST bit on MacPhyter to * validate the EEPROM checksum * Returns: 1 if FAIL, 0 if Succees int checksumcheck() unsigned long pcitestreg = EEBIST_EN; outpd( RegBase + PCITEST_CNTRL, EEBIST_EN ); while (pcitestreg & EEBIST_EN) pcitestreg = inpd( RegBase + PCITEST_CNTRL ); 11 www.national.com

AN-1351 if (inpd( RegBase + PCITEST_CNTRL ) & EEBIST_FAIL) printf( "\n!!warning: Checksum FAILED!\n" ); return( 1 ); else printf( "\neebist Test Passes!\n" ); return( 0 ); * Function: ReadEEWord * Purpose: Read 16-bit value from the specified location * Returns: void void ReadEEWord( unsigned short pmear, UINT32 offset, UINT16* peedata ) UINT16 value; outpd( RegBase + MEAR, 0 ); outpd( RegBase + MEAR, EECLK ); // clock out no chipselect eeput( (UINT32)(EEread offset), 9 ); value = eeget( 16 ); outpd( RegBase + MEAR, 0 ); // terminate read outpd( RegBase + MEAR, EECLK ); // clock out no chipselect *peedata = ( UINT16 )value; www.national.com 12

outpd( RegBase + MEAR, 0 ); // terminate read AN-1351 * Function: EEPUT * Purpose: Clock OUT data to EEPROM * Returns: void void eeput( UINT32 value, int nbits ) UINT32 mask = ((UINT32)1) << (nbits-1); UINT32 l; while( nbits-- ) // assert chip select, and setup data in l = ( value & mask )? EECS EEDI : EECS; outpd( RegBase + MEAR, l ); outpd( RegBase + MEAR, l EECLK ); mask >>= 1; * Function: EEGET * Purpose: Clock IN data from EEPROM * Returns: void UINT16 eeget( int nbits ) UINT16 mask = 1 << (nbits-1); UINT16 value = 0; while( nbits-- ) 13 www.national.com

AN-1351 // assert chip select, and clock in data outpd( RegBase + MEAR, EECS ); outpd( RegBase + MEAR, EECS EECLK ); if( inpd( RegBase + MEAR ) & EEDO ) value = mask; mask >>= 1; return( value ); * Function: WriteEeEnable * Purpose: ENABLE EEPROM Write Mode * Returns: void void writeeeenable() UINT32 mask; UINT32 l; int nbits = 9; // // Start the sequence with Chip Select 0 for a 4 microsecond cycle. // outpd( RegBase + MEAR, 0 ); outpd( RegBase + MEAR, EECLK ); mask = ((UINT32)1) << (nbits-1); while( nbits-- ) /* assert chip select, and setup data in */ www.national.com 14

l = ( 0x0130 & mask )? EECS EEDI : EECS; outpd( RegBase + MEAR, l ); outpd( RegBase + MEAR, l EECLK ); mask >>= 1; AN-1351 outpd( RegBase + MEAR, 0 ); // terminate operation //IOW32( mear, 0 ); /* clock out CS low */ outpd( RegBase + MEAR, EECLK ); * Function: WriteEEDisable * Purpose: Disable EEPROM write Mode * Returns: void void writeeedisable() UINT32 mask; UINT32 l; int nbits = 9; //ed->eeput( (uint32)eewritedisable, 9 ); nbits = 9; mask = ((UINT32)1) << (nbits-1); while( nbits-- ) /* assert chip select, and setup data in */ l = ( 0x0100 & mask )? EECS EEDI : EECS; outpd( RegBase + MEAR, l ); outpd( RegBase + MEAR, l EECLK ); mask >>= 1; outpd( RegBase + MEAR, 0 ); // terminate operation 15 www.national.com

AN-1351 * Function: doeechecksum() * Purpose: Read EEPROM contents, calculate checksum, * write it, verify the write and validate it. * Returns: 1 if FAIL, 0 if Succees int doeechecksum() int l; WORD value, checksum; unsigned char cslow, cshigh, cssum, csvals[ 11 ]; // Calculate Checksums: for( l=0; l<11; l++ ) ReadEEWord( RegBase + MEAR, l, &value ); cslow = value & 0xff; value >>= 8; cshigh = value & 0xff; csvals[ l ] = cslow + cshigh; // Calculate Checksums: cssum = 0; for( l=0; l<11; l++ ) cssum += csvals[ l ]; cssum += 0x55; checksum = (~cssum) + 1; checksum = ( checksum << 8 ) + 0x55; writeeeenable(); WriteEEWord( RegBase + MEAR, 0x0B, checksum ); writeeedisable(); ReadEEWord( RegBase + MEAR, 0xB, &value ); if (value!= checksum) www.national.com 16

printf( "\n!!warning Checksum not programmed correctly!\n" ); printf( "\n checksum: %04X actual: %04X", checksum, value ); AN-1351 if (checksumcheck()) // Invalid checksum return 1; outpd( RegBase + PCITEST_CNTRL, EELOAD_EN ); // Reload configuration information from EEPROM delay( 1 ); return 0; ***** * Function: WriteEeDefaults: * Purpose: Initialize the EEPROM without touching the * MAC address. * * Returns: 1 if FAIL, 0 if Succees * * The Following was taken from EPMON Programming script: * * eeprom 0 d008 # subsystem vendor * eeprom 1 0400 # subsys id * eeprom 2 2cd0 # min gnt, max lat * eeprom 3 cf82 # config stuff * eeprom 4 0000 # secure on pw stuff * eeprom 5 0000 # secure on pw stuff * eeprom 6 0000 # LSb is part of Ethernet ID * eeprom 7 2001 # Ethernet ID * eeprom 8 d1a1 # Ethernet ID * eeprom 9 $Loc9 # Ethernet ID * eeprom a a098 * eeprom b $value # checksum ******************* int writeeedefaults() FILE *stream; 17 www.national.com

AN-1351 char buf[120]; UINT16 eepromvalue[11]; UINT32 i; UINT16 value; unsigned char inputstring[25]; int nicaddress[3]; UINT16 Addressbit; // Read EEPROM values from file if the file exists, otherwise set as // default values if ((stream = fopen("eeprom.txt", "rt"))!= NULL) for (i = 0; i <= 0xA; i++) fgets(buf, sizeof(buf), stream); sscanf(buf, "%04X", &eepromvalue[i]); fclose(stream); else for (i = 0; i <= 0xA; i++) eepromvalue[i] = eepromdefaultvalue[i]; // Read subsystem ID's from file if the file exists, and convert the ID's // in readable form to the format that DP83815/816 uses if ((stream = fopen("subsysid.txt", "rt"))!= NULL) for (i = 0; i <= 1; i++) fgets(buf, sizeof(buf), stream); sscanf(buf, "%04X", &value); eepromvalue[i] = flip_16(value); fclose(stream); www.national.com 18

writeeeenable(); // Write into EEPROM for (i = 0; i <= 0xA; i++) if (i <=5 i == 0xA) WriteEEWord( RegBase + MEAR, i, eepromvalue[i] ); AN-1351 // Save the least significant bit for the MAC address: ReadEEWord( RegBase + MEAR, 0x6, &Addressbit ); Addressbit &= 1; WriteEEWord( RegBase + MEAR, 0x6, Addressbit ); // Clear the least significant bit for the MAC address: ReadEEWord( RegBase + MEAR, 0x9, &Addressbit ); Addressbit &= 0xfffe; WriteEEWord( RegBase + MEAR, 0x9, Addressbit ); writeeedisable(); // Check if the EEPROM values are written correctly for (i = 0; i <= 0xA; i++) if (i <= 5 i == 0xA) ReadEEWord( RegBase + MEAR, i, &value ); if (value!= eepromvalue[i]) printf("eeprom values are not written correctly!\n"); return 1; // Write MAC address also if it is in batch mode and the MAC address // file exists if (batchmode) 19 www.national.com

AN-1351 if (readmacfile(inputstring)) return 1; nicaddress[0] = (UINT16)*( inputstring+2 ); nicaddress[0] = (nicaddress[0] << 8) + (UINT16)*( inputstring ); nicaddress[1] = (UINT16)*( inputstring+6 ); nicaddress[1] = (nicaddress[1] << 8) + (UINT16)*( inputstring+4 ); nicaddress[2] = (UINT16)*( inputstring+10 ); nicaddress[2] = (nicaddress[2] << 8) + (UINT16)*( inputstring+8 ); if (writemacaddress(nicaddress)) return 1; // Call findnic routine again to display the new address if (findnic(true)) return 1; if (currentmacaddr == endmacaddr) return 1; return 0; else return doeechecksum(); * Function: readmacfile * Purpose:Opens up a file, retrieves MacAddress, * increments it and returns the new number. * Returns: 1 = FAIL; 0 = SUCCESS; loads the input; int readmacfile( unsigned char *inputstring ) www.national.com 20

FILE *stream; char buf[120]; AN-1351 // Open up MACADDR.TXT file in the cwd if ((stream = fopen("macaddr.txt", "rt"))!= NULL) fgets(buf, sizeof(buf), stream); sscanf(buf, "%06lX%06lX", &OUID, &startmacaddr); fgets(buf, sizeof(buf), stream); sscanf(buf, "%06lX%06lX", &OUID, &endmacaddr); fgets(buf, sizeof(buf), stream); sscanf(buf, "%06lX%06lX", &OUID, &currentmacaddr); fclose(stream); else printf("\nunable to open up MACADDR.TXT in current working directory."); return 1; // Check if the MAC address is valid if (((OUID == 0x000000) && (currentmacaddr == 0x000000)) ((OUID == 0xFFFFFF) && (currentmacaddr == 0xFFFFFF))) printf("\ninvalid MAC address: %06lX%06lX", OUID, currentmacaddr); return 1; else if ((currentmacaddr < startmacaddr) (currentmacaddr > endmacaddr)) printf("\nmac address is out of the range!"); return 1; sscanf(buf, "%02X%02X%02X%02X%02X%02X", inputstring, (inputstring+2), (inputstring+4), (inputstring+6), (inputstring+8), (inputstring+10) 21 www.national.com

AN-1351 ); return 0; * Function: writemacfile * Purpose:Opens up a file, writes the new number. * Returns: 1 = FAIL; 0 = SUCCESS; loads the input; int writemacfile(void) FILE *stream; // Stop program if current MAC address reachs the end MAC address if (currentmacaddr < endmacaddr) currentmacaddr++; // Open up MACADDR.TXT file in the cwd if ((stream = fopen("macaddr.txt", "wt"))!= NULL) fprintf(stream, "%06lX%06lX\t\t// Start MAC Address\n", OUID, startmacaddr); fprintf(stream, "%06lX%06lX\t\t// End MAC Address\n", OUID, endmacaddr); fprintf(stream, "%06lX%06lX\t\t// Current MAC Address\n", OUID, currentmacaddr); fclose(stream); else printf("\nunable to open up MACADDR.TXT in current working directory."); return 1; else printf("\nend MAC address is reached.\n"); return 0; www.national.com 22

National does not assume any responsibility for use of any circuitry described, no circuit patent licenses are implied and National reserves the right at any time without notice to change said circuitry and specifications. For the most current product information visit us at www.national.com. LIFE SUPPORT POLICY NATIONAL S PRODUCTS ARE NOT AUTHORIZED FOR USE AS CRITICAL COMPONENTS IN LIFE SUPPORT DEVICES OR SYSTEMS WITHOUT THE EXPRESS WRITTEN APPROVAL OF THE PRESIDENT AND GENERAL COUNSEL OF NATIONAL SEMICONDUCTOR CORPORATION. As used herein: 1. Life support devices or systems are devices or systems which, (a) are intended for surgical implant into the body, or (b) support or sustain life, and whose failure to perform when properly used in accordance with instructions for use provided in the labeling, can be reasonably expected to result in a significant injury to the user. BANNED SUBSTANCE COMPLIANCE www.national.com National Semiconductor Americas Customer Support Center Email: new.feedback@nsc.com Tel: 1-800-272-9959 National Semiconductor Europe Customer Support Center Fax: +49 (0) 180-530 85 86 Email: europe.support@nsc.com Deutsch Tel: +49 (0) 69 9508 6208 English Tel: +44 (0) 870 24 0 2171 Français Tel: +33 (0) 1 41 91 8790 2. A critical component is any component of a life support device or system whose failure to perform can be reasonably expected to cause the failure of the life support device or system, or to affect its safety or effectiveness. National Semiconductor certifies that the products and packing materials meet the provisions of the Customer Products Stewardship Specification (CSP-9-111C2) and the Banned Substances and Materials of Interest Specification (CSP-9-111S2) and contain no Banned Substances as defined in CSP-9-111S2. National Semiconductor Asia Pacific Customer Support Center Email: ap.support@nsc.com National Semiconductor Japan Customer Support Center Fax: 81-3-5639-7507 Email: jpn.feedback@nsc.com Tel: 81-3-5639-7560 MAC Address programming for DP83816 MacPHYTER II and DP83815 MacPHYTER AN-1351

IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete. All products are sold subject to TI s terms and conditions of sale supplied at the time of order acknowledgment. TI warrants performance of its hardware products to the specifications applicable at the time of sale in accordance with TI s standard warranty. Testing and other quality control techniques are used to the extent TI deems necessary to support this warranty. Except where mandated by government requirements, testing of all parameters of each product is not necessarily performed. TI assumes no liability for applications assistance or customer product design. Customers are responsible for their products and applications using TI components. To minimize the risks associated with customer products and applications, customers should provide adequate design and operating safeguards. TI does not warrant or represent that any license, either express or implied, is granted under any TI patent right, copyright, mask work right, or other TI intellectual property right relating to any combination, machine, or process in which TI products or services are used. Information published by TI regarding third-party products or services does not constitute a license from TI to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property of the third party, or a license from TI under the patents or other intellectual property of TI. Reproduction of TI information in TI data books or data sheets is permissible only if reproduction is without alteration and is accompanied by all associated warranties, conditions, limitations, and notices. Reproduction of this information with alteration is an unfair and deceptive business practice. TI is not responsible or liable for such altered documentation. Information of third parties may be subject to additional restrictions. Resale of TI products or services with statements different from or beyond the parameters stated by TI for that product or service voids all express and any implied warranties for the associated TI product or service and is an unfair and deceptive business practice. TI is not responsible or liable for any such statements. TI products are not authorized for use in safety-critical applications (such as life support) where a failure of the TI product would reasonably be expected to cause severe personal injury or death, unless officers of the parties have executed an agreement specifically governing such use. Buyers represent that they have all necessary expertise in the safety and regulatory ramifications of their applications, and acknowledge and agree that they are solely responsible for all legal, regulatory and safety-related requirements concerning their products and any use of TI products in such safety-critical applications, notwithstanding any applications-related information or support that may be provided by TI. Further, Buyers must fully indemnify TI and its representatives against any damages arising out of the use of TI products in such safety-critical applications. TI products are neither designed nor intended for use in military/aerospace applications or environments unless the TI products are specifically designated by TI as military-grade or "enhanced plastic." Only products designated by TI as military-grade meet military specifications. Buyers acknowledge and agree that any such use of TI products which TI has not designated as military-grade is solely at the Buyer's risk, and that they are solely responsible for compliance with all legal and regulatory requirements in connection with such use. TI products are neither designed nor intended for use in automotive applications or environments unless the specific TI products are designated by TI as compliant with ISO/TS 16949 requirements. Buyers acknowledge and agree that, if they use any non-designated products in automotive applications, TI will not be responsible for any failure to meet such requirements. Following are URLs where you can obtain information on other Texas Instruments products and application solutions: Products Applications Audio www.ti.com/audio Communications and Telecom www.ti.com/communications Amplifiers amplifier.ti.com Computers and Peripherals www.ti.com/computers Data Converters dataconverter.ti.com Consumer Electronics www.ti.com/consumer-apps DLP Products www.dlp.com Energy and Lighting www.ti.com/energy DSP dsp.ti.com Industrial www.ti.com/industrial Clocks and Timers www.ti.com/clocks Medical www.ti.com/medical Interface interface.ti.com Security www.ti.com/security Logic logic.ti.com Space, Avionics and Defense www.ti.com/space-avionics-defense Power Mgmt power.ti.com Transportation and Automotive www.ti.com/automotive Microcontrollers microcontroller.ti.com Video and Imaging www.ti.com/video RFID OMAP Mobile Processors Wireless Connectivity www.ti-rfid.com www.ti.com/omap www.ti.com/wirelessconnectivity TI E2E Community Home Page e2e.ti.com Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright 2011, Texas Instruments Incorporated