[MyHosting.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.

C compiler

Personally I had been using an early version (1985?) of the Keil compiler for a long time. It has served me well. In spite of its quirks, it has produced code that works, and as far as I can tell, it does not have bugs, other than the funky (by today's standards) DOS heritage.

Free Keil compiler

http://www.keil.com

Thanks to a recent (2014) agreement between Keil and Silabs, the Keil PK51 compiler suite is now available through the Silabs web site at NO CHARGE. This is not a crippled package, it is the same version you would have paid about $5,000 earlier this year for. The Keil compiler is THE reference for the 8051. I have pretty much switched all my development to this, using the Silabs IDE as the front end editor/debugger. The Silabs IDE may feel ancient compared to Eclipse or other more recent IDEs but it is functional.

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.

Please note that I used SDCC version 2.6.0 for this project. As of September 2010, the most recent stable release of SDCC is 2.9.0. I have not kept track of the changes since 2.6.0, and I still use it. As a matter of personal choice, I am reluctant to automatically upgrade compilers, unless I know exactly what problem I wanted to fix and make sure it is fixed in the new version. With embedded systems, newer is definitely not always better. Some gotchas I have observed with this version are documented below. The SDCC web site still has the older versions available for download, but just for safety, you may want to keep a copy of the download file for future reinstall. If you can no longer get v2.6.0, ask me, I keep a copy around :)

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 (v2.6.0 specifically) 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.

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.

The current version of the Keil professional compiler is a true Win32 application understanding long file names (finally…) so now that it is free, I see no reason to use anything else.

Using SDCC with the Silabs IDE under Windows 7 x64

This is based on SDCC version 2.6.0. By default, SDCC will be installed under C:\Program Files (x86)\SDCC.

In the Silabs IDE, go to Project→Tool Chain Integration and select tool vendor: SDCC. The default paths for the Assembler, Compiler and Linker executables are incorrect because 64-bit Windows 7 places 32-bit programs in the “Program Files (x86)” folder rather than the normal “Program Files” folder. You can therefore make the following changes:

  • Assembler: C:\Program Files (x86)\SDCC\bin\asx8051.exe
  • Compiler: C:\Program Files (x86)\SDCC\bin\sdcc.exe
  • Linker: C:\Program Files (x86)\SDCC\bin\sdcc.exe

You can leave all the command line flags at their defaults…

Silabs IDE (Integrated Development Environment)

The Silabs IDE is an older but fully functional 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 does not appear to be actively maintained by Silabs, other than adding support for new chips. The download version of the IDE has always been named mcu_ide.exe. There is no version information in the file name. So, make sure you keep a copy of whatever version of the IDE you download by renaming it something like mcu_ide-vx.x.x.exe instead of simply deleting it after you have installed the program. Otherwise, they are all named mcu_ide.exe and a newer download will overwrite the older version. By keeping the old version, you always have the capability to go back if you need a feature that has been removed. I wish I had done that from the beginning, as I have a few development kits that are unusable because the files supporting them are not in the current IDE and I did not keep a copy of the old 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. They cost about $50. I have found fully compatible JTAG adapters on eBay under the reference EC-6 that work well and cost about $15. I have one and it works well.

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 (sometimes it is a separate download). 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 very useful when you start a project with a brand new chip, and very useful if you are not familiar with the 8051 Special Function Registers. 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 uncommented C code (does not write your configuration inputs to the file in comments, as I would have expected) so you cannot feed the output back in the software to edit from there. 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. I wish Silabs would provide configuration files for the Configuration Wizard with their demo programs.

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 let you 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.

TCP/IP

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. The Silabs CP22xx series only supports 10BaseT Ethernet, not the faster, more popular and embedded standard 100BaseTX.

However, the TCP/IP wizard and Library only work with 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.

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.

To be honest, if you need a TCP/IP stack nowadays, you will probably be much better off with an ARM chip. Most ARM chips support 100BaseTX Ethernet instead of 10BaseT and a lot of the TCP/IP processing involves 32 bit variables, and that's just more efficiently done on a 32 bit chip.

Conclusion

In conclusion, Silabs tools and Keil PK51 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: 2015/01/25 09:53 by ko4bb
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Except as noted, this entire site Copyright © 2002-2017. KO4BB All rights reserved.