Welcome back to Chapter Two of the series that will teach you how to program an embedded MCU from the ground up!
Microcontroller (MCU) Differences vs. Computers
All computing devices have at their heart a little “calculator” that crunches numbers. At the most fundamental level that is all it does. A processor “core” as they are called is really nothing more than a machine that gobbles up numbers (interpreted as instructions) and spits out other numbers, which are the results of those instructions. It doesn’t matter if we are discussing the world’s most powerful servers or the tiniest of gadgets. All computers are the same in this regard.
The key differences between the most powerful computer processors and small MCUs are generally:
Computer versus Microcontroller
Therefore, big servers that run the Internet are likely to be clocked up to several GHz, with lots of hardware-accelerated 64-bit wide instructions that run on at least four cores and surrounded by large caches, which are reservoirs of fast local memory and other hardware acceleration circuitry. That takes a lot of energy, but these are servers that are connected with a power cord to an AC outlet, so they can afford to do all of that. MCUs on the other hand often run on battery power and need to consume as little energy as possible, with as low a clocking rate as possible (since it saves power), running only a handful of instructions that can be as small as 8-bits wide on a single core. The aim of an embedded MCU is to do as much as possible with as few resources as possible. This also makes the MCU cheap enough to be placed into nearly disposable gadgets.
A key point however, is that the MCU is no different at the most fundamental level from the standard desktop computer or web server that you may already have had some experience programming in the past. They both have a very similar number cruncher at their heart, but with different set of peripherals surrounding them. Therefore, any skills you might already have in programming regular old computers will help you learn how to program embedded devices. Does that make you feel better?
However, while all mobile/desktop/server computers a standard set of resources available to programmers like hard drives, displays, and network access, the MCU world is much different. There are severe resource constraints in most situations, with lots of specialization between manufacturers and models. You must choose your MCU carefully so as not to waste money or energy while trying to solve your particular embedded task. And you must be very careful about how you use your available resources. I’ll help you with that.
In addition, all mobile/desktop/server computers ship with an Operating System (OS) that helps programmers write, store, and execute source code, as well as optimizing the vast resources of the machine. If things go awry, the OS is there to save the day to inform the programmer that something has gone wrong. An OS is great to have, but it consumes a lot of those precious resources in order to exist, and this is sometimes too much power to bring to your appropriate MCU solution. While there are specialized “real time” OSes available for MCU’s called “RTOS” and a whole dedicate following for them, many embedded solutions don’t require that overhead or justify the expense to run them.
About the EFM32 Family of MCUs
The EFM32 family of MCUs that were chosen for this course are 32-bit cores. In general, this means that 32-bits of information can be processed at once. There are MCUs that operate at 8- or 16-bits and as such, less data can be “gobbled up” by the MCU at one time. Processing more bits at once can speed up the execution time of the program.
The type of processing core in the EFM32 family is an ARM Cortex M0+, M3 or M4 (depending on the EFM32 model) licensed from a company called ARM. These ARM cores are very popular in the mobile device market, and licensed by thousands of companies. The ARM core accepts machine instructions that are in the Thumb format. However, from a programmer’s perspective, the type of instruction format is usually not too important because software programming is usually written in a higher level language and the compiler takes care of translating the higher level language into machine instructions. This process will be covered in the next lesson.
MCU Bare Minimum Components
But the MCU is much more than just an ARM core. In order to use the core at a bare minimum, an MCU needs some non-volatile memory (memory that keeps its programming when the power is removed, typically flash memory) to store the software instructions, some Random Access Memory (RAM) to store the results of those instructions and some input/output pins to accept the program instructions and communicate the results of those instructions to the outside world. While the ARM core itself is licensed from a single company, the rest of the blocks on the MCU can be sourced from other vendors or custom-built by the semiconductor company that produces the MCU.
Once we have a bare minimum MCU, we could use it to embed our programs inside of electronic gadgets of all kinds. The programmer would have to work within the limitations of this bare-bones MCU, but it would work perfectly fine for some applications. Within the EFM32 family of MCUs however, the programmer has many more options. In order to make a more powerful and energy-friendly MCU, Silicon Labs has included a number of onboard hardware accelerator blocks (called peripherals) that automatically perform many tasks that would otherwise be cumbersome or time consuming to program strictly in software.
Which EFM32 is Right for Your Project?
The good news is that you don’t have to decide this right away. The Wonder Gecko Starter Kit is nearly the fully-loaded model so you can learn about all of the features that the EFM32 family offers. Once you learn how to use the MCU, you can choose a different model and port your software to that model easily.
This will get you started in making the decision. The EFM32 family has six basic models and each model has a variety of options regarding RAM, flash, and pin count. The models are Zero Gecko, Tiny Gecko, Gecko, Leopard Gecko, Giant Gecko and Wonder Gecko. A very detailed (and awesome!) breakdown of the different models can be found here: