Microcontroller
M4-R5.1 · Chapter 3: Sensors, Actuators and Microcontrollers · 7 min read
Microcontroller
1. Microcontroller — Overview
A microcontroller is a small computer on a single metal-oxide semiconductor (MOS) integrated chip. It is a compact, self-contained system manufactured to control the functions of embedded systems.
Examples of applications:
- Office machines, robots, home appliances, motor vehicles, and gadgets
A microcontroller consists of components like memory, peripherals, and most importantly a processor.
Examples of microcontrollers:
- 8051, 8051XA, PIC2X, Intel 8096, ATMEL families
ATmega328P — used in Arduino Uno (Atmel/Microchip AVR chip)
2. Basic Elements of a Microcontroller
- Processor (CPU) — with Clock Circuit, ALU, and Registers
- Memory — RAM and ROM
- Timers
- Serial Communication System
- I/O Pins
- ADC Circuit (Analog-to-Digital Converter)
- DAC Circuit (Digital-to-Analog Converter)
- Interrupt Circuit
3. Processor
The processor can be thought of as the brain of the device. It processes and responds to various instructions that direct the microcontroller's functions. This involves performing basic arithmetic, logic, and I/O operations. It also communicates with other components in the larger embedded system.
4. Memory
Memory is used to store data and programs. A microcontroller usually has a certain amount of RAM, ROM (EEPROM), or Flash memory for storing program source code.
A microcontroller has two main memory types:
(i) Program Memory
Program memory stores long-term information about the instructions that the CPU carries out. It is non-volatile memory — meaning it holds information without needing a power source.
Program memory is physically ROM or Flash memory — it retains data even when power is off.
(ii) Data Memory
Data Memory (DM) is used for temporary data storage while instructions are being executed. It is volatile — it holds information only while the device is connected to a power source.
Data memory is physically RAM — it loses all data when power is removed.
5. Serial Port
The serial port is one example of an I/O port. It allows the microcontroller to connect to external parallel ports but differs in the way it exchanges bits (serial = one bit at a time).
6. Timers and Counters
Timers and counters provide all timing and counting functions inside the microcontroller. The major operations include:
- Clock function manipulation
- Pulse generation
- Frequency measuring
7. Classification of Microcontrollers
Microcontrollers are classified based on four criteria:
(A) According to Bus Width
(i) 8-bit Microcontrollers
The bus width is 8 bits (1 byte). It can transfer and process 8 bits of data in a single cycle. To process large amounts of data, multiple cycles are required.
Examples: Intel 8051, 8031, PIC16F84, Motorola MC68HC11 — 'PIC1X' is not a standard family designation.
(ii) 16-bit Microcontrollers
The bus width is 16 bits (2 bytes). It can transfer 16 bits of data in a single cycle. A 16-bit microcontroller is more efficient compared to an 8-bit one.
Examples: Intel 8096, Texas Instruments MSP430, Freescale MC9S12.
(iii) 32-bit Microcontrollers
A 32-bit microcontroller can transfer and process 32 bits (4 bytes) of data in a single cycle. More powerful and accurate than 16-bit and 8-bit, but also more expensive and consumes more power.
Examples: ARM Cortex-M series, Intel i.MX, Microchip PIC32
(B) According to Memory
(i) Embedded Memory Microcontrollers
A microcontroller in which all functional components AND program memory are embedded inside the chip. Also called on-chip memory microcontrollers.
(ii) External Memory Microcontrollers
A microcontroller in which all functional components are inside the chip but the program memory is attached externally.
(C) According to Instruction Set
CISC — Complex Instruction Set Computer
This microcontroller features a large, complex instruction set that can perform intricate tasks, often requiring multiple clock cycles per instruction. They are commonly used in research-intensive and compute-heavy applications.
Note: Parallel processing is NOT possible in CISC.
RISC — Reduced Instruction Set Computer
Designed with a simpler instruction set, allowing most instructions to execute in a single clock cycle. Offers high speed and efficiency.
RISC is used in mobile phones, embedded systems, IoT (ARM architecture). CISC (e.g. x86) is used in desktops, servers, and research/compute-heavy systems.
8. Memory Architecture
(A) Harvard Architecture Microcontroller
The Harvard architecture-based microcontroller has physically separate memory storage — program memory and data memory — with separate bus lines for each. Both can be accessed at the same time, so it can complete an instruction in one machine cycle.
Advantage: Higher throughput and speed — ideal for Digital Signal Processors (DSPs) and real-time systems.
Due to the two physically separate bus lines, the complexity of the microcontroller design and development cost increases. Mostly used in modern microcontrollers and digital signal processing units.
(B) Von Neumann (Princeton) Architecture Microcontroller
Von Neumann (Princeton) architecture uses a single memory for both program and data storage. Proposed by mathematician John von Neumann in 1945.
There is only one bus used for both data access and instruction fetch. Both operations cannot be done simultaneously — they must be scheduled. This is why it takes two machine cycles to complete an instruction. This limitation is known as the Von Neumann Bottleneck.
'Von Neumann Bottleneck' is the formal name for this limitation — mention it in exams for extra marks.
Its design is simpler and production cost is very low compared to Harvard architecture.