uCEthernet - The fun begins
Ok. The hardware is here. Now we need to connect it up to the LPC2106 evalboard.
Firstly the 3.3V rail and ground rail needs to be connected.
As discussed briefly the ENC28J60 uses SPI for communications. SPI requires 4 signals
for bi directional communication.
- Clock (CLK)
- Data In (MOSI)
- Data Out (MISO)
- Chip Select (CS)
These lines need to be connected to the relevant pins on the LPC2106 evalboard.
The dedicated CSEL pin on the LPC2106 shouldn't be used for CS, instead pull this
pin high. Any other unused GIO pin can be used a the CS.
My test setup is shown below:
The small clips are used to inconjuntion with a low cost PC based logic analyser
to monitor all of the SPI signals. I use this to help with debugging the low level
code discussed in the next section.
The clock signal is controlled by the master device i.e. the LPC2106. All data is
clocked in and out using this pin. Note. the maximum clock speed is 7.5 MHz so B5
silicon of the ENC28J60 or higher is required.
From this point on I would strongly recommend reading the ENC28J60 datasheet through
to get a feel for how this IC works.
To test this board we are going to have to write some code. To keep things
manageable, we shall forget about TCP/IP, so we can just concentrate on MAC frames.
If we can successfully receive and transmit a MAC frame we are on to a good thing,
and we can start building on this success.
A MAC packet consists of a 7 byte preamble, 1 byte start
of frame, a 6 byte MAC source address, 6 byte MAC destination address, 2 byte Type/Length
packet, 46-1500 data bytes and a 4 byte checksum.
The ENC28J60 will generate the preamble, SOF and CRC checksum, but the host must
generate all the other sections and place them in the correct place within the ENC28J60's
memory map.
A driver for the ENC28J60 will be written such that it will contain the following
accessible functions:
- Initialise the ENC28J60, no arguments, returns PASS or FAIL
- Write a packet on to the Ethernet, arguments will be a ptr to a byte buffer and buffer
length (uint), returns PASS or FAIL.
- Try to Read a packet from the MAC. Arguments, ptr to buffer. Returns number of packets
(byte)
The ENC28J60 driver should be portable across a number of platforms, so ideally
any platform specific code should be kept out of the driver module. In this case
the platform specific details will be in the SPI.
The building blocks for the ENC28J60 driver can be viewed here.
If you have comments or suggestions on this code please
email me.
The code has been written and debugged with the Rowley Crossworks IDE. Testing
the driver was done in number of stages and is discussed in the next section. When I
get to the stage where the code is bug free(ish) I will put all the projects files
into a downloadable section. I will include project files for both the Crossword
IDE and also the Eclipse / gcc IDE.
Page 5