A microcontroller is a versatile device capable of many things.

It is essentially a mini computer on a single semiconductor integrated circuit chip.

It can be found in many different applications that range from consumer electronics, medical, marine, automotive, aviation and many more.

A microcontroller has many features that make it the choice for hobbyists working in their garage, and engineers working in the industry.

Microcontrollers have many features which include something known as peripherals.

But, what are microcontroller peripherals?

Microcontroller peripherals are parts of the device that serve a specific purpose which help the microcontroller achieve a certain task. Some common microcontroller peripherals are Timers, Analog to Digital converters (ADC), Serial Peripheral Interfaces (SPI), Pulse Width Modulation and 2 wire interfaces (I2C). 

These common peripherals are built into the microcontroller and is one distinguishing difference between it and the microprocessor.

Peripherals that come stock with the microcontroller are known as on-chip peripherals, and ones that you add and interface separately are known as off-chip peripherals. 

What is the main purpose of microcontroller peripherals?

As you briefly saw above, microcontroller peripherals serve a specific purpose that help the microcontroller with a given task.

Let’s take the Analog to Digital Converter (also better known as the ADC) peripheral as an example. 

The ADC has one specific task, which is to take analog data it receives from a sensor (or other any device that outputs analog data), and convert it to digital values that the microcontroller can then process. 

This opens up many possibilities for applications. 

Here is a simple example.

Say you want to turn on a fan when it gets too hot.

The temperature sensor reads the physical temperature of the environment in analog form. 

But, the microcontroller cannot process this information as it is in analog form. 

This is where the ADC lends its helping hand. 

It converts this analog data to digital which the microcontroller can then process accordingly. 

As you can see, the ADC helps the microcontroller with a specific task.

All the other microcontroller peripherals have different functions, but just like the ADC, help the microcontroller with a specific task.

Why use microcontroller peripherals?

The simple answer is to let you perform the task the peripheral was designed to do.

The ADC has the ability to convert analog data to digital.

From the example you saw above, without the ADC, the microcontroller would not be able to do anything with the data it receives from the temperature sensor.

The project specifications will determine what peripherals are needed or not needed. 

Different microcontroller peripherals examples

Microcontroller’s have many peripherals available for different applications.

Listing all of them might take some time, so I will list the peripherals that are most commonly used by a microcontroller.

These peripherals are always found embedded in the microcontroller.

The most common microcontroller peripherals are:

  • Timers
  • Analog to Digital Converter
  • Digital to Analog Converter
  • Serial Communication (SPI, I2C, and UART)
  • General Purpose Input/Output registers
  • Memory (FLASH, SRAM, EEPROM)
  • Pulse Width Modulation

Microcontroller Peripheral #1 : TIMER

The first peripheral that is always found in a microcontroller is the Timer.

Think of your daily life.

Everything you do is determined by a start time, duration and finish time.

You get up at 8am, get to work by 9am, work till 5pm, go to the gym at 6pm etc.

A microcontroller is very similar in the sense that it has operations which have starting times, durations and end times.

So, it needs some way of keeping track of all these events.

That is where the Timer comes in!

The Timer is an important part of a microcontroller as it maintains the timing of operations and keeps it in-sync with the system clock of the microcontroller.

A simple example of this is blinking an LED.

This might seem like not a great feat, but without the capabilities of the Timer you would not be able to do something as simple as turning an LED on and off.

Microcontroller Peripheral #2 : Analog to Digital Converter 

I mentioned the Analog to Digital Converter (ADC) earlier and its ability to convert analog data to a digital form.

This is one of the reasons the ADC is such a common peripheral in microcontrollers.

Sensors are devices that sense the physical world.

There are sensors available that can sense temperature, humidity, light, altitude, force and many more.

However, most if not all these sensors output values that are in an analog format.

As you saw earlier, the microcontroller can only process digital data (0’s and 1’s) and that is where the ADC bridges that gap. 

Microcontroller Peripheral #3 : Digital to Analog Converter

So, the microcontroller can convert analog data to digital using the ADC.

Can it reverse the process and covert digital data to analog?

Yes, absolutely!

Thanks to the Digital to Analog Converter (also known as DAC) peripheral.

The DAC peripheral gives the microcontroller the ability to reverse the process and convert digital to analog.

One of the many examples where this comes handy is playing audio from the micrcontroller’s memory.

You know now that the microcontroller only deals with digital values.

Say a piece of audio is recorded using a microphone and converted to digital data using the ADC and stored in the micrcontroller’s memory in a digital format.

To be able to recreate this audio and play it through a speaker, you will need the help of the DAC.

The DAC converts the digital values into an analog form that can then be played through a speaker.

Microcontroller Peripheral #4 : Serial Communication

Communication is an essential part in everyday life.

We communicate to each other visually, and orally to argue a point , to socialize, teach, learn etc.

Imagine a world where you weren’t able to communicate to your loved ones or anybody at all.

That world would suck!

In the world of microcontrollers, communication is also a crucial element. 

Microcontrollers have a range of serial communication peripherals which include:

  • Serial Peripheral Interface (SPI)
  • Two Wire Interface (I2C)
  • Universal Asynchronous Receiver /Transmitter (UART)

Serial communication allows a microcontroller to ‘talk’ to another microcontroller, computer or external peripheral devices.  

Communication allows the exchange of data which can be information like status updates, or sensor data.

Microcontroller Peripheral #5 : General Purpose Input/Output

Number 5 on the list of common microcontroller peripherals are input and output pins or GPIO’s.

Without the GPIO peripheral the microcontroller would not be able to interface with the other devices.

Devices such as:

  • Motors (Servos, stepper motors, DC brushless motors)
  • Sensors
  • LED’s
  • Buttons
  • Switches

Turning on a LED, reading a button press, connecting a sensor, etc, all requires input and output registers.

A microcontroller pin can be programmed either as an input or output.

Microcontroller Peripheral #6 : Memory

Remember what you did yesterday? (hopefully you do!)

That’s thanks to your memory! 

Our memory lets us remember important life events, things we have learnt, skills we have practiced, habits etc.

A microcontroller has memory for similar purposes.

It also has short term and long term memory just like we do.

A microcontroller memory peripheral typically has 3 types of data storage”

  • Static Random Access Memory (SRAM)
  • FLASH
  • Electrically Erasable Programmable Read Only Memory (EEPROM)

The short term memory (SRAM)  is used to store constants and variables that are used by the microcontroller during normal program execution. 

When the power is removed, all memory in RAM is lost.

Long term memory (FLASH) is where things like the program the software designer has written gets stored. 

Even when power is turned off, this memory remains. 

Microcontroller Peripheral #7 : Pulse Width Modulation

Last but not least of common microcontroller peripherals is Pulse Width Modulation (PWM).

The PWM peripheral works in conjunction with the timer peripherals of a microcontroller. 

What is PWM used for?

Say you have a motor connected to one of the output pins of the microcontroller. 

The speed of that motor can either be 0v or maximum voltage that the microcontroller is operating at (let’s say 5V).

But, you want to be able run that motor at a range of voltages from 0V to 5V that will alter its speed accordingly. 

That is where the PWM peripheral works its magic.

By connecting the motor to a PWM enabled pin you can vary the speed of the motor. 

Maybe you want to dim an LED, again PWM is what is needed. 

Do all microcontrollers have peripherals?

Microcontrollers come in a range of sizes, speeds, architectures, and manufacture families.

The most common microcontrollers available and used are Atmel AVR, 8051, and PIC.

While microcontrollers vary in specifications mentioned above, they all come with a set of peripherals.

However, a larger microcontroller might have more peripherals compared to a smaller microcontroller.

I covered the most common peripherals that are found in microcontrollers earlier. These peripherals can be found in most if not all microcontrollers regardless of size.

Other microcontroller peripherals (which are a bit more unique) might only be available to chips with higher specifications. 

Where are microcontroller peripherals located?

The standard peripherals like Memory, GPIO, ADC, DAC, Serial Communication and Timers are located internally in the microcontroller. 

However, there are peripherals that are available as separate modules and can be interfaced with the microcontroller externally. 

Maybe you want to add bluetooth capability to your next project. 

To do so, you will need to add an external bluetooth peripheral and interface it with the microcontroller. 

Can a microcontroller function without peripherals?

There is no specific answer for this question as it all depends on the specifications and complexity of the application.

While there are some peripherals that the microcontroller can function without, there are certain peripherals that it relies on.

These peripherals include Memory and Timers.

It requires memory to store the main program, as well as constants and variables during runtime. 

And it needs the Timer to ensure operations are run in sync with the system clock and on schedule. 

When is the best time to use microcontroller peripherals?

Knowing when to use a microcontroller peripheral all depends on the needs of the project.

When writing the program code, you as the designer will have to know when you will need to call on the functions of the ADC, or Serial Communication or Timers etc.

It might be right at the start of the program, or you might have to call on them depending on external factors.

By knowing the needs of your projects will determine when you use a particular microcontroller peripheral

Final Thoughts

A microcontroller is a great piece of engineering, that enables us to achieve many things and has been found in many applications.

Applications in Medical, Automotive, Aviation, Consumer Electronics and many more. 

But, sometimes a microcontroller by itself can be quite redundant.

That is where peripherals come to the rescue.

Microcontroller peripherals are parts modules of a microcontroller (internal or external) that serve a specific task.They help the microcontroller perform operations that it would not be able to do by itself. 

Much like a mouse and keyboard of a computer. 

The computer is capable of so many things, but remove simple peripherals like the mouse and keyboard and the computer is rendered useless. 

The mouse and keyboard serve specific tasks that help you and the computer.

Categories: Microcontrollers