How To Choose A Microcontroller
Pulse
Octopart Staff
Oct 10, 2017

Previously in this series, we’ve covered how to select components: how to select capacitors, resistors, and inductors and connectors. When choosing a microcontroller, the decision process becomes a bit more complicated. There are thousands of microcontrollers on offer and it’s a daunting task trying to choose the right one. Often enough, there are plenty of options that are right for the job. There’s also plenty that aren’t right. The trick is finding the best microcontroller that can provide for all the needs of the project and anything else that gets added later.

In this blog, we explain the most important aspects of microcontrollers, including architecture, memory size and interfaces. We will also look at some of the most popular microcontrollers on the market and evaluation boards to get you up and going.

Defining the microcontroller       

The microcontroller is the brains behind any project, performing thousands of tasks every second. Choosing familiar microcontrollers or what has worked previously can help in the process, but doesn’t necessarily fit every project.

Starting off, let’s look at the difference between a microprocessor and a microcontroller. These are often confused with each other. Microprocessors generally consist of just the Central Processing Unit (CPU), which performs all the instructions in a computer program, including arithmetic, logic, control and input/output operations. Microcontrollers contain one or more CPUs with RAM, ROM and programmable input/output peripherals. Microprocessors tend to operate at much greater clock speeds on general application tasks, like gaming, photo editing and software development, whereas microcontrollers are designed for more specific tasks in smaller embedded systems like keyboards, mice, electronic toys and vending machines.

In short, it’s easier to turn on and off an LED with a microcontroller as it has direct access to the output pin, whereas microprocessors have to communicate with the external peripherals (ICs) to control the LED.

As an example, the Raspberry Pi uses the BCM2835/BCM2836 Broadcom microprocessors and the Arduino uses the ATMEGA328p/ATMEGA2560 microcontrollers.

 

Breaking it down

To aid in choosing the right microcontroller, it’s necessary to break the application down to get a better understanding of what the project needs. As these individual needs are discussed, it should become clear what will work and what won’t.

There are a few key questions to ask before starting:

1)     What is the application?

2)     8bit, 16bit or 32bit?

3)     What processor? 8051, ARM, PIC, or AVR?

4)     What’s the operating voltage?

5)     What package size is needed?

6)     What communication interfaces are needed and how many?

7)     How much memory is needed? (including program memory and data memory)

These open-ended questions need further investigation into what the application does. With so many options available, it’s important to start ruling out as many as possible at the start, focusing on key specifications.

What is the application?

Will the application need a lot of processing? Can this processing be done in an 8bit microcontroller? How complex is the design?

If the design needs to perform numerous calculations, more memory may be needed. Performing an FFT on an audio signal will require more RAM, greater sampling rates and high-resolution ADCs, as well as other features. Taking a temperature reading and sending commands over UART are relatively light weight and much smaller microcontrollers can be used with less memory. The application dictates which type of microcontroller and the features. Some common applications include wearables, automotive, industrial, smart home/energy and the internet of things.

Bit Size? 8-bit, 16-bit and 32-bit

The bit size actually refers to the size of a ‘word’ used inside the processor. This ‘word’ is a piece of data handled by the instruction set of the microcontroller.  The size of the word differs in each microcontroller between 8 bits, 16 bits, 32 bits and even 64 bits. A word can be used as an address, a variable, a register or an instruction. In an 8-bit processor, 8 bits are used in every instruction. 16-bit and 32-bit processors can operate with larger amounts of data. Larger register or bus widths, means less restrictions on resources. What does this really mean though? Each instruction inside the processor is dictated by the word size. In assembly language, an instruction is followed by a variable, address or a register. For example, “MOV AL, 61h;” moves the hexadecimal value 0x61 into the AL register. When compiled, this is converted into machine code 10110000 011000001, which is two 8-bit words, where MOV is 10110, AL is 000 and 0x61 is 01100001. While it is not impossible to operate with larger numbers, it is more complicated and less efficient than using a higher bit size microcontroller.

This also has an effect on the size of internal ROM and RAM memory. In the 8-bit processor again, the memory size is dictated by 8 bits, which gives 255 unique memory locations.  Whereas a 16-bit microcontroller can handle up to 65,535 memory locations and a 32-bit microcontroller can handle up to 4,294,967,295 memory locations. In saying this, manufacturers have developed ways to allow smaller bit size microcontrollers to access more memory through banks of addresses and paging.  This complicates the software slightly. Usually 8-bit microcontrollers tend to be lower cost, lower power and faster control, but technological advancements mean 16-bit and 32-bit microcontrollers can now compete with each other.

While the bit size is very clear when writing in assembly language, when writing in C or C++, it is not often obvious in the code, making it an important thing to remember. When using C or C++, the various data types have different sizes from one microcontroller to another. Trying to use a 16-bit unsigned integer in an 8-bit microcontroller will end up losing the most significant byte. However, using an 8-bit integer in a 16-bit or 32-bit microcontroller won’t cause any problems. The most important thing when considering the bit size is the amount of data to be processed. An 8-bit microcontroller will be sufficient when communicating with low speed buses, taking sensor measurements or even controlling a buzzer. However, it will have a lot of trouble trying to control an LCD touch screen or Ethernet interface. This is where a 32-bit microcontroller will excel.

Taking a look at the different architectures and what they mean (ARM/AVR/PIC/8051)

There are a few different microcontroller architectures available on the market including the 8051, ARM, AVR and the PIC. Microchip’s PICs have been around a long time. Atmel’s AVR microcontrollers have been popularized through the Arduino development platform. ARM processors are newer, faster and have been adopted by NXP Semiconductors, Texas Instruments and STMicroelectronics.

The major differences focus around how they operate at the lower level. While 8051, AVR and PIC all have offerings in 8-bit, 16-bit and 32-bit, the ARMs generally come in 32-bit and even 64-bit. The 8051, AVR and PIC work closer with the I/O peripherals and can be lower power and faster as a result. In saying this, continuous development provides a very competitive market where it’s difficult to confirm advantages of one over the other.

RISC and CISC architectures

In order to compare between ARM, AVR and PIC, it’s necessary to look at the fundamental architectures. RISC is a reduced instruction set computer, which is able to perform more instructions with lower cycles than a CISC architecture (complex instruction set computer). CISC processors include the Intel x86 and 8051, Motorola 68000 and Zilog Z80 families. RISC processors are common in embedded or smaller systems that use a small set of simple and general instructions. One of the key advantages to RISC is the load/store architecture which separates memory access and ALU operations (arithmetic logic unit). This improves cost, power consumption and heat dissipation, making them desirable for light, battery operated devices. RISC processors can be found in the ARM, AVR and PIC microcontrollers

ARM

ARM stands for Advanced RISC Machine. Technically ARM is a processor, which is built into the embedded microcontroller. They are typically 32-bit or 64-bit and commonly used in PDAs and smartphones. The ARM Cortex is a group of processors licensed by ARM Holdings. They come in three variants; A, R and M. The Cortex-A series is the “Application” profile, which is the only variant containing an MMU (memory management unit). Many modern operating systems need this MMU to operate. The Cortex-R series is the “Real-time” profile, which is optimized for high performance, hard real-time and safety critical applications. It is similar to the Cortex-A profile, except more fault tolerant.

The most common set is the Cortex-M “Microcontroller” profile. This group consists of the Cortex-M0, Cortex-M0+, Cortex-M1, Cortex-M3, Cortex-M4(F), Cortex-M23 and the Cortex-M33(F). The ‘F’ denotes an optional floating point unit (FPU) inside the core. Typically, microcontrollers can’t use floating points. The Cortex-M0 represents the optimised core with small silicon die size, at the lowest price. The Cortex-M0+ is an optimized version of the M0, which includes some features from the M3 and M4 cores. The Cortex-M1 is specially designed to be loaded as a softcore into Altera, Xilinx and Microsemi FPGA offerings. The Cortex-M3 is used for highly deterministic, low cost, real time applications. The Cortex-M4 is a Cortex M3 with additional DSP instructions and an optional FPU. The Cortex-M7 is a high -performance core with greater power efficiency over the M4.  The Cortex-M23 is similar to the M0+ with additional Trustzone security features. The Cortex-M33 is similar to the Cortex-M4 with the additional Trustzone security features as well.

AVR

AVR is a family of microcontrollers developed by Atmel that use the RISC processors. AVR are most commonly used in the Arduino line of open source board designs. These are available in 8-bit tinyAVR, megaAVR and XMEGA.

AVR32 is the 32-bit offering, which was intended to compete with ARM processors. These are not compatible with the original ARM and include additional SIMD and DSP instructions as well as audio and video processing features.

One of the nice features of most AVR models is that they can reserve a bootloader region to store re-programming code. The code can then re-program through any interface available.

PIC

PIC stands for Peripheral Interface Controller. It is a family of microcontrollers developed by Microchip with a wide variety of options available. They are not strictly RISC processors as they differ very slightly in their operation. The product range includes the 8-bit PIC10, PIC12, PIC 16 and PIC18, the 16-bit PIC24 and dsPIC and the 32-bit PIC32MX, PIC32MZ, PIC32MM and PIC32MK. The 8-bit range focuses on lower cost, the dsPIC focuses on digital signal processing.

The PIC32 series of microcontrollers uses the MIPS32-M4K core technology, which is a 32-bit RISC architecture. MIPS is a direct competitor to the ARM processors covering all types of applications in home entertainment, embedded and networking products, mobile, wearable and IoT devices.

8051

The Intel MCS-51 (also known as 8051) is a CISC architecture. These are available in 8-bit, 16-bit and 32-bit microcontrollers. 8051 silicon IP cores are typically smaller size, lower power compared to ARM Cortex-M and MIPS processors. They are used in everything from USB flash drives to washing machines and complex wireless communications systems-on-chip.

The 8051 processors are widely used by Nordic Semiconductors wireless system-on-chip solutions.

The Operating Voltage

This is generally one of two options, but still important to note. Microcontrollers generally operate at either 3.3V or 5V. If the microcontroller is powered from 3.3V and other devices in the system that communicate with the microcontroller operate at 5V, then level translation may be necessary, which complicates the circuit and adds extra cost. It is good practice to try and keep everything in the one voltage domain.

Package Size  

For package sizes check out our Guide to IC Packages for a breakdown of the package sizes. If the project is to start off on a breadboard, then a DIP package will be necessary. This isn’t usually available for many of the microcontrollers. Alternatively, SOIC, SSOP and TSSOP parts are relatively easy enough to solder by hand, where QFN, QFP and BGA/LGA devices need proper reflow to assemble.

Which communication interfaces are needed?

This comes back to the application and the devices added to the circuit. A serial EEPROM may need a I2C or SPI interface. Other devices may require UARTs/USART/EUSARTs for serial communication. Some displays require parallel interfaces, which can be pin heavy. It’s good to scope out the various devices in the circuit first to gauge what is needed.

Check out the Sensors section in the Common Parts Library, which shows a few examples of devices, which the microcontroller may need to communicate with.

How much memory is needed?

Again, this is application dependent. Will the project need a lot of local processing or will it perform very basic tasks? There are different memory types available in each microcontroller. These are usually volatile memory; RAM and ROM. There are a few microcontrollers that have non-volatile memory EEPROMs as well. It can be difficult to gauge how much of each is needed at first and takes some experience to get the hang of it. This is also dictated by the bit size mentioned earlier.

It’s important to note the difference between program and data memory. Program memory is where the compiled code will be stored and run from and the data memory is used during run time. If a lot of processing is needed, then more data memory will be needed. If the project needs to use look up tables or store a lot of pre-defined values, then larger program memory will be needed.

Comparing microcontrollers

Looking at the top microcontroller manufacturers, there’s quite a lot of overlap in their abilities. Let’s consider four popular microcontrollers across the range: Texas Instrument’s MSP430, STMicroelectronic’s STM32F401, Microchip’s PIC16F1619 and Cypress Semiconductor’s CY7C68013A.

Both the MSP430 and PIC16F1619 focus on low cost. The 16-bit MSP430 is a better choice for lower power, battery operated devices with numerous configurable interfaces, like an indoor/outdoor motion sensor.

The PIC16F1619 is an 8-bit microcontroller, similar in function to the MSP430. It doesn’t have as low power, but will focus on safety critical applications in home appliances and white goods. These types of appliances need to be able to safely handle all types of scenarios and reset in a clean manner if something goes wrong. For example, when the door of a dishwasher is opened, the wash cycle will stop. Then it will resume again when the door is closed.

The STM32F401  is a 32bit ARM Cortex M4 with an FPU processor as well. The 32-bit core and FPU make this microcontroller ideal for medical equipment, video and audio equipment, scanners and anything that needs to perform a lot of floating point calculations as fast as possible. It also has a direct USB interface to the microcontroller, adding a useful external interface. The PIC16F1619 and the MSP430 could not handle these applications as they cannot handle the amount of data being processed at the same time. On the other hand, the ARM Cortex M4 could easily perform most of the tasks of the MSP430 and the PIC16F1619, sacrificing both power and cost.

Cypress Semiconductors CY7C68013A takes a slightly different market angle. Using an 8051 microprocessor, the CY7C68013A has an integrated USB 2.0 interface, allowing data transfer rates of over 53Mbytes per second (maximum allowable USB bandwidth). The STM32 has a USB interface, but it’s only a low speed interface to allow basic communications. The CY7C68013A is ideal for custom USB interfaces, like an encrypted USB Key, with large data storage. Maximum bandwidth would be necessary for this type of application.

Rule of thumb tips on picking a microcontroller

While it is a good idea to consider all of the microcontrollers on offer, it isn’t usually the quickest route to making a selection. This is where a quick rule of thumb comes in handy:

1)     Are they in stock and easily available? More often than not, the perfect microcontroller isn’t easily available or can only be bought in bulk volumes.

2)     What toolchain are they using? Are there online examples to leverage from?

3)     Is it new? While there’s nothing better than using the latest and greatest, it also means finding all the early problems that get added to the first application note. Anything older than 3-4 months should have had plenty of testing by various different consumers in different applications.

4)     Check the pinout. There’s nothing more annoying than having searched for a microcontroller with 2 UARTs and a I2C bus to find out that they’re sharing the same pins.

5)     Not sure how much memory is necessary? Choose a microcontroller with more memory than is needed. Future design iterations can choose a smaller microcontroller within the same family with less memory to save cost.

6)     How many general purpose input/output (GPIO) pins are needed? Always get more than is needed. Extra debug points can be catered for with extra GPIOs. It’s always easy to get a smaller microcontroller in the same family to try and cut costs. It’s much harder to go larger.

7)     Purchase and use evaluation boards and development kits if using a microcontroller different to what you’re used to. The evaluation boards tend to be a little more expensive, but time and money is saved in the long run.

8)     If creating a number of similar projects, consider using the same microcontroller (or a similar enough one) to save hardware and software design time.

 

Conclusion

While there are a lot of options on the market, the key is to select one and get started with it as soon as possible. Evaluation kits prove invaluable in helping choose the right microcontroller. The following are a list of the some of the more popular evaluation kits that can be up and running sample code in under a day.

1)     STMicroelectronics STM32Nucleo-F401RE

2)     Microchips Curiosity Development Board (DM164136)

3)     Renesas R5F562TAADFP Microcontroller Starter Kit

4)     NXP Semiconductors FRDM-KL26Z Low-cost Freedom development board for Kinetis KL16 and KL26

5)     Microchip (originally Atmel) ATMEGA328P-XMINI Xplained Mini Evaluation kit for ATmega328P

6)     Cypress Semiconductor CY8CKIT-030A PSoC 3 Application Processor and SOC Development Kit

[gallery size="full" ids="4655,4657,4658,4659,4660,4661"]

If you have any comments or suggestions, drop us a note in our Slack room or in comments below. Be sure to check out the other blogs in this series: how to select a capacitor, resistor, inductor and connector

Read More Articles