[1and1.com]   [KO4BB Home Page]   [Manuals Home Page]   [KO4BB Wiki]

 

Tools for the Silabs (and other) 8051 Micro Controllers

Silabs Kits

The free software that comes with the Silabs kits includes two main components: a free version of the Keil compiler, and the Silabs IDE. All the Silabs chips (well, not all, but all the C8051Fxxx) are flash based, and they can be erased and reprogrammed on the fly thousands of times. Some (all?) chips can even write to flash from within the program running in flash (for non-volatile run-time-defined parameter storage for instance), kind of like whacking oneself in the head….

In addition to these two tools, the kits also come with full documentation on the processors and the kits, and one or more configuration utilities.

Free Keil evaluation compiler

http://www.keil.com

The free Keil compiler that comes with the Silabs package is crippled, in that it is limited to 1k of code or something like that, and does not contain the floating point math library (including the math library would blow the 1k limit pretty quickly anyhow). On the other hand, the Keil compiler is THE reference for the 8051.

Older Silabs packages had an older version of the Keil compiler which allowed 4k of code. Then Silabs came out with some very small chips that had less than 4k and as little as 1k of code space, and Keil found out a lot of people could create useful code with 4k or less so they had to shut that down. The current demo linker starts linking at 1k from the bottom of flash, so chips with just 1k of flash cannot be programmed with the Keil demo at all (shut that down too.) The older Keil demo that shipped a few years ago did not have that 1k guard.

Free, Open Source SDCC compiler

http://sdcc.sourceforge.net/

The free SDCC compiler is fully supported by the Silabs IDE, and the header files for all the Silabs chips are included with the default SDCC distribution, so download, click install and you can start coding with SDCC faster than you can say “Keil”.

SDCC does not come with a lot of documentation. Actually, come to think of it, it comes with absolutely no useful documentation. Good thing is, you mostly don't need it. If you want to learn 8051 C, go to the Keil web site and look for the C51 manuals http://www.keil.com/support/man_c51.htm. Remember, the code is the same, the library functions are the same, the only difference is the handling of SFRs, which for the most part you don't need to worry about since that's done in the headers that come with SDCC.

The Thunderbolt monitor is the first project I do with SDCC. It was painless. Overcoming the FUD around switching compiler was the hardest part.

Differences between SDCC and Keil

The differences between Keil and SDCC are mostly in the Special Function Register declarations (the header files), so for instance, my original Keil code compiled with no modification under SDCC.

I noticed one instance where SDCC worked differently from Keil. I have written an awful lot of C programs, but I have never read K&R, so I do not know the gospel, and I could not tell who is right (which is why I said “worked differently”), but it seems to me in that instance, Keil did what was intuitively correct, while SDCC did not.

SDCC is very actively developed, so that “difference” may actually have been resolved by now. SDCC has much better warnings (actually useful, as opposed to “I have crashed, good luck figuring out why” you get from Keil).

SDCC presents the listing files (.lst extension) in a much more useful way. The assembly code is listed just below the line of C code that produced it. Keil shows the assembly at the bottom of the listing, with line number references to the C code, which is very hard to read.

Another difference is that even the Keil professional compiler ($5,000, we tried it at work) really is a set of DOS programs that reluctantly and only partially work under Windows. The Keil linker only knows about 8.3 file names and will crash if there is something like “Documents and Settings” in the path for instance. Keil creates and puts stuff in a C:\autoexec.bat file without telling you (there is no mention of it anywhere, save for a post in an on-line forum dated 2002.) That confused the heck out of us for a while, and was the straw that broke the Camel's back as far as I was concerned. Even after the Keil compiler was uninstalled using the uninstall script that came with it, the autoexec.bat file had not been cleaned up and the previous compiler (which we wanted to upgrade) was unusable until the autoexec.bat file was manually cleaned up.

On the other hand, SDCC is a true Windows command line application.

SDCC does not support float type in printf() and sprintf() statements out-of-the-box. It seems it is only a matter of recompiling the compiler with the right compile options. It can be done under gcc + cygwin under Windows. Please note that the float type is fully supported in the math library.

Silabs IDE

The Silabs IDE is a slick piece of code, which includes text editing, incremental compilation support, flash upload and real time, non-intrusive debugging via JTAG (on the larger chips) or a slick 2 wire interface (C2) on the smaller chips like the F330. Functionality of the loader/debugger is exactly the same via the JTAG or C2 interfaces.

The Silabs IDE is also very actively developed by Silabs, and new versions come up often. I recommend checking their web site often and try to keep the most current version.

About the hardware, Silabs has a number of JTAG/C2 adapters. The Toolstick Base adapter ($18) works with the Toolstick modules ($10), but you can buy a $10 JTAG adapter that allows to use the Toolstick Base with regular JTAG interface for the larger chips that don't come on a Toolstick. This is a little clunky, but it works, I use it. They also have a regular JTAG/C2/USB adapter, and an older JTAG/C2/Serial adapter. I have all of them.

Sometimes, the IDE looses track of the JTAG/C2/USB box (does not connect). This tends to happen on laptops that are plugged in and out of their docking station. That seems to confuse either the program, or Windows, or both. We do that a lot on some machines. When that happens, reinstalling the Silabs IDE (or upgrading, that's a good opportunity to do it) usually fixes the problem. You don't need to uninstall, just reinstall on top, you won't loose anything.

Update: When you install the IDE, it also installs a number of undocumented programs in the C:\Silabs\MCU\Utilities directory. The names are fairly explicit as to what these programs do, but there is not much documentation that I have found, so try those at your own risk.

If you run different versions of the IDE on different machines, and move the JTAG adapter between machines, the IDE will want to reprogram the JTAG firmware. It only takes a click and a few seconds, but if you switch machines, you really want the same IDE version on all.

The Silabs IDE comes with a tool called Configuration Wizard. This slick tool will generate the setup instructions for the hardware, such as the oscillator, ports, UART, ADC, and so on. It is a little clunky, but useful when you start a project with a brand new chip. It allows you to get the chip setup without having to read all the manual. I said it is clunky because if you use it, you pretty much have to keep using it when you make changes, because it creates undocumented C code (does not write your configuration inputs to the file in comments, as I would have expected.) You can save the configuration file, or print it (highly recommended), and if you do, then you can find out what you did (at what frequency does the CPU run, how is the UART or ADC configured, and so on). On the other hand, if you start from a working example from the Silabs installation (which is what I did for this project), you can probably ignore the configuration wizard. You will have to get familiar with the 8051 architecture anyhow eventually.

Assembly

Using either Keil or SDCC, you will probably never have to learn a single line of assembly because C extensions allow you to use all the bit oriented functions. The only assembly instruction that the compiler will not generate is NOP. In-line assembly is not supported anyhow, but you could have assembly modules in a project otherwise written in C. I have done it a couple of times at the beginning because I was not sure the compiler was doing what I wanted. Keil can generate assembly (it does not by default), and SDCC always produces assembly files, so a good way to learn 8051 assembly is by looking at the output from the compiler.

Temptations and Gotchas

Silabs also makes an Ethernet controller or two (CP2200 series). They are intended to work with their larger chips, but since they only require 18 IOs or so, they work with even smaller chips (as long as they have at least 32k of flash). When you buy one of the kits with the Ethernet kit AB4, you get a software pack that includes a “free” TCP/IP stack (made by CMX/Micronet). The Silabs package comes with a TCP/IP Configuration Wizard and is intended to work only with the Keil compiler. Using the demo Keil compiler with the TCP/IP stack is made possible because the Keil demo compiler is smart about the TCP/IP library, and even though the total code size vastly exceeds 1k, it will let you write simple programs that use the TCP/IP stack. Pretty spiffy.

However, the TCP/IP wizard and Library only work with the Keil compiler, so if you want to do anything that requires more than 1k of custom code (excluding the TCP/IP stack), you need to fork $5,000 for the Keil compiler.

Then the TCP/IP stack only comes as a library, and support from Silabs on the TCP/IP stack is minimal, so if you need any help with the TCP/IP stack, or access to the source code, or using a different compiler, you need to send a very, very large check to CMX, the amount of which depends on what option(s) you want (you want fries with that?), how many projects you want to develop and so on (this pricing strategy is generally referred to as “value pricing”), the cost will be anywhere upwards of $15,000 and usually much more.

TCP/IP

Googling TCP/IP, CP2200 and 8051 will eventually lead you to the free Open Source uIP TCP/IP stack, which has been ported to the 8051 and CP2200. It is full featured, but this is not a ready-to-run program for the faint of heart. I have the source code and if/when I get this running with one of the Silabs chip, I will post it on this web site.

Conclusion

In conclusion, Silabs tools and SDCC make for a very nice platform, and if you want to do real microcontroller programming in C, this would be a very good place to start, continue and finish. Keep in mind the Silabs product line starts with the C8051F300, which has 11 pins and runs at up to 25 MHz, and goes up to the C8051F120 which has 100 pins and runs at up to 100 MHz clock. All chips run roughly 1 clock/instruction (for most single byte instructions). I am not aware of any other 8 bit processor running at 100 MIPS.

Didier KO4BB

 
tools_for_the_silabs_and_other_8051_micro_controllers.txt · Last modified: 2010/06/04 16:27 by 66.150.8.161
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki