Microcontrollers: The Basics


Different kinds of computers are designed for different purposes. The computer at the heart of your laptop is optimized for different puprposes than the one in your phone or the one in your mouse. The simplest computers are those that are designed to take inout from the phyiscal world and control output devices in the physical world. These are called microcontrollers.

Most electronic devices you use today have a microcontroller at their core. Microcontrollers are optimized for control of general input and output. They’re generally less computationally capable than the processors used in multimedia computers or servers, for example. They require less power than a those other processors, and they’re easier to interface with the physical world through input circuits called sensors and output circuits called actuators. They can communicate with other processors through various communication interfaces.

Microcontrollers: Computers for the Physical World

When you’re building something that controls digital media from the physical world, it’s common to use microcontrollers to sense the user’s actions, then pass information about those actions to a multimedia processor like the one in your laptop. Keyboards and computer mice have microcontrollers inside that communicate with personal computers using the USB communications protocol.

Like any other computer, a microcontroller has to have input ports to detect action by a user, and output ports through which it expresses the results of its programs. The metal pins or contact points on a microcontroller are the inputs and outputs. Other devices, like light, heat, or motion sensors, motors, lights, our sound devices, are attached to these pins to allow the microcontroller to be sensitive to the world and to express itself. A microcontroller also requires power connections and communications connections, just like any other computer.

The image below shows an Atmel microcontroller with its pins labelled. You can see which ones are general purpose input and output (GPIO), which ones are for power and communications, and which ones have specialty functions as well, the most common of which is analog input.

There are several different types of microcontrollers. The simplest have very little program memory, only one or two GPIO pins and no specialty functions. These might only cost a fraction of a dollar apiece, in large quantities. Slightly more capable ones will have more memory, more GPIO pins and will include specialty functions as well. The Atmega328 processor that’s at the heart of the Arduino Uno is one of these processor. You can buy these processors for a few dollars apiece in quantity. More powerful than those are the controllers that have connections to interface to a display screen, like those in your mobile phone. These might cost several dollars, or tens of dollars. The more memory, processing power and input/output ports that a microcontroller has, the more expensive it tends to be.

Complex electronic devices like mobile phones or media players or televisions often contain multiple microcontrollers. A very simple controller might be used to control the power systems for the device, another might control the physical input interface, like the touchscreen of a phone or the remote control of a TV, another might control the display, while a more powerful processor controls the whole system, communicating with each lesser processor as needed. When your device is complex enough to need an operating system, then the control of displays, power, and physical IO is usually farmed out to microcontrollers, while the central processor runs the operating system.

The line between microcontrollers and operating system computers is getting blurry these days, so it helps to understand types of programs that different devices might run in order to understand the difference.

Programs for Microcontrollers and Other Processors

Programs for any processors fall into a few different classes: firmware, bootloaders, basic input-output systems, and operating systems. When you understand how they’re all related, you gain a better picture of how different classes of processors are related as well.

Microcontrollers generally run just one program as long as they are powered. That program is programmed onto the controller from a personal computer using a dedicated hardware programming device. The hardware programmer puts the program on the controller by shifting the instructions onto it one bit at a time, through a set of connections dedicated for this purpose. If you want to change the program, you have to use the programmer again. This is true of any processor, by the way: even the most powerful server or multimedia processor has to have a piece of firmware put on it with a hardware programmer at first.

Microcontrollers generally don’t run operating systems, but they often run bootloaders. A bootloader is a firmware program that lives in a part of the controller’s memory, and can re-program the rest of that memory. If you want to program a microcontroller directly from a personal computer without a separate hardware programmer, or from the internet, then you need a bootloader. Whenever your phone is upgrading its firmware, it’s doing it through a bootloader. Bootloaders allow a processor to accept new programs through more than just the dedicated programming port.

Any processor that will run an operating system will run a Basic Input-Output System, or BIOS as well. A BIOS may be loaded onto a processor using a bootloader. A BIOS runs before, or instead of, the operating system. It can control any display device attached to the processor, and any storage attached (such as a disk drive), and any input device attached as well.

Bootloaders and BIOSes are often called firmware because they’re loaded into the flash memory of the processor itself. Other programs live on external storage devices like disk drives, and are loaded by the BIOS. When you change a processor’s firmware, you need to stop the firmware from running, upload the new firmware, and reset the processor for the changes to take effect.

An operating system is a program that manages other programs. The operating system schedules access to the processor to do the tasks that other programs need done, manages network and other forms of communications, communicates with a display processor, and much more.

Programs are compiled into the binary instructions that a processor can read using programs called compilers. A compiler is just one of the many applications that an operating system might run, however. The applications that an operating system runs also live on external storage devices like disk drives.

Firmware Stored on Details
Single program Processor’s program memory Is the only program running; must be loaded by hardware programmer
Bootloader Processor’s program memory Must be loaded by hardware programmer; Takes small amount of program memory; can load another program into the rest of program memory
BIOS Processor’s program memory Usually loaded by bootloader; can load operating system into RAM memory
Software Stored on Details
Operating System External mass storage Runs other programs; loaded into RAM by BIOS; unloaded from RAM on reset
Applications External mass storage Loaded into RAM by operating system and unloaded as needed

Generally, the term microcontroller refers to firmware-only processor, and a processor that runs an operating system from external storage is called an embedded processor, or a central processor if it’s in a device with lots of other processors. For example, the Arduino is a microcontroller. The Raspberry Pi and BeagleBone Black are embedded processors, and phones, tablets, and laptops are multi-processor devices running a central processor.Microcontrollers The Basics Schematic

Microcontroller Development Boards and Activity Boards

A processor, whether microcontroller or multimedia processor, can’t operate alone. It needs support components. For a microcontoller, you need at least a voltage regulator and usually an external clock called a crystal. You might also add circuitry to protect it in case it’s powered wrong, or in case the wrong voltage and current are plugged into the IO pins. You might include communications interfaces as well. This extra circuitry determines the base cost of a development board like the Arduino or the Raspberry Pi.

Development boards usually include:

  • The processor itself
  • Power regulation circuitry
  • Hardware programmer connector
  • Communications interface circuitry
  • Basic indicator LEDs

More advanced development boards might also include multiple communications interface circuits, including wireless interfaces; sensors already attached to some of the GPIO pins; a mass storage connector like an SD card; and video or audio circuitry, if the processor supports that. The more features a board offers, the more it costs.

A development board allows you to program the controller’s firmware and software, but an activity board may not. Activity boards contain a pre-programmed microcontroller and some sensors and actuators along with a communications interface and a communications protocol so that you can interface the board and its sensors and actuators with software running on your personal computer. Boards like the MaKey MaKey or the PicoBoard are activity boards. Activity boards generally can’t operate on their own without being connected to a personal computer, while development boards can.


For more detail: Microcontrollers: The Basics

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top