Ethernet Kit Includes Free Stack
March 3, 2011
SiliconLabs has assembled a kitthat lets engineers and product designers explore a way to addEthernet-communication capabilities to a circuit or product. The hardwarecomprises two boards, one with an 8051-type microcontroller and a second with aSiLabs CP2200 single-chip Ethernet controller. The kit comes with several demonstrationsand code examples that use the royalty-free MicroNet TCP/IP stack from CMXSystems. By now, SiLabs will have revised the kit User's Guide to correct minorerrors and add omitted information.
I liked this kit, in spite of a few minor hurdles. Theready-to-go CMXstack and the SiLabs wizard front end make it easy for engineers to jump intoan Ethernet project. SiLabs provides the source code for each project - but notthe 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 applicationnote AN237, "TCP/IP Library Programmer's Guide," which explains theTCP/IP API and how to use it.
The 8051 MCU (C8051F120) oversees the CP2200 Ethernet controllerand uses its external-memory bus for read and write operations that involve theCP2200's internal transmit and receive buffers, and internal control registers.Programmers will likely use the SiLabs API, but you can perform operations onthe registers and buffers if you wish.
It took little time to set up the hardware and print theEthernet-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 andapplication notes from the CD. You get a choice to install additional toolsfrom Keil or Raisonance. But the UG information doesn't mention installingthese tools, so I didn't.
The tutorial information starts with basic Web-server code andthe use of the SiLabs TCP/IP Wizard, which I liked very much. The wizardgives 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. Checkboxes in the wizard let me choose physical layer, Internet layer,transport layer, application layer and system settings. I also set IP addressesfor the development kit, my gateway and subnet mask. Upon completion, I savedthe "profile." The wizard then created a complete project thatsupplied the skeleton of a working program I could compile and run. (To findthe IP address on a Windows PC, go to Start-->Run... and type in cmd to opena command-prompt window. At the prompt, type /ipconfig /all and you'll seenetwork-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 meantand still don't. This step didn't cause a problem, but an explanation mighthave 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 displayedan error message. The software people at SiLabs told me I had to install theKeil tools. But the UG did not explain the need to load these tools nor did itexplain how to connect the IDE with the Keil tools. I tracked down anapplication note (AN104) that explains the process and some settings you mustcheck.
Unfortunately, the tool-location settings apply only to thecurrent project unless you set up and name a Tool Definition Preset. So, afteryou follow the instructions in AN104, and before you click "OK" inthe Tool Chain Integration window, click on "Save As" and give theKeil settings your own name. Then when you start a new project, go toProject-->Tool Chain Integration ... and locate your named settings in the"Preset Name:" window to set up a new project with the Keil tools. Keepin mind the distributed Keil tools have a 4-kbyte code limit, so you can'tcreate large projects unless you buy the full - and expensive - version ofKeil's tools for 8051 MCUs. Of course you can use other assemblers, compilersand linkers, but it could take a lot of work to integrate them with the SiLabsIDE. A second CD-ROM in the kit supplies other software tools from IAR andTasking. I did not try these tools.
The first project set up a one-page Web server on the 8051 andlet me "ping" the server to determine I had a good connection. Nextthe project code displayed a simple Web page on my lab PC. This demonstrationworked well.
The second project exceeded the code limit of the Keil compilerby 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 IPaddress for the board set via a serial port on the 8051 board. This exercise workedwell, although the UG authors refer to the Web-server-2 project when they meanthe Web-server-3 project. Also, none of the exercises include a step to stopthe 8051 processor before going on to the next exercise. Be sure to click onthe red stop sign or go to Debug-->Stop to stop the 8051. Other minordocumentation glitches can cause confusion. In one section, for example, the UGexplains the need to replace a 2-ohm SMT resistor with a 0-ohm resistor, but itfails to mention which resistor needs replacing. I simply bridged a piece ofwire 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 onthe C8051F120 Target Board down and reset the MCU."
Do I reset the MCU through the debug interface or somehow in thehardware?
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 Resetbutton and release the SW2 button."
The final exercise let me modify the simple Web-page contents inHTML and have the server display it on my PC. The murky instructions didn'toffer much help. I suggest kit users who complete the third exercise use it atthe basis for their Web-page changes. Otherwise you could wonder what projectto start with. This final exercise notes use of an "HTML2C" utilityprogram to convert HTLM Web "pages" into an array of characters andproduce two files that the server will use. Unfortunately, the UG doesn'texplain where to find the HTML2C program. Find it in the VFILE_DIR folder foreach of the projects. CMX provides the HTML2C utility for its TCP/IP stack. Justrun the HTML2C.exe program and you can figure out how to use it.
The final exercise includes a demonstration of active Java Webpages and it worked well. Just remember that if you use the Web-server-3project as your starting point, you must go through the steps to establish anIP address for the board set. A flashing green LED on the 8051 board serves asa reminder. When you want to access the dynamic Web pages, I suggest you open anew browser and retype the IP address for the board set. If your browserdoesn't clean out its cache, you'll see the previous Web page and wonder whythe exercise doesn't work. The browser "sees" the old IP address andsimply pulls the old page out of its cache. Caching depends on your browsersettings.
By arrangements between SiLabs and CMX, engineers can use the CMXTCP/IP stack binary code for no fee and no royalty in their products. The stacksupports FTP, HTTP, SMTP, DHCP and other application-layer protocols, as wellas and transport- and Internet-layer protocols. If you need support, technicalassistance, source code or the latest version of the MicroNet TCP/IP stack,contact CMXSystems directly for purchase and licensing information.
About the Author
You May Also Like