Silicon
Labs has assembled a kit
that lets engineers and product designers explore a way to add
Ethernet-communication capabilities to a circuit or product. The hardware
comprises two boards, one with an 8051-type microcontroller and a second with a
SiLabs CP2200 single-chip Ethernet controller. The kit comes with several demonstrations
and code examples that use the royalty-free MicroNet TCP/IP stack from CMX
Systems. By now, SiLabs will have revised the kit User's Guide to correct minor
errors and add omitted information.
I liked this kit, in spite of a few minor hurdles. The
ready-to-go CMX
stack and the SiLabs wizard front end make it easy for engineers to jump into
an Ethernet project. SiLabs provides the source code for each project - but not
the stack - so you can see how they work. Software flow charts would help,
though. If you want to go beyond the kit's basic exercises, review application
note AN237, "TCP/IP Library Programmer's Guide," which explains the
TCP/IP API and how to use it.
|
The 8051 MCU (C8051F120) oversees the CP2200 Ethernet controller
and uses its external-memory bus for read and write operations that involve the
CP2200's internal transmit and receive buffers, and internal control registers.
Programmers will likely use the SiLabs API, but you can perform operations on
the registers and buffers if you wish.
It took little time to set up the hardware and print the
Ethernet-DK User's Guide from the accompanying CD-ROM. The User's Guide (UG)
instructed me to install the SiLabs integrated-development environment (IDE),
examples, and a TCP/IP Wizard. I also elected to install documents and
application notes from the CD. You get a choice to install additional tools
from Keil or Raisonance. But the UG information doesn't mention installing
these tools, so I didn't.
The tutorial information starts with basic Web-server code and
the use of the SiLabs TCP/IP Wizard, which I liked very much. The wizard
gives you an easy-to-use front end for the CMX TCP/IP stack -
you don't get bogged down in Ethernet bits, bytes and packets. Check
boxes in the wizard let me choose physical layer, Internet layer,
transport layer, application layer and system settings. I also set IP addresses
for the development kit, my gateway and subnet mask. Upon completion, I saved
the "profile." The wizard then created a complete project that
supplied the skeleton of a working program I could compile and run. (To find
the IP address on a Windows PC, go to Start-->Run... and type in cmd to open
a command-prompt window. At the prompt, type /ipconfig /all and you'll see
network-adapter and other network information.)
When I tried to run the sample program I ran into a two problems.
The first time I ran the IDE, it asked me if I wanted to "connect"
some windows. I clicked "OK" but didn't understand what the message meant
and still don't. This step didn't cause a problem, but an explanation might
have overcome the anxiety of seeing an unexpected and cryptic message.
Second, when I opened the first project and tried to build it,
SiLabs IDE couldn't locate the assembler, compiler or linker, so it displayed
an error message. The software people at SiLabs told me I had to install the
Keil tools. But the UG did not explain the need to load these tools nor did it
explain how to connect the IDE with the Keil tools. I tracked down an
application note (AN104) that explains the process and some settings you must
check.
Unfortunately, the tool-location settings apply only to the
current project unless you set up and name a Tool Definition Preset. So, after
you follow the instructions in AN104, and before you click "OK" in
the Tool Chain Integration window, click on "Save As" and give the
Keil settings your own name. Then when you start a new project, go to
Project-->Tool Chain Integration ... and locate your named settings in the
"Preset Name:" window to set up a new project with the Keil tools. Keep
in mind the distributed Keil tools have a 4-kbyte code limit, so you can't
create large projects unless you buy the full - and expensive - version of
Keil's tools for 8051 MCUs. Of course you can use other assemblers, compilers
and linkers, but it could take a lot of work to integrate them with the SiLabs
IDE. A second CD-ROM in the kit supplies other software tools from IAR and
Tasking. I did not try these tools.
The first project set up a one-page Web server on the 8051 and
let me "ping" the server to determine I had a good connection. Next
the project code displayed a simple Web page on my lab PC. This demonstration
worked well.
The second project exceeded the code limit of the Keil compiler
by 34 bytes, so the build ended with an error message. Perhaps I made an error,
but the SiLabs-provided code for this project also exceeded the 4-kbyte limit.
I went on to the third exercise in which I compiled code that let me set the IP
address for the board set via a serial port on the 8051 board. This exercise worked
well, although the UG authors refer to the Web-server-2 project when they mean
the Web-server-3 project. Also, none of the exercises include a step to stop
the 8051 processor before going on to the next exercise. Be sure to click on
the red stop sign or go to Debug-->Stop to stop the 8051. Other minor
documentation glitches can cause confusion. In one section, for example, the UG
explains the need to replace a 2-ohm SMT resistor with a 0-ohm resistor, but it
fails to mention which resistor needs replacing. I simply bridged a piece of
wire across resistor R1, based on schematic-diagram information.
Also, the User's Guide notes:
"To force an IP address update hold the SW2 (P3.7) switch on
the C8051F120 Target Board down and reset the MCU."
Do I reset the MCU through the debug interface or somehow in the
hardware?
The UG should state something like:
"To force an IP address update, press down and hold the SW2
(P3.7) switch on the C8051F120 Target Board. Then press and release the Reset
button and release the SW2 button."
The final exercise let me modify the simple Web-page contents in
HTML and have the server display it on my PC. The murky instructions didn't
offer much help. I suggest kit users who complete the third exercise use it at
the basis for their Web-page changes. Otherwise you could wonder what project
to start with. This final exercise notes use of an "HTML2C" utility
program to convert HTLM Web "pages" into an array of characters and
produce two files that the server will use. Unfortunately, the UG doesn't
explain where to find the HTML2C program. Find it in the VFILE_DIR folder for
each of the projects. CMX provides the HTML2C utility for its TCP/IP stack. Just
run the HTML2C.exe program and you can figure out how to use it.
The final exercise includes a demonstration of active Java Web
pages and it worked well. Just remember that if you use the Web-server-3
project as your starting point, you must go through the steps to establish an
IP address for the board set. A flashing green LED on the 8051 board serves as
a reminder. When you want to access the dynamic Web pages, I suggest you open a
new browser and retype the IP address for the board set. If your browser
doesn't clean out its cache, you'll see the previous Web page and wonder why
the exercise doesn't work. The browser "sees" the old IP address and
simply pulls the old page out of its cache. Caching depends on your browser
settings.
By arrangements between SiLabs and CMX, engineers can use the CMX
TCP/IP stack binary code for no fee and no royalty in their products. The stack
supports FTP, HTTP, SMTP, DHCP and other application-layer protocols, as well
as and transport- and Internet-layer protocols. If you need support, technical
assistance, source code or the latest version of the MicroNet TCP/IP stack,
contact
CMX
Systems directly for purchase and licensing information.