Issue
146 September 2002
Build
Your Own 8051 Web Server
by
Jim Brady
BENCHMARKING
The
first thing I did when I got the Cygnal evaluation board
was run the trusty sieve benchmark on it. [1] First,
I soldered a 22.1184-MHz crystal onto the board and
wrote a function to make the CPU use it instead of the
slower on-chip oscillator.
Most
of its Cygnal 8051’s instructions execute in one or
two clocks, as compared to 12 or 24 clocks for standard
8051s. So, I expected good performance, and indeed the
C8051F005 runs the sieve benchmark about 19 times faster
than a standard 8051. It also ran faster than most 16-bit
CPUs I’ve tested, which is impressive because much of
the sieve is 16-bit operations.
To
be fair, I should mention that the Cygnal 8051 has the
advantage of running entirely out of internal memory.
But the results are still representative of what I could
expect of the various CPUs in this application. To run
the sieve on the C8051F005, I had to scale it down to
fit into RAM, and then scale the result to allow comparison
to other CPUs. You can see the test results in Table
1.
BUILDING
THE BREADBOARD
Photo
1 shows my breadboard with the Cygnal eval board mounted
atop it. The board is part of the Cygnal P/N C8051F005DK
package (about $99). It also includes an RS-232-to-JTAG
interface to program the 8051’s flash memory, IDE, and
a full-speed emulator. My breadboard holds the CS8900A,
associated Ethernet I/O, thermistor circuit, and RS-232
interface. To hold the 100-lead TQFP CS8900A, I used
an RDI/Wainwright solder mount board.
|

(Click
here to enlarge)
|
Photo
1—The Cygnal C8051F005TB sits atop my breadboard
at the upper-right. The top ribbon cable connects
the 8051 CPU to the CS8900A Ethernet controller
while the lower ribbon cable carries analog signals. |
I
connected the evaluation board to my breadboard with
two ribbon cables, one for analog and the other for
digital. In order to keep the ribbon cables short to
reduce cross talk, I cut off the prototyping area of
the eval board. In addition, I added a 22.1184-MHz crystal
and cut the trace that connected the crystal to the
I/O connector. I did this to make sure noise could not
get into the oscillator.
The
Ethernet transformer and associated circuit design in
Figure 1 was taken directly from the CS8900A datasheet.
The eval board operates from 3.3 V, so I used the 3.3-V
version of the CS8900A and the corresponding impedance-matching
components for the 10BaseT interface. I kept wire lengths
to a minimum in the area between the CS8900A and the
RJ45 Ethernet connector.
A
thermistor bridge circuit allows the ratiometric measurement
of both power supply voltage and temperature. Using
a ratio prevents 3.3-V power supply fluctuations from
affecting the temperature measurement. After linearizing
the thermistor characteristic, the firmware displays
temperature on the web page.
ETHERNET
I/O
Listing
1 shows the assembly code that reads Ethernet frames
from the CS8900A. Less you think this bit-banging approach
is inefficient, consider that the Cygnal I/O speed is
40 ns while the maximum access time of the CS8900A is
135 ns. The CS8900A access time imposes the limit, not
the 8051. I suspect this method of data transfer is
at least as fast as conventional 8-bit bus I/O.
| Listing
1—This code reads an Ethernet frame from the
CS8900A. The Cygnal 8051 is so fast that NOPs must
be inserted to meet the CS8900A worst-case access
time. |
Figure
1 shows the interface between the CPU and Ethernet controller.
8051 port lines P1.0 to P1.2 select the CS8900 address.
Only three lines are required because most of the CS8900’s
registers are indirectly addressed. Pulsing port pins
P1.3 and P1.4 generates read and write strobes. 16-bit
data is transferred in and out of ports 2 and 3.
|

(Click
here to enlarge)
|
Figure
1—The left side shows part of the Cygnal C8051F005TB
target board. On the right is my CS8900A Ethernet
interface, temperature-sensing bridge, and RS-232
port. |
My
first design used the interrupt output of the CS8900A
to interrupt the 8051 when an Ethernet frame arrived.
The problem with this is that Cirrus Logic recommends
reading everything out of the chip in the interrupt
service routine. Because the CS8900A has more RAM than
the 8051, I went with polling and only read the most
recent frame. This way the CS8900A can queue a number
of frames while the 8051 pulls them out and processes
them one at a time. I configured the CS8900A to capture
only the frames directed to my MAC address, plus broadcast
frames. If the 8051 had to deal with every Ethernet
frame on a busy network, it would be in big trouble.