[MyHosting.com]   [KO4BB Home Page]   [Manuals Home Page]   [KO4BB Wiki]
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tools_for_the_silabs_and_other_8051_micro_controllers [2013/01/08 19:00]
127.0.0.1 external edit
tools_for_the_silabs_and_other_8051_micro_controllers [2015/01/25 09:53]
ko4bb
Line 13: Line 13:
 ==== C compiler ==== ==== 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. After a quick, short-lived experiment with a recent version of Keil (2007), I switched to SDCC (details below).+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 evaluation ​compiler ====+==== Free Keil compiler ====
  
 [[http://​www.keil.com]] [[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.  +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 forThe 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.
- +
-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. +
- +
-I bet that when Keil realizes that some creative people can make useful applications run in 1k of code, the free demo compiler will be reduced ​to 512 bytes... So if you have a version of the Keil demo compiler that supports ​more than 1k, keep it, or move to SDCC (see below). +
- +
-The most recent ​versions of the Silabs IDE do not even contain the Keil demo compiler, ​it has to be downloaded separately, directly from the Keil web site. One more reason to move directly to SDCC...+
  
 ==== Free, Open Source SDCC compiler ==== ==== Free, Open Source SDCC compiler ====
Line 48: Line 42:
  
 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 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. 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.
  
-== File location in Keil and SDCC == +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.
- +
-Because ​of Keil's limitation with filenames (remember that it is a DOS program), you typically cannot place your projects in your My Document folder, because the path to that folder uses names that do not follow the 8.3 conventionTherefore, when using Keil, it is usually necessary to place your project files directly from the top of the C:\ drive +
- +
-For simplicity, I initially followed the same principle with the SDCC projects, ​so that it would be easy to switch between SDCC and Keil if there were any need to. +
- +
-Not only there has not been a need to, but I recently upgraded my main laptop to Windows 7 from Windows XP (a generally smooth upgrade if you want my opinion, even though I did like XP, and still do, as it is still running on several machines here). HoweverWindows 7 has been having problems with the file locations because it is a little more rigorous about keeping files where they should be, and most programs do not have write/erase permissions outside the My Documents folder, so have moved my SDCC projects under the My Documents folder of Windows 7 and all is good. I hope that by now Keil has fixed their problem with 8.3 filenames, but I have no desire ​to find out, Keil is out as far as I am concerned. +
- +
- +
- +
- +
- +
- +
  
 ==== Using SDCC with the Silabs IDE under Windows 7 x64 ==== ==== Using SDCC with the Silabs IDE under Windows 7 x64 ====
Line 85: Line 62:
 ==== Silabs IDE (Integrated Development Environment) ==== ==== Silabs IDE (Integrated Development Environment) ====
  
-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 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 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 to make sure you get support for the newest ​chips. However, new versions often affect previous features in a negative way. 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.+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. +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 $15I have one and it works well
- +
-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 stationThat 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.  **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. 
Line 97: Line 72:
 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. 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 ​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. I wish Silabs would provide configuration files for the Configuration Wizard with their demo programs.+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 ==== ==== 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.+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.
  
-==== Temptations and Gotchas ​====+==== 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. ​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.+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 fastermore popular ​and embedded standard 100BaseTX.
  
-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.+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. 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.
  
-Googling TCP/IPCP2200 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 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 chipI will post it on this web site.+To be honestif you need a TCP/IP stack nowadaysyou 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 variablesand that's just more efficiently done on a 32 bit chip.
  
 ====== Conclusion ====== ====== 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.+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 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.