English
Language : 

PIC18F97J60 Datasheet, PDF (233/474 Pages) Microchip Technology – 64/80/100-Pin, High-Performance, 1 Mbit Flash Microcontrollers with Ethernet
PIC18F97J60 FAMILY
18.4 Module Initialization
Before the Ethernet module can be used to transmit
and receive packets, certain device settings must be
initialized. Depending on the application, some config-
uration options may need to be changed. Normally,
these tasks may be accomplished once after Reset and
do not need to be changed thereafter.
18.4.1 RECEIVE BUFFER
Before receiving any packets, the receive buffer must
be initialized by setting the ERXST and ERXND Point-
ers. All memory between and including the ERXST and
ERXND addresses will be dedicated to the receive
hardware. It is recommended that the ERXST Pointers
be programmed with an even address.
Applications expecting large amounts of data and
frequent packet delivery may wish to allocate most of the
memory as the receive buffer. Applications that may
need to save older packets, or have several packets
ready for transmission, should allocate less memory.
When programming the ERXST or ERXND Pointers, the
ERXWRPT Pointer registers will automatically be
updated with the value in ERXST. The address in the
ERXWRPT will be used as the starting location when the
receive hardware begins writing received data. For track-
ing purposes, the ERXRDPT registers should
additionally be programmed with the same value. To
program the ERXRDPT registers, write to ERXRDPTL
first, followed by ERXRDPTH. See Section 18.5.3.3
“Freeing Receive Buffer Space” for more information.
18.4.2 TRANSMISSION BUFFER
All memory which is not used by the receive buffer is
considered to be transmission buffer. Data which is to
be transmitted should be written into any unused
space. After a packet is transmitted, however, the hard-
ware will write a 7-byte status vector into memory after
the last byte in the packet. Therefore, the application
should leave at least 7 bytes between each packet and
the beginning of the receive buffer.
18.4.3 RECEIVE FILTERS
The appropriate receive filters should be enabled or
disabled by writing to the ERXFCON register. See
Section 18.8 “Receive Filters” for information on how
to configure it.
18.4.4 WAITING FOR THE PHY START-UP
TIMER
If the initialization procedure is being executed immedi-
ately after enabling the module (setting ECON2<5> to
‘1’), the PHYRDY bit should be polled to make certain
that enough time (1 ms typical) has elapsed before
proceeding to modify the PHY registers. For more
information on the PHY start-up timer, see
Section 18.1.3.1 “Start-up Timer”.
18.4.5 MAC INITIALIZATION SETTINGS
Several of the MAC registers require configuration
during initialization. This only needs to be done once
during initialization; the order of programming is
unimportant.
1. Set the MARXEN bit (MACON1<0>) to enable
the MAC to receive frames. If using full duplex,
most applications should also set TXPAUS and
RXPAUS to allow IEEE defined flow control to
function.
2. Configure the PADCFG<2:0>, TXCRCEN and
FULDPX bits in the MACON3 register. Most
applications should enable automatic padding to
at least 60 bytes and always append a valid
CRC. For convenience, many applications may
wish to set the FRMLNEN bit as well to enable
frame length status reporting. The FULDPX bit
should be set if the application will be connected
to a full-duplex configured remote node;
otherwise it should be left clear.
3. Configure the bits in MACON4. For maintaining
compliance with IEEE 802.3, be certain to set
the DEFER bit (MACON4<6>).
4. Program the MAMXFL registers with the maxi-
mum frame length to be permitted to be received
or transmitted. Normal network nodes are
designed to handle packets that are 1518 bytes
or less.
5. Configure the Back-to-Back Inter-Packet Gap
register, MABBIPG. Most applications will
program this register with 15h when Full-Duplex
mode is used and 12h when Half-Duplex mode
is used. Refer to Register 18-19 for a more
detailed description of configuring the
inter-packet gap.
6. Configure the Non Back-to-Back Inter-Packet
Gap Low Byte register, MAIPGL. Most
applications will program this register with 12h.
7. If half duplex is used, the Non Back-to-Back
Inter-Packet Gap High Byte register, MAIPGH,
should be programmed. Most applications will
program this register to 0Ch.
8. If Half-Duplex mode is used, program the
Retransmission Maximum and Collision Win-
dow registers, MACLCON1 and MACLCON2.
Most applications will not need to change the
default Reset values. If the network is spread
over exceptionally long cables, the default value
of MACLCON2 may need to be increased.
9. Program the local MAC address into the
MAADR1:MAADR6 registers.
© 2006 Microchip Technology Inc.
Advance Information
DS39762A-page 231