Embedded Systems
Module 2
Microcontroller
Compiled by: Dr. Herman B. Acla
A microcontroller (MCU) is a small computer on a single integrated circuit that is
designed to control specific tasks within electronic systems. It combines the
functions of a central processing unit (CPU), memory, and input/output interfaces,
all on a single chip.
A typical microcontroller consists of a processor core, volatile and non-volatile
memory, input/output peripherals, and various communication interfaces. The
processor core is responsible for executing instructions and controlling the other
components of the microcontroller.
The memory is used to store data and program code, while the
input/output peripherals are used to interact with the external environment.
Microcontroller
A microcontroller is a self-contained desktop that can be utilized in an embedded
system. A few microcontrollers may run at clock rate rates and use four-bit
expressions. Because many of the devices they control are battery-operated,
microcontrollers must often be low-power. It is a small, low-cost computer built into
a single chip. It is often used as part of an embedded system to control specific
functions in electronic devices.
A microcontroller includes:
A processor that runs instructions.
Memory to store programs and data.
Input/Output ports to connect with buttons, sensors, screens, etc.
Communication ports (to connect with other devices).
Why Are Microcontrollers Useful?
They are programmable, so you can make them do different tasks.
Common programming languages used are C, C++, and assembly language.
They are often low-power, which is great for devices that run on batteries.
They are small, cheap, and perfect for controlling devices over a long time.
Most microcontrollers are embedded, meaning they are built inside other
devices.
The microcontroller used in Embedded System. For example:
• Security Systems
• Laser Printers
• Automation System
• Robotic
Figure 1. Uses of microcontroller
Working of Microcontroller
The microcontroller chip is a high-speed device, yet it is slow when compared to a
computer. As a result, each command will be executed quickly within the
microcontroller. The quartz oscillator is enabled and through control logic register
once the supply is powered on. Parasite capacitors will be recharged for a few
seconds while the early preparation is taking place.
Once the voltage level reaches its maximum value and the oscillator's frequency
stabilizes, the operation of writing bits through special function registers becomes
stable. Everything is controlled by the oscillator's CLK, and the whole electronics will
begin to function. All of this happens in few nanoseconds.
A microcontroller's major role is that it can be thought of as a self-contained system
with a processor memory. Its peripherals can be used in the same way that an 8051
microcontroller can. The bulk of microcontrollers in use today are embedded in other
types of machinery such as telephones, appliances, vehicles, and computer system
peripherals.
Types of Microcontroller
The types of microcontroller are characterized by the bits,
memory architecture, memory/devices and instruction set.
Figure 2. Classification of microcontrollers
Classification of Microcontrollers by Number of Bits
8-bit Microcontrollers
o The internal bus is 8-bits wide.
o The ALU (Arithmetic Logic Unit) performs operations on 8 bits at a time.
o Example microcontrollers: Intel 8031/8051, PIC1x, Motorola MC68HC11.
Figure 3. Intel 8051 microcontroller
16-bit Microcontrollers
o The internal bus is 16-bits wide, providing better precision and
performance than 8-bit.
o A 16-bit microcontroller can handle a wider range of numbers (0x0000 to
0xFFFF, or 0 to 65535) compared to the 8-bit range (0x00 to 0xFF, or 0
to 255).
o Example microcontrollers: Extended 8051XA, PIC2x, Intel 8096/8097,
Motorola MC68HC12.
Figure 4 Intel 8097 microcontroller
32-bit Microcontrollers
o These microcontrollers use 32-bit instructions for operations.
o Used in advanced applications like medical devices, engine control
systems, office machines, and other embedded systems.
o Example microcontrollers: Intel/Atmel 251 family , PIC3x.
Figure 5. PIC32AK microcontroller
Classification of Microcontrollers by Memory Type
Embedded Memory Microcontroller
o All functional blocks are built into the chip.
o Includes program memory, data memory, I/O ports, serial communication,
counters, timers, and interrupts.
o Example: 8051 microcontroller (has everything on the chip).
External Memory Microcontroller
o The microcontroller does not have all functional blocks on the chip.
o Some components, like program memory, need to be connected
externally.
o Example: 8031 microcontroller (does not have program memory on the
chip).
Classification of Microcontrollers by Instruction Set
CISC (Complex Instruction Set Computer)
o Allows complex instructions that can do multiple tasks in one command.
o Reduces the need for many simpler instructions.
o Example: CISC systems shorten execution time by reducing the number of
instructions in a program.
RISC (Reduced Instruction Set Computer)
o Simplifies the instruction set, using fewer, simpler commands.
o Allows instructions to work on any register and access program and data
simultaneously.
o Shortens execution time by reducing clock cycles per instruction.
o RISC systems generally offer better execution performance compared to
CISC systems.
Classification of Microcontrollers by Memory Architecture
Harvard Memory Architecture Microcontroller
o Has separate memory for program and data.
o Allows simultaneous access to both program and data memory,
improving efficiency.
o Common in microcontrollers that require faster data processing.
Von Neumann Memory Architecture Microcontroller
o Uses shared memory for both program and data.
o Simplifies design but can be slower since the program and data share the
same bus.
Microcontroller Properties
Microcontroller devices are capable of having words longer than 64 bits.
Microcontroller consist of RAM , ROM , Timer , I/O Ports.
Microcontroller ROM is used for program storage and RAM is used for data
storage.
It is designed by using CISC architecture.
The power consumption of modern microcontrollers is significantly lower and
have operating voltage range from 1.8V to 5.5V
The latest feature of microcontroller is flash memory like EPROM and EEPROM.
The most recent feature of a microcontroller is flash memory, such as EPROM
and EEPROM.
Uses of Microcontroller
Microcontrollers are used in a wide range of electronic devices and systems given
below:
Everyday Uses of Microcontrollers:
Devices that detect and control light (like automatic street lights).
Devices that monitor and adjust temperature (like smart thermostats).
Fire detection and safety systems (like smoke alarms).
Tools used in factories to measure and monitor things.
Systems that control industrial processes automatically.
Figure 6. Smart thermostat (left) smoke alarm (right)
Uses of Microcontrollers in Industrial Control:
Devices that measure and track industrial data.
Systems that manage and control production processes.
Figure 7. Industrial control panel
Uses of Microcontrollers in Measuring Devices:
Voltage meters.
Devices that count rotating parts (like in motors).
Current meters.
Portable measuring tools (like digital multimeters).
Issues in Microcontroller
Some of the most common issues that can arise with microcontrollers:
Timing Issues
o Microcontrollers need precise timing to run tasks correctly.
o Any timing errors can cause malfunctions that are often hard to detect
and fix.
Power Issues
o They need a stable power supply.
o Power fluctuations or drops can cause the microcontroller to stop
working or behave unpredictably.
Heat Issues
o Microcontrollers generate heat during use.
o Too much heat can damage the chip or cause it to fail.
o Caused by poor design, bad cooling, or high room temperatures.
Noise Issues
o Can be affected by electromagnetic interference (EMI) and radio
frequency interference (RFI) from nearby devices.
o This can lead to errors or unexpected behavior.
Code Issues
o The software or code running on the microcontroller may have bugs or
errors.
o This can lead to malfunctions or failure of the system.
Security Issues
o Microcontrollers can be hacked or infected with malware.
o Risks include unauthorized access, data theft, or system control by
attackers.
Compatibility Issues
o May not work well with other hardware or components.
o Can result in errors or system failures.