Microcontroller Basics

Wearables and dozens of real time applications use a microcontroller other than a microprocessor for their core design of the entire product. And, these days almost every electronic device comes with a microcontroller.

Most of the embedded applications make use of a microcontroller unit (MCU) to perform computing operations and Boolean functions.

This article covers the microcontroller basics along with its working, applications, advantages, and disadvantages.

What is a Microcontroller?

Microcontroller (MCU) as the name suggests it is a tiny device that executes dedicated tasks assigned by the user. Tasks may be related to normal calculations like addition, subtraction, division and floating point math.

Other than this, microcontroller control, process, and stores the information in the memory. The memory size varies for different microcontroller families.

They are often referred as “On-Chip microcomputer” in some cases. The building blocks of the microcontroller are the processor, memory, and peripherals.

Let’s discuss a bit more in detail.


Here is the inside view of microcontroller architecture.

It consists of supporting hardware, such as CPU (central processing unit), clock, crystal oscillator, memory and hardware peripherals connected internally.

  • CPU

Basically, the CPU is the central part of a microcontroller. It is a brain that follows out an action given by the user. The CPU fetches the instruction from the memory (ROM), decodes it and executes it. This technique is known as pipelining. The pipelining is done with the help of the data bus and address bus.

The CPU operates instructions at a speed of MegaHertz (MHz) or GigaHertz (GHz).

  • Clock

The MCU requires the clock to do any task. To provide a clock to the microcontroller, a crystal oscillator is driven to the CPU.

The crystal selection determines the speed at which microcontroller want to operate. The frequency range of the crystal oscillator is generally in the range of MHz.

  • Registers

Register is a data storing an element. It stores a binary word of 8-bit length. The microcontrollers are equipped with various general purpose and peripheral registers. General purpose registers include Program Counter (PC) and the stack pointer for storing the data and instructions.  Whereas Peripheral registers are useful to configure the hardware in a microcontroller.

  • Input-Output Ports

Input/output ports are commonly called as GPIO (General purpose Input output) ports. This means these ports can be used either as input or output. Some micro MCU supports alternate GPIO. They can be used for multiple functions.

They are required for connecting the external devices like Display interfaces (LED, LCD, and touch screen), motors, etc. I/O ports are also used for input sensing and switching purposes.

  • Memory

As you know, memory is of two types (RAM and ROM).

RAM (Random access memory) is for storing the temporary storage of data and ROM (Read Only Memory) is for permanent storage.

To store the data in a microcontroller, the processor architecture is divided into Harvard and Von-Neumann architecture. Harvard has separate memory buses (address bus and data bus) to store the instructions and data, whereas Von-Neumann has a common memory for both instructions and data.

  • Timers

Timers are the most innovative peripherals that can produce precise time delay. It can repeat a pre-defined task at a known time period.

Some of the applications of timer include motor control, to turn on/off relay circuit, GPS (Global Position System), home appliance control etc.

  • Counters

The Counter is a peripheral that counts the events happening outside the MCU.

Applications of counters include pulse measurement, object detection, etc. They are used in frequency measurement, to count the rise or fall in temperature in microwave ovens, to measure the set time in washing machine and electric heaters.

  • Serial Interfaces

In electronics, different devices talk to each other using serial communication. To achieve serial communication, interfaces like UART (Universal Asynchronous receiver-transmitter), I2C, and SPI etc. are used.

Moreover, advanced protocols like Ethernet, USB are also incurred in latest microcontrollers.

  • Analog to Digital Converter (ADC)

Sensors convert physical parameters like temperature, humidity, and pressure into analog signals. The ADC converts this analog signal into digital bytes. The analog signals may be in the form of voltage, current or resistance.

It has an internal clock that measures the clock cycles fed by the MCU and samples with its own clock. The number of clock cycles represents the digital representation of analog voltage.

  • Digital to Analog Converter (DAC)

DAC (Digital to analog conversion) is a contrary of ADC. DAC converts the digital data into an analog voltage form. Some of the applications of DAC include digital signal processing, motor control, music players, digital potentiometer etc.

  • Interrupts

An Interrupt is an event that comes into play to do more than one task. When an interrupt is called the microcontroller stops the current execution (first task) and performs other tasks (second task). After completing the second task, it comes back to the first task and carries out normal operations.

Microprocessor vs Microcontroller

In some scenarios, the term microprocessor or microcontroller is quite confusing. But, both of them have similar features with added features for the microprocessor.

Some manufacturers specify the term microprocessor other than microcontroller. But, this may not be true in all cases. To justify this here is the difference between the microcontroller and microprocessor.

This uses a tiny micro CPU that runs at a lower frequencyIt uses a general purpose Central processing unit (CPU) that runs at a higher frequency
Slow in speed of operationFaster in operations.
All peripherals (timer, counter, rtc) are present inside it.Some components are outside the microprocessor.
Supports Boolean operationsDon’t support Boolean functions.
Less time is required to access the CPU registersMore time is required to access the CPU registers.
Mostly used in real time applicationsUsed in Personal desktops and Laptops.
Supports RTOS (Real time operating system)Supports RTOS and kernel based services.
Examples: 8051, PIC, MSP430, Renesas, STM microcontroller etc.Examples: X86, Motorola, Broadcom, Pentium etc.
Suitable to perform bit wise operationsNot supports all types of bitwise operations
The Hardware design is less Hardware complexity is tedious.
Not always support multi-taskingBest suited for multi-tasking
Less expensive The Cost is high

How it works?

When the power supply is switched on, the crystal oscillator triggers clock pulses and generates the frequency. After some time, the oscillator gets stabilized.

Now, the microcontroller starts its working from the Program counter (PC). The program counter address is stored in the ROM. The PC stores the address of the next instruction to be executed. It performs the instructions from the start address (0x00) of the program counter. This address is sent to the instruction decoder which will understand and completes the instructions.


The main advantage of the microcontroller is that the cost and size is less. The interfacing of peripherals becomes easy with I/O ports. And, the speed of execution is faster in terms of speed and memory.

To use a microcontroller in your application other than the processor, here are the key advantages.

  1. Ideal for dedicated applications.
  2. Rigid in nature (i.e. one time programmable)
  3.  Application development time becomes easy.
  4. Practical observations can be done using the simulator and emulator.
  5. Easy to design and deploy.


The most undesirable thing when working with microcontrollers is, they cannot withstand high voltages. The main disadvantage of the microcontroller is that the architecture is difficult to understand.

Other than above, they have limited amount of RAM and not suitable to perform parallel tasks simultaneously.


There are many applications of microcontroller. But here are a few of them.

  • The PWM (pulse width modulation) feature in microcontroller allows to drive DC motors.
  • Used in telecommunications, consumer electronics, test Jig boards, smart energy meters, medical electronics, defense and aerospace etc.
  • Human machine interface devices.
  • Home appliance and Lighting.
  • Automotive electronics for electric power steering, braking etc.
  • Touch sensing solutions.
  • In railways for signaling, door control, propulsion, and braking.
  • Used in industrial control for automation, PLC (programmable logic controllers), motion controllers etc.
  • Battery management systems for monitoring the power level and currents.
  • They are employed in alternative energy (solar, wind, etc.) and transportation (lifts and cranes).
  • Robotics (for Automation)

Final Words

Microcontroller has shortened the human efforts by doing repeated jobs.

If you want to enforce microcontroller projects for embedded devices, you have to understand the architecture of microcontroller.

Ever wish you had worked with a microcontroller to handle complex tasks? Share your thoughts in the comments below.



Leave a Reply

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