Ethernet tips

1. Introduction

The scope of this document is providing some high level information and tips to people that just start with PIC Ethernet access (like I did a few months ago).

The purpose of this document is not to explain the Ethernet details (like HTTP, TCP/IP), nor the details of the several software libraries providing Ethernet access to PIC's, nor the internals of the hardware capable of handling Ethernet.
For this information you will have to look into the relevant literature and the relevant datasheets, find the relevant forum threads, look into code examples/snippets or contact the software library authors.

To make Ethernet capable applications there are several configurations (hardware/software) one can choose. One big distiction on hardware side we can make is the usage of a PIC that is Ethernet capable or not.
On Software side there is the choice between mE's libraries and those of e.g. Yo2Lio, and with or without TCP/IP stack.

2. Hardware Configurations

A. Usage of a non Ethernet Capable PIC together with the ENC28J60

The ENC28J60 is an interface chip between Ethernet and the PIC. The interface between ENC and PIC is the SPI one. The PIC has to have sufficient ROM and RAM on board (depending on the Ethernet library used and the rest of the application), and has to be hardware SPI capable.
MikroElektronika makes a number of boards containing the ENC28J60, see below.

a. Usage of the Serial Ethernet board from mikroElektronika.

This is the easiest solution: no extra interfacing required between the PIC (5V or 3.3V) and the board.
You need:

b. Usage of the Serial Ethernet PROTO board from mikroElektronika.

This configuration requires some extra hardware between the PIC and a 5V PIC. No extra interface required with a 3.3V PIC.
You need: Extra links:
Some discussions related to the EthProto board.
Serial Ethernet Proto: Shield RJ45 jack not grounded.

c. Usage of the Ethernet Connector board from mikroElektronika.

Here you use a minimal board (the ENC is not on the board!) from mE that only carries the Ethernet plug and its interface to the ENC28J60. The latter is the chip used on both boards from previous configurations. You need somewhat more soldering skills than in the 2 previous confugurations to make this one.
You need: For the connections of the "Ethernet Connector board" to the ENC28J60, see the circuit diagram of the Serial Ethernet Proto board or the Serial Ethernet board.

B. Usage of an Ethernet capable PIC

A number of PIC's do not need an external ENC28J60, it is built in inside the PIC. The PIC18F97J60 family has that capability.
You need: For the connections of the "Ethernet Connector board" to the PIC, see the circuit diagram in the PIC18F97J60 family datasheet.

2. Software Libraries

The Ethernet software libraries can be divided into a number of categories: Here is an overview (all for mP PRO):
Name from
Mikro-
Elektronika
for
ENC28J60 (1)
for
PIC18F97J60
family
TCP/IP stack
present
Library Forum
ENC28J60 Ethernet Library V3.4 no (2) yes no no link (3) link
ENC28J60 Ethernet Library with TCP/IP Stack V3.5 no (2) yes no yes link (5) link
PIC18F97J60 Ethernet Library V3.4 no (2) no yes no link (4) link
PIC18F97J60 Ethernet Library with TCP/IP Stack V3.5 no (2) no yes yes link (6) link
SPI Ethernet Library yes yes no no built in --
Ethernet Library yes no yes yes built in --
(1) and a non Ethernet but SPI capable PIC.
(2) from Yo2Lio
(3) Files: definitions_enc.mcl, lib1_enc28j60_v3_4.mcl, lib2_enc28j60_v3_4.mcl, Lib_Delays_LIO.mpas and pic_additional_string_library.mcl
(4) Files: lib1_18f97j60_v3_4.mcl, lib2_18F97J60_V3_4.mcl , Lib_Delays_LIO.mpas and pic_additional_string_library.mcl
(5) Files: definitions_enc.mcl, lib1_enc28j60_v3_5.mcl, lib2_enc28j60_v3_5.mcl, Lib_Delays_LIO.mpas and pic_additional_string_library.mcl
(6) Files: lib1_18f97j60_v3_5.mcl, lib2_18F97J60_V3_5.mcl , Lib_Delays_LIO.mpas and pic_additional_string_library.mcl

3. Tips

The tips below (and more) can also be found in several mE forum threads.

1. Serial Ethernet Proto board: do not forget its supply voltage is 3.3V, not 5V. (see here)
2. Serial Ethernet Proto board: if the PIC is a 5V one then do not forget that a level shifter is needed in the PIC's SPI IN line. (see here)
There is a possibility (suggestion --actually used-- from Yo2lio) of eliminating the level shifter by
  • MCU (5V MCU) is powered at 4.2 V (lower voltage for the maximum speed), AND
  • ENC28J60 is powered at 3.6 V (max voltage)
3. Serial Ethernet Proto board: The Ethernet connector is not grounded, while it should be. So, please solder a small wire between one of the outer case connections of the jack and the minus of E1 (elco of 470 uF). I do not know if this error is also present on the Ethernet Connector board.
4. Ethernet Speed: do not forget the ENC28J60 and the the PIC18F97J60 family only support 10Base Ethernet speed: only use a hub/switch which is capable of handling 10Base.
5. Ethernet cable: When using any board from mikroElektronika, always use a straight cable to connect with a hub or a switch, and
use a cross cable to connect with another PC (network card).
6. Ethernet connector: When using any board from mikroElektronika, then do not be mislead by the (board side) pinning of the Ethernet plug, should you have a look at the electrical circuit diagram. This pinning is different to the normal pinning of an ethernet cable because of the internal electronics (transformers etc...) inside the plug.
7. SPI Speed: If using rather long (= 10cm) wires for the SPI interface between the ENC28J60 and the PIC then it may be necessary to lower the SPI speed, otherwise random connection loss can occur. Lowering the speed can be done by using the SPI_Init_Advanced(MASTER_OSC_DIV64, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH); in stead of simply SPI_Init;.
8. Live connection (= LED A "on") test for ENC28J60 usage: The minimum requirements for a live Ethernet connection are not much:
  • The ENC has power (= Power led on),
  • the connection of the Ethernet cable is OK, and
  • the device at the other end (hub, switch or PC) is Ok.
This is always the first test to do. The processor does not have to run to accomplish this.
I do not know if the same behaviour is also valid for the PIC18F97J60 family.

-------------------------------------------