Introduction. APPLICATION NOTE 712 DS80C400 Ethernet Drivers. Jun 06, 2003

Similar documents
ECE 274 Digital Logic. Digital Design. Datapath Components Registers. Datapath Components Register with Parallel Load

GRABLINKTM. FullTM. - DualBaseTM. - BaseTM. GRABLINK Full TM. GRABLINK DualBase TM. GRABLINK Base TM

Application Support. Product Information. Omron STI. Support Engineers are available at our USA headquarters from

Engineer To Engineer Note

INPUT CAPTURE WITH ST62 16-BIT AUTO-RELOAD TIMER

Avaya P460. Quick Start Guide. Important Information. Unpack the Chassis. Position the Chassis. Install the Supervisor Module and PSU

The Official IDENTITY SYSTEM. A Manual Concerning Graphic Standards and Proper Implementation. As developed and established by the

Safety Relay Unit G9SB

WE SERIES DIRECTIONAL CONTROL VALVES

SeSSION 9. This session is adapted from the work of Dr.Gary O Reilly, UCD. Session 9 Thinking Straight Page 1

ViaLiteHD RF Fibre Optic Link

VISUAL IDENTITY GUIDE

Explosion protected add-on thermostat

CPE 200L LABORATORY 2: DIGITAL LOGIC CIRCUITS BREADBOARD IMPLEMENTATION UNIVERSITY OF NEVADA, LAS VEGAS GOALS:

Panel-mounted Thermostats

Contents 2. Notations Used in This Guide 7. Introduction to Your Projector 8. Using Basic Projector Features 34. Setting Up the Projector 17

Corporate Logo Guidelines

Chapter 1: Introduction

Safety Relay Unit G9SB

A New Concept of Providing Telemetry Data in Real Time

Contents. English. English. Your remote control 2

Pitch I. I. Lesson 1 : Staff

Notations Used in This Guide

Before Reading. Introduce Everyday Words. Use the following steps to introduce students to Nature Walk.

Contents 2. Notations Used in This Guide 6. Introduction to Your Projector 7. Using Basic Projector Features 28. Setting Up the Projector 15

Contents 2. Notations Used in This Guide 6. Introduction to Your Projector 7. Using Basic Projector Features 30. Setting Up the Projector 17

CPSC 121: Models of Computation Lab #2: Building Circuits

Applications to Transistors

Your KIM. characters, along with a fancy. includes scrolling, erase to end of screen, full motions, and the usual goodies. The

ECE 274 Digital Logic. Digital Design. Sequential Logic Design Controller Design: Laser Timer Example

Notations Used in This Guide

CMST 220 PUBLIC SPEAKING

lookbook Higher Education

ViaLite SatComs Fibre Optic Link

Contents 2. Notations Used in This Guide 6. Introduction to Your Projector 7. Using Basic Projector Features 29. Setting Up the Projector 16

Chapter 5. Synchronous Sequential Logic. Outlines

Contents 2. Notations Used in This Guide 6. Introduction to Your Projector 7. Using Basic Projector Features 29. Setting Up the Projector 16

1. Connect the wall transformer to the mating connector on the Companion. Plug the transformer into a power outlet.

Have they bunched yet? An exploratory study of the impacts of bus bunching on dwell and running times.

walking. Rhythm is one P-.bythm is as Rhythm is built into our pitch, possibly even more so. heartbeats, or as fundamental to mu-

Outline. Circuits & Layout. CMOS VLSI Design

A Proposed Keystream Generator Based on LFSRs. Adel M. Salman Baghdad College for Economics Sciences

Lecture 3: Circuits & Layout

Pro Series White Toner and Neon Range

LCD Data Projector VPL-S500U/S500E/S500M

Chapter 3: Sequential Logic Design -- Controllers

User's Guide. Downloaded from

Sequencer devices. Philips Semiconductors Programmable Logic Devices

Day care centres (ages 3 to 5) Kindergarten (ages 4 to 5) taken part in a fire drill in her building and started to beep.

SWITCHED ACCESS REMOTE TEST SYSTEM (SARTS- 1 A) REMOTE TEST SYSTEM 1 A (RTS-1 A) TESTS

PRACTICE FINAL EXAM T T. Music Theory II (MUT 1112) w. Name: Instructor:

PIRELLI BRANDBOOK 4. IDENTITY DESIGN

LAERSKOOL RANDHART ENGLISH GRADE 5 DEMARCATION FOR EXAM PAPER 2

LCD VIDEO MONITOR PVM-L1700. OPERATION MANUAL [English] 1st Edition (Revised 2)

What do these sentences describe? Write P for plants, A for animals or B for both next to each sentence below. They ve got roots.

1 --FORMAT FOR CITATIONS & DOCUMENTATION-- ( ) YOU MUST CITE A SOURCE EVEN IF YOU PUT INFORMATION INTO YOUR OWN WORDS!

Train times. Monday to Sunday. Stoke-on-Trent. Crewe

92.507/1. EYR 203, 207: novaflex universal controller. Sauter Systems

LOGICAL FOUNDATION OF MUSIC

DIGITAL EFFECTS MODULE OWNER'S MANUAL

lookbook Transportation - Airports

LCD VIDEO MONITOR PVM-L3200. OPERATION MANUAL [English] 1st Edition (Revised 1)

THE MOSSAT COLLECTION BOOK SIX

For public transport information phone Bus 415. Easy access on all buses. Middleton Alkrington Middleton Junction Chadderton Oldham

MILWAUKEE ELECTRONICS NEWS

Answers to Exercise 3.3 (p. 76)

Train times. Monday to Sunday

METROLOGIC INSTRUMENTS, INC. IS6520/MS6520 Cubit Series Omnidirectional Bar Code Scanner Installation and User s Guide

ARCHITECTURAL CONSIDERATION OF TOPS-DSP FOR VIDEO PROCESSING. Takao Nishitani. Tokyo Metropolitan University

lookbook Senior Living

Reproducible music for 3, 4 or 5 octaves handbells or handchimes. by Tammy Waldrop. Contents. Performance Suggestions... 3

Animals. Adventures in Reading: Family Literacy Bags from Reading Rockets

Your Summer Holiday Resource Pack: English

DS /211 ED SOLENOID OPERATED DIRECTIONAL CONTROL VALVE. Q max 150 l/min SERIES 12 SUBPLATE MOUNTING ISO (CETOP 05) p max 320 bar

Standards Overview (updated 7/31/17) English III Louisiana Student Standards by Collection Assessed on. Teach in Collection(s)

lookbook Corporate LG provides a wide-array of display options that can enhance your brand and improve communications campus-wide.

Homework 1. Homework 1: Measure T CK-Q delay

User's Guide. Downloaded from

MODELING OF BLOCK-BASED DSP SYSTEMS Dong-Ik Ko and Shuvra S. Bhattacharyya

400 Series Flat Panel Monitor Arm

Outline. Annual Sales. A Brief History. Transistor Types. Invention of the Transistor. Lecture 1: Circuits & Layout. Introduction to CMOS VLSI Design

Who Is the Crucified? Assembly, SATB Choir, Descant, Keyboard, Guitar, and English Horn or C Instrument

22 May to 10 December Pontefract Train Times

Reverse Iterative Deepening for Finite-Horizon MDPs with Large Branching Factors

find out more at eastcoast.co.uk/2for1 eastcoast.co.uk/welcome

LOGOMANUAL. guidelines how to use Singing Rock logotype. Version 1.5 English. Lukáš Matěja

Contents. Thank you for the music page 3 Fernando 9 Waterloo 18

SMOKE FRGTORY FOG AITD HAZE GE]'IERATOßS

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

DRAFT. Vocal Music AOS 2 WB 3. Purcell: Music for a While. Section A: Musical contexts. How is this mood achieved through the following?

TAP 413-1: Deflecting electron beams in a magnetic field

AI-1204Z-PCI. Features. 10MSPS, 12-bit Analog Input Board for PCI AI-1204Z-PCI 1. Ver.1.04

Mapping Arbitrary Logic Functions into Synchronous Embedded Memories For Area Reduction on FPGAs

AN425 Interfacing the PCF8584 I 2 C-bus controller to 80C51 family microcontrollers. Philips Semiconductors MICROCONTROLLER PRODUCTS

Big Adventures. Why might you like to have an adventure? What kind of adventures might you enjoy?

ZLAN-86 Ethernet Switch Ethernet Interfaces Reference Design

CAN THO UNIVERSITY JOURNAL OF SCIENCE INSTRUCTIONS FOR AUTHORS

SUMMER HOMEWORK. English 4 th ESO

Phosphor: Explaining Transitions in the User Interface Using Afterglow Effects

Good Evening! Welcome!

Transcription:

Mxim > Design Support > Technicl Documents > Appliction Notes > Microcontrollers > APP 712 Keywords: DS80C400, ethernet drivers, ethernet controller, TCP/IP router, source code, MII, MAC, PHY, ethernet driver, specil function register, SFR, control sttus register, CSR, MAC ddress, high speed microcontroller, micros APPLICATION NOTE 712 DS80C400 Ethernet Drivers Jun 06, 2003 Abstrct: The DS80C400 high-speed microcontroller hs built-in Ethernet medi-ccess controller (MAC) with n industry-stndrd medi independent interfce (MII). This ppliction note presents design considertions nd fully tested exmple ssembly code for n Ethernet interrupt hndler, nd code for sending nd receiving Ethernet pckets. Using these routines, you cn develop custom pplictions such s TCP/IP routers. Introduction The DS80C400 high-speed microcontroller hs built-in Ethernet medi-ccess controller (MAC) with n industry-stndrd medi independent interfce (MII). Plese refer to the High-Speed Microcontroller User's Guide: DS80C400 Supplement nd the DS80C400 dt sheet for detils. This ppliction note presents design considertions nd fully tested exmple ssembly code for n Ethernet interrupt hndler, nd code for sending nd receiving Ethernet pckets. Using these routines, you cn develop custom ppliction such s TCP/IP routers. Full source code nd the heder files defining the symbolic constnts cn be found on the Dlls Semiconductor ftp site t http://files.mximintegrted.com/microcontroller/mxtni/ds80c400/ethdriver/. Pge 1 of 13

Figure 1. DS80C400 Ethernet Buffer. The DS80C400 MAC Hrdwre Ethernet Buffer Memory The DS80C400 communictes with the network vi set of specil function registers (SFRs) nd 8kB of dul port buffer memory. The buffer memory is divided into the receive nd send memory nd cn be ddressed in blocks of 256 bytes ("pges"). The receive pges re orgnized in circulr fshion, mnged by the DS80C400 hrdwre. The send buffer is mnged by the user's ppliction. The loction for the Ethernet buffer is usully ddress 0FFE000h (defult configurtion estblished by ROM loder), ssigned to the constnt ETH_RECEIVE_BUFFER. Ethernet Control Sttus Registers The primitives RedCSR nd WriteCSR re used to red nd write the DS80C400 Ethernet control sttus registers (CSRs). Note tht the exmple code does not sve the processor registers cross function clls. When using this code, ensure tht you don't destroy the processor stte (this is especilly importnt when using interrupt driven dt trnsfer). Pge 2 of 13

Red CSR RedCSR reds control sttus register. *************************************************************************** Function Nme: ETH_RedCSR Description: Red from specified register. Input(s): -> register ddress Outputs(s): r3:r2:r1:r0 -> 32 bit register byte vlue *************************************************************************** ETH_RedCSR: push eie clr eie.5 csr, ; Lod CSRA SFR with the LSB of the ; 16-bit ddress of the trgeted CSR nl bcuc, #0f0h ; Cler BCUC commnd bits orl bcuc, #BCU_READ_CSR ; Write red CSR commnd to BCUC SFR push cc eth_redcsr_busy: ; Wit until Busy bit in BCUC SFR is reset, bcuc ; Move to cc since BCUC is not bit cp. jb cc.7, eth_redcsr_busy pop cc r3, csrd ; Red CSRD SFR for MSB of 32 bit dt r2, csrd r1, csrd r0, csrd ; LSB pop eie Listing 1. RedCSR Reds Control Sttus Register Note tht this code sves, disbles, nd restores the Ethernet ctivity interrupt enble (eie.5) to mke sure tht write to the CSR is not interrupted by n Ethernet ctivity interrupt. The definition for the bcuc, csrd nd csr SFRs cn be found in the include file ds80c400.inc. Constnt vlues such s BCUC_READ_CSR re defined in eth400.inc. Write CSR The WriteCSR function writes 32 bit vlue to control sttus register. *************************************************************************** Function Nme: ETH_WriteCSR Description: Write to specified register. Input(s): -> register ddress r3:r2:r1:r0 -> 32 bit vlue Outputs(s): N/A Pge 3 of 13

*************************************************************************** ETH_WriteCSR: push eie clr eie.5 csrd, r3 ; Write CSRD SFR for MSB of 32 bit dt csrd, r2 csrd, r1 csrd, r0 ; LSB csr, ; Lod CSRA SFR with the LSB of the ; 16-bit ddress of the trgeted CSR nl bcuc, #0f0h ; Cler bcuc commnd bits 0-3 orl bcuc, #BCU_WRITE_CSR ; Write write CSR commnd to bcuc SFR push cc eth_writecsr_busy: SFR is reset, bcuc jb pop cc pop eie cc.7, eth_writecsr_busy Listing 2. WriteCSR Writes Control Sttus Register Initiliztion MAC Address ; Wit until Busy bit in BCUC In order to use the DS80C400 on the network, globlly unique MAC ddress needs to be progrmmed into the device. The MAC ddress cn either be cquired from the DS2502-E48 MAC ddress 1-Wire prt (Dlls Semiconductor hs registered rnge of redy-to-go MAC ddresses in order to simplify building embedded devices) or from nother IEEE registered source. Very importnt: Under NO circumstnces select rndom MAC ddress or the ddress of nother existing device. MAC ddresses re globlly unique nd network stbility depends on well behved devices! *************************************************************************** Function Nme: ETH_LodEthernetAddress Description: Lod the 48 bit ethernet ddress into the controller. Input(s): dptr0 -> pointer to the Ethernet ddress (big-endin) ; for exmple 00 60 01 02 03 04 Outputs(s): N/A *************************************************************************** ETH_LodEthernetAddress: x, @dptr r0, inc dptr x, @dptr r1, inc dptr x, @dptr r2, Pge 4 of 13

inc dptr x, @dptr r3, inc dptr cll x inc x clr cll, #CSR_MAC_LO ETH_WriteCSR, @dptr r0, dptr, @dptr r1, r2, r3,, #CSR_MAC_HI ETH_WriteCSR Listing 3. LodEthernetAddress Lods the MAC Address into the DS80C400 Note tht two CSR writes re required to fully lod the 6-byte Ethernet MAC ddress. Since this code is only clled during initiliztion, it is not protected ginst Ethernet ctivity interrupts. Initilizing the Ethernet MAC further requires configurtion of the prtition between receive buffer (incoming pckets) nd send buffer (outgoing pckets). Figure 1 shows this prtition between pge n-1 nd pge n. To simplify code nd void dropping inbound pckets, most pplictions will benefit from prtitioning the buffer memory in fshion tht reserves most of the pges for inbound pckets nd only lloctes enough pges for one outbound pcket. The reson for this is tht Ethernet is shred medium nd even in switched networks only frction of incoming pckets re of interest to n ppliction. Therefore, we define the constnts ETH_TRANSMIT_PAGE to 17h nd ETH_SEND_BUFFER to ETH_RECEIVE_BUFFER + 17h x 256. Constnt ETH_TRANSMIT_PAGE ETH_SEND_BUFFER Vlue 17h 0FFF700h The following code first disbles the trnsmitter nd then initilizes the DS80C400 buffer memory to select the 23:9 receive:send prtition. The code then sets the hlf/full duplex sttus (this sttus cn be cquired from the MII, see below) nd enbles the trnsmitter. Enbling the Trnsceiver *************************************************************************** Function Nme: ETH_EnbleTrnsceiver Description: Enble receiver nd trnsmitter for Ethernet controller. Input(s): N/A Outputs(s): N/A Pge 5 of 13

*************************************************************************** ETH_EnbleTrnsceiver: push eie clr eie.5 ; First, disble trnsmitter nd receiver (full duplex bit is ; not settble if they re on) clr r3, r2, r1, r0,, #CSR_MAC_CTRL cll ETH_WriteCSR ; Set Ethernet buffer sizes TIMEDACCESS ebs, #ETH_TRANSMIT_PAGE ; Also clers the flush filter filed bit r3, #00h ; Select non-byte swp mode dptr, #ETH_DUPLEX_STATUS x, @dptr swp ; Move bit to position 4 (20:F) jnz eth_et_fullduplex orl, #80h ; Disble receive own (23:DRO) eth_et_fullduplex: orl, #08h ; Pss ll multicst (19:PM) OPTIONAL r2, ; Set duplex mode ccording to PHY detection r1, #10h ; Perfect filtering of multicst, ; lte collision control, no uto pd strip r0, #0ch ; Block-off limit 10, no deferrl check, ; enble trnsmitter nd receiver, #CSR_MAC_CTRL cll ETH_WriteCSR pop eie Listing 4. EnbleTrnsceiver Prtitions the Buffer Memory nd Enbles the Trnsceiver Note tht this code ssumes the duplex sttus informtion is stored t loction ETH_DUPLEX_STATUS in MOVX memory. Flushing the Buffer Next, the Ethernet buffer is flushed to ensure clen strtup. *************************************************************************** Function Nme: ETH_Flush Description: Relese ll resources. Input(s): N/A Outputs(s): N/A *************************************************************************** ETH_Flush: Pge 6 of 13

nl bcuc, #0f0h ; Cler bcuc commnd bits orl bcuc, #BCU_INV_CURR ; Write relese commnd to bcuc SFR Listing 5. Flush Flushes the Receive Buffer Sending nd Receiving Sending Pcket To send pcket, the user's ppliction must first plce the pcket dt in the Ethernet send buffer. If previous pcket ws plced t the sme ddress, the ppliction must wit for the trnsmit to be complete before modifying the buffer memory. Note tht the first four bytes of the send buffer re reserved for the send sttus word. The first byte tht will be trnsmitted is t loction ETH_SEND_BUFFER+4. *************************************************************************** Function Nme: ETH_Trnsmit Description: Trnsmit the rw Ethernet pcket currently in the Ethernet send buffer Input(s): r5:r4 = totl pcket length in bytes Outputs(s): N/A *************************************************************************** ETH_Trnsmit: ; Ethernet frme is in trnsmit buffer (Strting t ; pge offset = 4). Byte count is in r5:r4 bcuc SFR ; Lod MSB of byte count to bcud SFR bcud, r5 ; Lod LSB of byte count to bcud SFR bcud, r4 ; Lod strting pge ddress to bcud SFR bcud, #ETH_TRANSMIT_PAGE ; XXX Set trnsmit in progress flg in your softwre here ; XXX so you cn void interrupting trnsmit in progress. ; XXX e.g.: setb ds400_xmit ; Write trnsmit request to bcuc SFR nl bcuc, #0f0h ; Cler bcuc commnd bits orl bcuc, #BCU_XMIT ; Write trnsmit commnd to Listing 6. Trnsmit Sends Pcket Onto the Network Receiving Pcket When pcket is received (usully indicted by n interrupt, see below), the user code needs to unlod the pcket from the Ethernet buffer memory nd then relese the buffer memory, unlike the send buffer, which is mnged by the user, the receive buffer is mnged by the DS80C400. Pge 7 of 13

Unloding the Pcket Dt Note tht received pcket cn spn severl pges in the receive buffer nd it cn wrp from the lst pge in the receive buffer to the first pge in the receive buffer. Ensure tht your pcket copy routine properly hndles this cse. *************************************************************************** Function Nme: ETH_Receive Description: Strt unloding the lst pcket from the Ethernet controller. Input(s): N/A Outputs(s): N/A *************************************************************************** ETH_Receive: ; Get loction of buffer nd set dptr0 ccordingly, bcud nl, #1fh ; we re not interested in the pge count ; so now contins the strting pge number ; (1 pge is 256 bytes) dptr, #ETH_RECEIVE_BUFFER ; receive buffer strting ddress b, ; "multiply" pge by 256 to get byte count clr cll Add_Dptr0_16 ; nd dd it to receive buffer strting ddress ; dptr0 now points to the receive sttus word of the pcket x, @dptr inc dptr r2, ; sve LSB of frme length x, @dptr inc dptr r3, ; sve this ; check runt frme, wtchdog time-out nl, #(80h or 40h) jnz eth_ueh_relese, r3 ; restore nd get frme length nl, #3fh r3, ; sve HSB of frme length x inc, @dptr dptr ; check CRC error, MII error, collision seen, frme too long nl, #(20h or 08h or 02h or 01h) jnz eth_ueh_relese x, @dptr ; MSB of sttus word ; check for length error, control frme, unsupported ctrl frme ; missed frme b, Pge 8 of 13

frme! nl, #(80h or 20h or 04h or 02h or 01h) jnz eth_ueh_relese ; bd bd bd, b nl, #40h ; check for filter mtch jz eth_ueh_relese ; XXX Copy the pcket into your buffer here. ; XXX r3:r2 contin the length of the pcket, ; XXX dptr0 points to the beginning of the dt. ; XXX Note tht the buffer cn wrp! eth_ueh_relese: Listing 7. Receive Receives Pcket from the Network Relesing the Buffer After processing n incoming pcket, the user code needs to relese the buffer memory in the Ethernet receive buffer. *************************************************************************** Function Nme: ETH_Relese Description: Relese resources. Input(s): N/A Outputs(s): N/A *************************************************************************** ETH_Relese: nl bcuc, #0f0h ; Cler bcuc commnd bits orl bcuc, #BCU_INV_CURR ; Write relese commnd to bcuc SFR Listing 8. Relese Releses Pcket from the Receive Buffer Interrupt Driven Opertion Insted of polling the bit flgs in the bcuc SFR, n ppliction should use the Ethernet ctivity interrupt for better performnce. There is one interrupt hndler for both receive nd trnsmit complete interrupts. The Ethernet ctivity interrupt clls loction 000073h. Since there re only 8 bytes per interrupt, we suggest instlling long jump to the ctul function: org 73h ljmp ETH_ProcessInterrupt Processing Interrupts The following code hndles both receive nd trnsmit complete interrupts. *************************************************************************** Function Nme: ETH_ProcessInterrupt Description: ISR for Ethernet interrupt Pge 9 of 13

Input(s): N/A Outputs(s): N/A Destroyed: Nothing. *************************************************************************** ETH_ProcessInterrupt: push cc, bcuc nl, #rif ; Received dt? jz eth_pi_no_receive ; XXX Cll your receive pcket hndler here. ; XXX Ensure it sves nd restores ll registers! ; XXX E.g.: cll ETH_ProcessPcket eth_pi_no_receive:, bcuc nl, #tif jz eth_pi_exit ; Trnsmitted dt? ; XXX If you keep trck of send in progress, here's the plce ; XXX to cler the flg. ; XXX E.g.: clr ds400_xmit nl bcuc, #(not(tif) nd 0f0h) ; nd NOOP commnd ; XXX If you keep trnsmit queue, send next pcket from queue ; XXX E.g.: cll ETH_SendNextFromQueue eth_pi_exit: pop cc i Listing 9. ProcessInterrupt Hndles Ethernet Activity Interrupts Enbling Interrupts Finlly, fter enbling the Ethernet interrupt, the DS80C400 is redy to receive nd send pckets. *************************************************************************** Function Nme: ETH_EnbleInterrupts Description: Enble Ethernet trnsmit/receive interrupts. Input(s): Outputs(s): Destroyed: *************************************************************************** ETH_EnbleInterrupts: ; XXX If you keep trck of trnsmits in progress, cler ; XXX the flg here. ; XXX E.g.: clr ds400_xmit nl bcuc, #(not(rif or tif) nd 0f0h) ; Cler interrupt flgs setb eie.5 ; Enble Ethernet ctivity interrupt clr eip ; Set network interrupt priority low Listing 10. EnbleInterrupts Enbles the Ethernet Activity Interrupt Medi Independent Interfce (MII) The Medi Independent Interfce (MII) defines I/O lines tht llow the DS80C400 to communicte with Pge 10 of 13

the physicl lyer interfce (PHY). Even though mny PHYs hve vendor-specific commnd set, there re common commnds tht most PHYs shre, defined in the IEEE Std. 802.3. Communictions with PHY cn be used to query PHY for its uto negotition nd duplex stte, nd to isolte nd "unisolte" PHYs (in the cse of multiple PHYs) nd reconfigure PHY. The MII on the DS80C400 is ccessed through CSR registers. The following routines red nd write n MII register in given PHY. Red MII Register *************************************************************************** Function Nme: ETH_RedMII Description: Red MII register Input(s): -> register number, b -> PHY number Outputs(s): r1:r0 -> contents of MII register Notes: MII ddress Register (14h): 31-16 -- reserved 15-11 -- PHY ddress 10-6 -- MII register 5-2 -- reserved 1 -- MII write 0 -- MII busy *************************************************************************** ETH_RedMII: push eie clr eie.5 r7, ; Sve register number ; Wit until MII is not busy eth_rmii_busy:, #CSR_MII_ADDR cll ETH_RedCSR jb, r0 cc.0, eth_rmii_busy clr r3, ; Reserved - lwys cler r2,, r7 ; Restore register number rr rr ; And shift to pos 10:8 r7, ; Sve result of shift nl, #07h ; Select bits 0:2 r1,, b ; Lod PHY ddress nl, #1fh rl rl rl ; shift to 7:3 orl, r1 r1,, r7 ; Restore result of shift nl, #0c0h ; Select bits 7:6 r0, cll, #CSR_MII_ADDR ETH_WriteCSR Pge 11 of 13

; Wit until MII is not busy eth_rmii_busy2:, #CSR_MII_ADDR cll ETH_RedCSR, r0 jb cc.0, eth_rmii_busy2 ; Red MII dt register, #CSR_MII_DATA cll ETH_RedCSR pop eie Listing 11. RedMII Reds n MII Register from Given PHY Write MII Register *************************************************************************** Function Nme: ETH_WriteMII Description: Write MII register Input(s): -> register number, b -> PHY number, r1:r0 -> dt Outputs(s): N/A *************************************************************************** ETH_WriteMII: push eie clr eie.5 push 0 ; Sve r1 nd r0 push 1 r7, ; Sve register number ; Wit until MII is not busy eth_wmii_busy:, #CSR_MII_ADDR cll ETH_RedCSR jb pop 1 pop 0, r0 cc.0, eth_wmii_busy clr r3, ; Reserved - lwys cler r2, ; Write MII dt register, #CSR_MII_DATA cll ETH_WriteCSR, r7 ; Restore register number rr rr ; And shift to pos 0:2 r7, ; Sve result of shift nl, #07h ; Select bits 0:2 r1,, b ; Lod PHY ddress nl, #1fh rl rl rl ; shift to 7:3 Pge 12 of 13

orl, r1 r1,, r7 ; Restore result of shift nl, #0c0h ; Select bits 7:6 orl, #2 ; Select write bit :1: r0, cll pop, #CSR_MII_ADDR ETH_WriteCSR eie Listing 12. WriteMII Writes n MII Register to Given PHY MII Exmple The following code reds the MII sttus register of PHY: b, #0, #MII_STATUS cll ETH_RedMII Relted Prts DS80C400 Network Microcontroller Free Smples More Informtion For Technicl Support: http://www.mximintegrted.com/support For Smples: http://www.mximintegrted.com/smples Other Questions nd Comments: http://www.mximintegrted.com/contct Appliction Note 712: http://www.mximintegrted.com/n712 APPLICATION NOTE 712, AN712, AN 712, APP712, Appnote712, Appnote 712 2013 Mxim Integrted Products, Inc. Additionl Legl Notices: http://www.mximintegrted.com/legl Pge 13 of 13