KEMBAR78
Module 1 | PDF | Microcontroller | Central Processing Unit
0% found this document useful (0 votes)
8 views123 pages

Module 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views123 pages

Module 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 123

MICROCONTROLLERS

BEC405A

Gahan A V
Assistant Professor
Department of Electronics and Communication Engineering
Bangalore Institute of Technology
BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Syllabus

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Text Book

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Module 1

14
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

Definition of a Microcontroller

A microcontroller is a compact integrated circuit designed for specific applications. It consists of a CPU
(processor), memory (RAM & ROM), and input/output (I/O) ports all embedded within a single chip.
Microcontrollers are optimized for real-time operations, low power consumption, and control-oriented
applications.

Day-to-Day Usage of Microcontrollers

•Washing Machines – Controls water level, motor speed, and timer.


•Microwave Ovens – Manages cooking time, heating levels, and display.
•Refrigerators – Maintains temperature control and energy efficiency.
•Engine Control Unit (ECU) – Regulates fuel injection, ignition, and emissions.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
•Airbags & ABS – Ensures safety by deploying airbags and preventing skidding.
•Infotainment Systems – Controls audio, GPS, and touchscreen interface.
•Smartphones & Tablets – Used in power management and sensors.
•TV Remote Controls – Processes user inputs and transmits infrared signals.
•Digital Cameras – Manages autofocus, image processing, and storage.
•Robotics – Controls movement, sensors, and communication.
•Factory Machines – Regulates conveyor belts, temperature, and pressure systems.
•Blood Pressure Monitors – Measures and displays readings.
•Pacemakers – Helps regulate heartbeats.
•Glucose Meters – Assists in blood sugar level monitoring.
•Smart Lights & Fans – Controls switching via voice or mobile app.
•Home Security Systems – Manages CCTV cameras and motion sensors.
•Smart Thermostats – Regulates room temperature automatically.
•Wireless Routers – Manages network connections.
•Bluetooth & Wi-Fi Modules – Helps in wireless communication in devices.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

Definition of a Microprocessor

A microprocessor is the central processing unit (CPU) of a computer system, designed to perform arithmetic and
logic operations, execute instructions, and manage data flow. Unlike microcontrollers, microprocessors do not
include built-in memory, I/O ports, or peripherals, requiring external components to function.

Day-to-Day Uses of Microprocessors

•Personal Computers & Laptops


•The CPU (Central Processing Unit) of a computer is a microprocessor that handles tasks like running applications, browsing the
internet, and gaming.
•Examples: Intel Core i5/i7, AMD Ryzen series.

•Smartphones & Tablets


•Processors in mobile devices handle multitasking, gaming, and internet browsing.
•Examples: Qualcomm Snapdragon, Apple A-series, MediaTek Helio.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

•Infotainment systems and GPS navigation are also controlled by microprocessors.

•Smart TVs, Gaming Consoles, and Streaming Devices use microprocessors to process video, audio, and interactive
functions.
•Examples: Sony PlayStation, Xbox, NVIDIA Shield, Roku.

•Smart Speakers (Alexa, Google Home), Thermostats (Nest), and Home Security Systems use microprocessors for voice
recognition and automation.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

•Servers & Workstations – Handle large-scale data processing.


•ATMs & Point-of-Sale (POS) Machines – Process financial transactions securely.
•Medical Equipment – MRI scanners, CT scanners, and diagnostic machines use microprocessors.
•Routers, Modems, and 5G Network Infrastructure use microprocessors for data handling and signal
processing.
•Navigation Systems, Radar, and Military Drones rely on high-performance microprocessors for real-time
decision-making.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

The difference between a microprocessor and a microcontroller lies in their architecture, purpose, and applications:
Microprocessor (MPU)
•A microprocessor is the CPU (Central Processing Unit) alone without built-in memory, I/O ports, or peripherals.
•It requires external RAM, ROM, timers, and I/O interfaces to function properly.
•Designed for general-purpose computing, such as in personal computers, servers, and workstations.
•Examples: Intel x86 series (8086, 80286, 80386, Pentium), Motorola 680x0 series.
Microcontroller (MCU)
•A microcontroller is an integrated system that includes a CPU, RAM, ROM (Flash memory), I/O ports, timers, and
peripherals on a single chip.
•Designed for specific embedded applications, such as in automobiles, washing machines, industrial automation, medical
devices, and consumer electronics.
•More power-efficient and optimized for real-time control.
•Examples: Intel 8051, AVR, PIC, ARM Cortex-M series.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Let's consider an example to illustrate the difference between a microprocessor and a microcontroller in a real-
world scenario.
Example: Traffic Light Control System
Using a Microprocessor (MPU)
If we design a traffic light control system using a microprocessor, we need:
•A CPU (e.g., Intel 8086) for processing.
•External RAM for temporary data storage.
•External ROM to store the program.
•I/O Ports to connect sensors and traffic lights.
•Timers to control light switching.
•Power Supply and interfacing circuits.
Because the microprocessor lacks built-in peripherals, all these components must be externally connected, making
the system complex, bulky, and expensive.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

Using a Microcontroller (MCU)


If we design the same traffic light control system using a microcontroller (e.g., 8051 or AVR), we
get:
•A CPU for processing.
•Built-in RAM & ROM for program execution.
•Built-in I/O Ports to directly connect sensors and traffic lights.
•Built-in Timers to manage time intervals for light changes.
Since everything is integrated on a single chip, the system becomes compact, power-efficient, and
cost-effective—perfect for embedded applications.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

•A microprocessor would be overkill for such an application, requiring extra components and increasing
complexity.
•A microcontroller is the ideal choice, as it is self-contained, requires fewer components, and is
optimized for real-time embedded systems.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Microcontrollers for embedded systems


Microprocessors, Microcontrollers, and Embedded Systems
Microprocessors and microcontrollers are widely used in embedded systems—devices designed to perform one specific task.
For example, a printer has a processor inside it that only receives data and prints. This is different from a PC, which can run
multiple applications like word processing, gaming, and web browsing.
A PC can do many tasks because it has:
•RAM to load different software
•An operating system to manage applications
In contrast, an embedded system runs only one fixed program, which is stored in ROM (Read-Only Memory).
Many parts of a PC, like the keyboard, printer, modem, and mouse, are actually embedded systems. Each of these devices has
a microcontroller inside, performing just one function.
For example:
•A mouse has a microcontroller that tracks movement and sends the position to the PC.
•A disk controller in a computer manages data reading and writing on the hard drive.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
X86 PC embedded applications
Although microcontrollers are commonly used in embedded systems, sometimes they lack the power needed for
certain tasks. In such cases, microprocessors are used instead.

Many major companies like Intel, AMD, and Freescale (formerly Motorola) have adapted their general-purpose
microprocessors for high-end embedded applications.

•Intel & AMD promote their x86 processors for both PCs and embedded systems.

•Freescale continues to develop the 68000 series for embedded applications, even though Apple stopped using them
in Mac computers.

•Apple switched to PowerPC processors (a collaboration between IBM and Freescale) for their Mac computers in
the 1990s.

When a company modifies a general-purpose processor for embedded use, it is called a high-end embedded
processor.
The terms "embedded processor" and "microcontroller" are sometimes used interchangeably, but they are not
always the same.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Choosing a microcontroller

There are four major 8-bit microcontroller families:


1.Intel’s 8051
2.Zilog’s Z8
3.Microchip’s PIC 16X
4.Freescale’s 6811
Each of these has a unique instruction set and architecture, meaning programs written for one will not work on another.
Apart from 8-bit microcontrollers, there are also 16-bit and 32-bit microcontrollers available.
Factors to Consider When Choosing a Microcontroller
When selecting a microcontroller, designers look at:
1.Computing Needs – Processing power, memory, and speed required for the task.
2.Software Development Tools – Availability of compilers, assemblers, and debuggers.
3.Cost & Reliability – How efficiently and affordably the microcontroller meets the project’s needs.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
Criteria for Choosing a Microcontroller

When selecting a microcontroller, it must meet the task requirements efficiently and cost-effectively. The key factors to
consider include:
1.Computing Power
1. Choose between 8-bit, 16-bit, or 32-bit microcontrollers based on processing needs.
2.Speed
1. Determine the maximum clock speed the microcontroller supports.
3.Packaging Format
1. Available in different sizes like 40-pin DIP (Dual Inline Package) or QFP (Quad Flat Package), which affects
space, assembly, and prototyping.
4.Power Consumption
1. Critical for battery-operated devices, where low power usage is essential.
5.Memory (RAM & ROM)
1. Check the amount of built-in RAM and ROM to ensure it meets storage requirements.
6.I/O Pins & Timers
1. The number of input/output pins and built-in timers should match the project’s needs.
7.Scalability & Upgradability
1. How easy it is to upgrade to higher-performance or low-power versions if needed.
8.Cost per Unit
1. Important for mass production; some microcontrollers cost as low as 50 cents per unit when ordered in bulk
(e.g., 100,000+ units).
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
More Criteria for Choosing a Microcontroller
Ease of Development
•The microcontroller should be easy to develop software for.
•Important tools include:
✅ Assembler (to convert code into machine language)
✅ Debugger (to find and fix errors)
✅ C Compiler (for writing efficient programs)
✅ Emulator (to test code before final implementation)
•Good technical support and availability of third-party tools are also key factors.
Availability & Supply
•The microcontroller should be readily available in the required quantities.
•Future availability is also crucial for long-term projects.
•Among 8-bit microcontrollers, the 8051 family is the most widely supported.
•Originally made by Intel, but also produced by Atmel, Philips, AMD, Infineon, Matra, Dallas Semiconductor, and
others.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Harvard vs. Princeton (Von Neumann) Architecture


Microcontrollers and microprocessors use different architectures to process data. The two main types are:
1.Harvard Architecture
2.Princeton (Von Neumann) Architecture

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
1. Harvard Architecture
•Uses separate memory for program instructions and data.
•Allows fetching of instructions and data simultaneously, making it faster.
•Commonly used in microcontrollers (e.g., 8051, PIC, AVR, ARM Cortex-M).
How It Works:
•One memory stores program instructions (ROM).
•Another memory stores data (RAM).
•Since the CPU can access both memories at the same time, execution is efficient and fast.
Example:
A restaurant with separate counters for ordering food and picking it up. This speeds up the process because people can order
and receive food at the same time.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
2. Princeton (Von Neumann) Architecture
•Uses one single memory for both program instructions and data.
•The CPU can only fetch either an instruction or data at one time, which can create a bottleneck and slow execution.
•Commonly used in general-purpose computers (e.g., Intel, AMD, x86 processors).
How It Works:
•Program instructions and data are stored in the same memory.
•The CPU must switch between fetching instructions and accessing data, which can slow down execution.
Example:
A restaurant with only one counter for both ordering and picking up food. This makes the process slower because customers must
wait for their turn before picking up their food.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

RISC vs. CISC


Processors are mainly classified into two types based on how they execute instructions:
1.RISC (Reduced Instruction Set Computer)
2.CISC (Complex Instruction Set Computer)
These architectures determine how a processor handles instructions and performs computations.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
1. RISC (Reduced Instruction Set Computer)
•Uses simple and limited instructions that execute in one clock cycle.
•Requires more instructions to perform complex tasks.
•Focuses on speed and efficiency by breaking down complex tasks into multiple simple instructions.
•Used in mobile devices, embedded systems, and ARM processors.
How It Works:
•Instructions are fixed in size and execute quickly.
•Tasks that require multiple steps in CISC are broken down into smaller, faster steps in RISC.
Example:
Imagine cooking a meal with pre-cut vegetables and measured ingredients. You follow simple steps, making the cooking
process faster.
Real-World Processors:
•ARM Cortex (used in smartphones and tablets)
•MIPS (used in routers and game consoles)
•PowerPC (used in some gaming consoles and embedded systems)
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY
2. CISC (Complex Instruction Set Computer)
•Uses complex instructions, which may take multiple clock cycles to execute.
•A single instruction can perform multiple tasks (e.g., fetching data, modifying it, and storing it back).
•Focuses on reducing the number of instructions needed to perform a task.
•Used in desktop computers, laptops, and x86 processors.
How It Works:
•Instructions are variable in size and can take multiple cycles to execute.
•One complex instruction might replace multiple simpler instructions in RISC.
Example:
Imagine cooking a meal where you chop, mix, and cook all in one step using a food processor. The process is more compact but
may take longer to execute.
Real-World Processors:
•Intel x86 (used in PCs and laptops)
•AMD Ryzen (used in high-performance computing)
•IBM mainframes (used in enterprise systems)
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Four-Bit to Thirty Two-Bit Microcontrollers

Microcontroller Features and Market Adaptation


Microcontrollers are designed to meet the needs of different applications, ranging from household appliances to automobiles.
Since no single microcontroller can efficiently handle all tasks, semiconductor companies offer a variety of models with
different word sizes (4-bit, 8-bit, 16-bit, and 32-bit).
As the word size increases, microcontrollers not only process data more efficiently but also include additional features to meet
specific market demands. Some of the most popular features are:
Analog-to-Digital (A/D) Converters
1. Convert real-world analog signals (like temperature or sound) into digital data that the microcontroller can process.
Counter Arrays
1. Used for counting events or generating timing pulses in various applications.
Watchdog Timers (WDTs)
1. Prevents the system from freezing by automatically resetting the microcontroller if it detects a failure in program
execution.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

Serial Communication Interfaces


1. Supports both asynchronous (UART) and synchronous data transmission, allowing the microcontroller to
communicate with other devices.
Pulse Width Modulation (PWM)
1. Used for motor speed control, LED brightness control, and power regulation in various applications.
Phase-Locked Loops (PLLs)
1. Maintain synchronization in communication systems, ensuring that data transmission is stable.
External Bus Controllers
1. Enable the microcontroller to interface with external memory such as RAM, ROM, or SDRAM, expanding its
capability.
Application-Specific Microcontrollers
If a particular industry, such as automotive dashboard control, has a large enough demand, semiconductor companies design
custom microcontrollers specifically for that application. These specialized microcontrollers integrate the most relevant
features to optimize performance and reduce cost.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Four-bit microcontrollers

Four-bit microcontrollers are widely used in high-volume, low-cost applications. They are designed to be compact,
with a small number of pins and minimal data-handling capacity, making them ideal for simple electronic tasks.

Renesas M34501 (a 4-bit microcontroller in a 20-pin DIP package).

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Key Features of 4-bit Microcontrollers:

1.Low Cost & Small Size


1. The price depends more on the package volume and pin count than on the internal silicon.
2. Keeping the bit width and pin count low helps reduce costs.
2.Limited Data Processing
1. Can handle only basic operations, making them suitable for simple tasks.
3.Common Applications
1. Digital displays (LED/LCD controllers in watches, calculators, and meters).
2. Battery chargers (for efficient power management).
3. Basic automation devices (like simple remote controls).
4. Smart chips (used in low-cost, embedded applications).
4.Example Microcontroller
1. Renesas M34501 (a 4-bit microcontroller in a 20-pin DIP package).

Why Use 4-bit Microcontrollers?


Even though they are not powerful, they are extremely cost-effective and work well in applications where basic
computing is enough.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Eight-bit microcontrollers

Eight-bit microcontrollers are among the most widely used microcontrollers today, with dozens of manufacturers
producing various models. Their popularity comes from their balanced performance, cost-effectiveness, and ease
of use.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Why 8-bit Microcontrollers Are Useful:


1.Efficient for Many Applications
1. Can handle 256 different values (0–255 in decimal).
2. Suitable for control and monitoring applications.
3. Can process ASCII characters efficiently, making them ideal for communication systems.
2.Easy Memory Integration
1. Most RAM and ROM store data in 1-byte (8-bit) units, making it simple to interface with an 8-bit
microcontroller.
3.Large Variety of Models
1. Over 600 models are based on the 8051 architecture alone.
2. Additional models from Microchip, Motorola, and Zilog expand the choices available.
Example: 8051 Microcontroller in a 40-Pin DIP Package
The 8051 is one of the most well-known 8-bit microcontrollers, used in embedded systems, industrial control, and
automation.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Sixteen-Bit Microcontrollers
A 16-bit microcontroller is more powerful than an 8-bit microcontroller because it can process data in 16-bit chunks
instead of 8-bit chunks. This makes it faster and more suitable for complex applications that require more memory and
processing power.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
Key Features of 16-Bit Microcontrollers:
1.Increased Memory and Speed
1. Supports larger memory sizes, allowing storage of more data and bigger programs.
2. Can process larger numbers (0 to 65,535 instead of 0 to 255 in 8-bit systems) in one operation.
2.Better for Programming in High-Level Languages
1. Supports programming in C and C++ more efficiently compared to 8-bit microcontrollers.
2. Allows for more structured and modular coding.
3.Ideal for Data-Intensive Applications
1. Used in applications like:
1. Disk drives (e.g., hard drives)
2. Modems (for communication)
3. Printers and scanners
4. Pattern recognition systems
5. Automotive control systems (engine control, airbags, braking systems)
6. Industrial automation and robotics
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

More I/O and Peripheral Support


•Has more input/output (I/O) pins, timers, and external memory support.
•Comes with built-in modules like:
• Analog-to-Digital Converters (ADC) for sensors
• Pulse Width Modulation (PWM) for motor control
• Serial Communication Ports (UART, SPI, I2C) for interfacing with other devices

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
32-bit microcontroller
A 32-bit microcontroller is the most powerful among the common microcontroller types (4-bit, 8-bit, 16-bit,
and 32-bit). It processes 32-bit data at a time, which makes it extremely fast and capable of handling
complex applications.

Key Features of 32-Bit Microcontrollers:


1.High Processing Power & Speed
1. Can handle larger numbers (0 to 4.29 billion compared to just 65,535 in 16-bit systems).
2. Suitable for real-time data processing and advanced computing tasks.
2.Massive Memory Support
1. Comes with more built-in RAM and ROM for handling large applications.
2. Can support external memory interfaces for even more storage.
3.Specialized for Advanced Applications
1. Unlike 8-bit and 16-bit microcontrollers, which are often general-purpose, 32-bit microcontrollers are designed
for specific high-end applications.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
•Common Applications
•PDAs (Personal Digital Assistants)
•GPS systems
•Automotive control systems (engine management, advanced driver assistance systems)
•Communication networks (Wi-Fi, Ethernet)
•Robotics (AI-driven control systems)
•Gaming consoles (like PlayStation, Xbox)
•Advanced Peripheral Support
•Supports high-performance features such as:
•Direct Memory Access (DMA) → Allows direct data transfer between peripherals and memory without CPU
involvement, improving speed.
•Color LCD controller → Enables high-resolution graphical displays.
•Multiple UARTs & Serial Communication Interfaces → Used for high-speed communication.
•Pulse Width Modulation (PWM) → Used for controlling motors, LED brightness, and power management.
•Real-Time Clock (RTC) → Keeps track of time even when power is off.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY
Example: Sharp LH79520 (A 32-bit Microcontroller)
•Comes in a 176-pin LQFP package
•Features:
• 32KB RAM
• Color LCD controller (for graphical display)
• 3 UARTs (for communication)
• Synchronous Serial Interface
• 2 PWM outputs
• 64 I/O pins (for external devices)
• 4 counters (for timing operations)
• Watchdog Timer (WDT) (for system safety)
• Real-Time Clock (RTC)
• PLL (for clock synchronization)
• Direct Memory Access (DMA) for high-speed data transfer

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

8051 Microcontroller Hardware

The 8051 microcontroller is one of the most popular and widely used microcontrollers, originally developed by
Intel in 1980. Over time, many semiconductor manufacturers have created their own versions of the 8051, leading to
a wide variety of models with different features.

Variants of the 8051 Microcontroller


The generic name "8051" actually includes many microcontrollers, such as:
•8031 → No internal ROM (requires external memory).
•8051 → Standard model with internal ROM, RAM, timers, and I/O ports.
•8052 → Enhanced version with extra RAM, more timers, and additional instructions.
•8751 → Version with Erasable Programmable Read-Only Memory (EPROM) for reprogramming.
•8051-based microcontrollers → Available in NMOS and CMOS technology for different power and speed
requirements.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
Key Features of the 8051
The architecture of the 8051 microcontroller consists of the following components:
1. CPU (Central Processing Unit)
•8-bit CPU with an Accumulator (A) and B register.
•Arithmetic and Logic Unit (ALU) for performing calculations.
•Program Counter (PC) – a 16-bit register that holds the memory address of the next instruction.
•Program Status Word (PSW) – an 8-bit register that holds status flags like carry, auxiliary carry, and parity.
•Stack Pointer (SP) – an 8-bit register that keeps track of the top of the stack.
2. Memory Organization
•Internal ROM (Read-Only Memory):
• 4K ROM (8051 model) for program storage.
• 0K ROM in 8031 (external memory required).
•Internal RAM (Random Access Memory):
• 128 bytes total.
• 32 bytes for register banks (divided into four banks, each with eight registers).
• 16 bytes (bit-addressable memory) for individual bit-level operations.
• 80 bytes for general-purpose data storage.
3. Input/Output Ports
•32 I/O pins, grouped into four 8-bit ports:
• P0, P1, P2, and P3
• Each port can be programmed as input or output.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

4. Timers and Counters


•Two 16-bit timers/counters (T0 and T1) used for:
• Timing operations
• Event counting
5. Serial Communication
•Full-duplex UART (Universal Asynchronous Receiver Transmitter)
•Uses SBUF (Serial Buffer Register) for data transmission and reception.
6. Interrupt System
•Two external interrupts
•Three internal interrupts
•Interrupt Priority Control (IP) Register
7. Special Function Registers (SFRs)
•Control Registers:
• TCON (Timer Control)
• TMOD (Timer Mode)
• SCON (Serial Control)
• PCON (Power Control)
8. Oscillator and Clock Circuit
•Generates the clock signal for synchronizing all operations.
•Requires an external crystal oscillator (typically 11.0592 MHz).

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

8051 Microcontroller (40-Pin DIP) Pin Assignments

The 8051 microcontroller is available in a 40-pin Dual Inline


Package (DIP). Each pin has a specific function, such as I/O
operations, power supply, clock, serial communication, and
control signals.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
Pin No. Pin Name Description

1-8 Port 1 (P1.0 – P1.7) 8-bit bidirectional I/O port (no internal pull-ups)

9 RST (Reset) Active high reset pin (must be high for 2 machine cycles)

10-17 Port 3 (P3.0 – P3.7) Dual-purpose I/O port (with alternate functions)

10 P3.0 / RXD Serial Input (UART Receiver)


11 P3.1 / TXD Serial Output (UART Transmitter)
12 P3.2 / INT0 External Interrupt 0
13 P3.3 / INT1 External Interrupt 1
14 P3.4 / T0 Timer 0 external input
15 P3.5 / T1 Timer 1 external input
16 P3.6 / WR External memory write signal
17 P3.7 / RD External memory read signal

18-19 XTAL2, XTAL1 Crystal oscillator connections (typically 11.0592 MHz)

20 GND Ground (0V)

21-28 Port 2 (P2.0 – P2.7) Dual-purpose I/O (also acts as higher address bus in external memory mode)

29 PSEN (Program Store Enable) Enables external program memory

30 ALE (Address Latch Enable) Latches the lower byte of the address

31 EA (External Access Enable) Must be low for external memory, high for internal ROM

32-39 Port 0 (P0.0 – P0.7) Open-drain bidirectional I/O (also serves as address/data bus in external memory mode)

40 VCC +5V Power Supply


DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY
1.Power Supply & Clock Pins:
1. VCC (Pin 40) – +5V power supply.
2. GND (Pin 20) – Ground (0V).
3. XTAL1 (Pin 19) & XTAL2 (Pin 18) – Connects to external crystal oscillator (e.g., 11.0592 MHz) to
generate the clock signal.
2.I/O Ports:
1. Port 0 (P0.0 - P0.7, Pins 32-39) – Acts as a bidirectional I/O port and multiplexed address/data
bus.
2. Port 1 (P1.0 - P1.7, Pins 1-8) – General-purpose bidirectional I/O port.
3. Port 2 (P2.0 - P2.7, Pins 21-28) – Serves as I/O or high-order address bus.
4. Port 3 (P3.0 - P3.7, Pins 10-17) – Each pin has an alternate function (Serial Communication,
Interrupts, Timers, External Memory Control).
3.Control Pins:
1. RST (Pin 9) – Resets the microcontroller when held high for two machine cycles.
2. PSEN (Pin 29) – Enables external ROM memory.
3. ALE (Pin 30) – Helps latch the lower address byte.
4. EA (Pin 31) – Selects between internal or external program memory.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

The 8051 Oscillator and Clock


The heart of the 8051 microcontroller is the clock circuitry, which generates clock pulses that synchronize all internal
operations. The XTAL1 and XTAL2 pins are provided for connecting an external resonant network to form an
oscillator circuit.

Oscillator Circuit in 8051


•Clock Frequency (f): The crystal frequency defines the internal clock speed of the 8051 microcontroller.
•Typical Crystal Frequency: The 8051 is commonly operated at 11.0592 MHz to achieve standard baud rates for serial
communication.
•Frequency Range:
• Minimum: 1 MHz
• Maximum: 16 MHz (varies by manufacturer)
•Why Use a Crystal?
• Provides stable and precise clock pulses.
• Ensures accurate timing for serial communication.
• Ceramic resonators can be used but are less stable.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
Basic Components of the 8051 Oscillator Circuit
To form an oscillator, we need:
1.Crystal Oscillator (Typically 11.0592 MHz for accurate serial communication).
2.Two capacitors (C1, C2) (Typically 30pF each).
3.A resistor (optional) to fine-tune the oscillation.
4.Internal Inverter in the 8051 chip to complete the oscillator circuit.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Program Counter and Data Pointer

The 8051 microcontroller has two 16-bit registers that handle memory addressing:
1.Program Counter (PC)
2.Data Pointer (DPTR)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

A and B CPU Registers

• The 8051 microcontroller contains 34 general-purpose (or working) registers.

• Two of these, registers A and B, hold results for many instructions, particularly mathematical and logical operations
performed by the 8051's central processing unit (CPU).

• The remaining 32 registers are arranged into four banks (B0–B3), each containing eight registers. These register banks
form part of the internal RAM memory and are essential to the mathematical core of the 8051.

• The A register (Accumulator) is the most versatile of the two CPU registers. It is used for many operations, including:
•Addition
•Subtraction
•Integer multiplication and division
•Boolean bit manipulations

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Additionally, the A register plays a crucial role in data transfers between the 8051 and external memory.
The B register is primarily used with the A register for multiplication and division operations. It has no
other dedicated function aside from storing temporary data.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Flags and the Program Status Word (PSW)

Flags are 1-bit registers used to store the results of specific program instructions. Other instructions can check the state of
these flags and make decisions accordingly. To facilitate easy access, these flags are grouped inside:
•Program Status Word (PSW) register
•Power Control (PCON) register

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Types of Flags in the 8051

The 8051 microcontroller has four math flags that automatically respond to arithmetic operations and three user-defined
flags that can be manually set or cleared by the programmer.
Math Flags (Set/Cleared Automatically by Arithmetic Operations)
1.Carry (C) – Set when a carry occurs in addition or a borrow occurs in subtraction.
2.Auxiliary Carry (AC) – Used in BCD (Binary-Coded Decimal) operations, set when there is a carry from bit 3 to bit 4.
3.Overflow (OV) – Indicates arithmetic overflow in signed number operations.
4.Parity (P) – Set if the number of 1s in the accumulator is even (Even Parity), and cleared if odd (Odd Parity)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

User Flags (Manually Controlled by the Programmer)


1.F0 – A general-purpose flag for user-defined operations.
2.GF0 & GF1 – Two additional general-purpose flags stored in the PCON register, which can be used to track program
conditions.

Program Status Word (PSW) Structure


The PSW register holds:
•The math flags
•The user-defined F0 flag
•Register bank select bits (to switch between four general-purpose register banks)
The GF0 and GF1 flags are located in the PCON register instead of the PSW.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Usage in Programming
•Math flags change automatically based on arithmetic operations (e.g., addition, subtraction, multiplication).
•User flags can be set or cleared manually using data move instructions (covered in Chapter 5).

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Internal RAM

The 8051 microcontroller has 128 bytes of internal RAM, which is divided into three distinct regions:

1. Register Banks (Address Range: 00h to 1Fh)


•The first 32 bytes (00h to 1Fh) form four banks of working registers.
•Each bank consists of eight registers named R0 to R7.
•The Program Status Word (PSW) bits RS0 and RS1 determine which bank is selected during program execution.
•On reset, Bank 0 is selected by default.
•The other banks can be used as general-purpose RAM if not actively selected.
Register Bank Addressing Example
•R0 of Bank 3 can be accessed either as R0 (if Bank 3 is selected) or as RAM address 18h (irrespective of selection).

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

2. Bit-Addressable RAM (Address Range: 20h to 2Fh)


•This area consists of 16 bytes (20h to 2Fh), forming 128 individual addressable bits (bit addresses: 00h to 7Fh).
•Each byte in this area contains 8 bits, which can be addressed either as a whole byte or as individual bits.
Bit Addressing Example
•Bit address 4Fh is the 7th bit of RAM byte address 29h.
•This area is useful for storing binary events (e.g., switch ON/OFF, LED state) without wasting an entire byte.

3. General-Purpose RAM (Address Range: 30h to 7Fh)


•The remaining 80 bytes (30h to 7Fh) can be used for storing variables, data, or stack operations.
•This section is only byte-addressable, meaning bits cannot be accessed individually.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Why Use Bit-Addressable RAM?


•When only a single bit is needed (e.g., a flag for a condition), using bit-addressable RAM is more memory-efficient
than using a full byte.
•This helps optimize memory usage in applications that involve boolean operations like status flags, switch states, or
interrupt triggers.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

The Stack and the Stack Pointer

1. What is the Stack?


•The stack is an area in internal RAM used to store and retrieve data quickly.
•It works in Last In, First Out (LIFO) order.
•Certain instructions (like PUSH and POP) use the stack for temporary data storage.
2. The Stack Pointer (SP) Register
•The Stack Pointer (SP) is an 8-bit register that holds the address of the top of the stack.
•The SP keeps track of where the last data byte was stored in the stack.
Stack Pointer Behavior
•When pushing data (PUSH instruction):
• The SP increments first before storing data.
• This means the stack grows upwards in RAM.
•When popping data (POP instruction):
• The byte is read first, then the SP decrements.
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

3. Default and Custom Stack Locations


•On reset, the SP is set to 07h (default).
•This means the stack starts at address 08h, avoiding register banks (00h - 07h).
•Programmers can change the SP to a higher RAM address to prevent overwriting important data.

4. Stack Limitations and Precautions


•The stack is limited by the size of internal RAM (128 bytes).
•If the stack grows too large, it may overwrite important data in:
• Register banks (00h – 1Fh)
• Bit-addressable RAM (20h – 2Fh)
• General-purpose RAM (30h – 7Fh)
•Programmers must ensure the stack does not exceed its allocated space.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

5. Best Practices for Stack Usage


✅ Place the stack high in RAM to avoid conflicts with register banks and bit-addressable memory.
✅ Monitor SP carefully when dealing with nested function calls and interrupts.
✅ Use stack efficiently to prevent stack overflow, which can cause program errors.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Special Function Registers

1. What Are Special Function Registers (SFRs)?


•SFRs are specific internal registers used for operations beyond general-purpose RAM.
•They are located in the address range 80h to FFh in the internal memory.
•Unlike regular RAM, SFRs control the microcontroller’s special functions, such as timers, serial communication,
interrupts, and I/O ports.

2. Features of SFRs
•SFRs are accessed like RAM but only in the upper memory range (80h – FFh).
•Some SFRs are bit-addressable (marked with an asterisk * in documentation).
• This means you can modify individual bits without affecting the rest of the register.
•Unused addresses in the SFR range should not be accessed, as they can cause unpredictable results.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Internal ROM

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Input / Output Pins Ports, and Circuits.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

1. General Structure of Port Pins


Each port pin is controlled by:
•A latch (flip-flop) that stores the pin state (1 or 0).
•Control Logic that manages data flow (input/output).
•Pull-up resistors (except for Port 0) to ensure a default high state when not actively driven.

An internal pull-up in a microcontroller is a built-in resistor that connects a digital input pin to the power supply
(Vcc), ensuring the pin reads a high logic level when not actively driven by another component

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

1. Port 0 (P0) Configuration


Functionality:
•Multiplexed Address/Data Bus (A0–A7): Used when interfacing with external memory.
•General I/O: Acts as a bidirectional port when no external memory is used.
•No Internal Pull-Up Resistors: Requires external pull-ups when used as an output.
Working:
•The flip-flop (latch) stores the data.
•Control logic decides whether to read or write.
•Enhancement-mode FET and Depletion-mode FET help switch between address/data and normal I/O modes.
Key Points:
•If used as an output, it needs external pull-up resistors.
•If used as an input, it floats when no external pull-up is provided.
•When connected to external memory, it functions as lower byte address/data lines.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

2. Port 1 (P1) Configuration


Functionality:
•Dedicated General Purpose I/O (GPIO).
•Internal Pull-Up Resistors Present → No need for external pull-ups.
Working:
•The latch stores the output value.
•The internal pull-up ensures that the pin is HIGH when not driven LOW.
•The control logic helps in reading and writing operations.
Key Points:
•Always used as a general I/O port.
•Unlike P0, it does not require external pull-ups.
•Suitable for simple digital input/output operations.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

3. Port 2 (P2) Configuration


Functionality:
•Multiplexed Address Bus (A8–A15) when external memory is used.
•General I/O otherwise.
•Internal Pull-Up Resistors Present.
Working:
•Works similarly to P1 when used for I/O.
•If external memory is used, it acts as high-order address bus (A8–A15).
•Control logic determines if it functions as address lines or general I/O.
Key Points:
•Used in external memory interfacing (higher address lines).
•Works like Port 1 when acting as an I/O.
•Has internal pull-ups, so no external resistors are needed

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
4. Port 3 (P3) Configuration
Functionality:
•Multifunctional Pins (Alternate Functions):
• RxD (P3.0) - Serial Data Input.
• TxD (P3.1) - Serial Data Output.
• INT0 (P3.2) - External Interrupt 0.
• INT1 (P3.3) - External Interrupt 1.
• T0 (P3.4) - Timer 0 External Input.
• T1 (P3.5) - Timer 1 External Input.
• WR (P3.6) - External Memory Write.
• RD (P3.7) - External Memory Read.
Working:
•It functions like P1/P2 but has additional control circuitry for special functions.
•Internal pull-ups ensure it stays HIGH by default.
Key Points:
•Used for communication, interrupts, and timers.
•Can still function as a normal I/O port.
•Internal pull-ups make it easier to use for digital logic.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Port 0

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Port l

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Port 2

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Port ·3

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

External Memory
The 8051 microcontroller has limited internal memory, but designers can expand both program (ROM) and data
(RAM) memory using external memory chips. Here’s a breakdown of how it works:

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

This circuit shows how external EPROM (Read-


Only Memory) and RAM (Random Access
Memory) are connected to the 8031
microcontroller. Since the 8031 has no internal
ROM, it requires external memory for storing
programs and data.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Components in the Circuit


1.8031 Microcontroller - Controls the system and communicates with external memory.
2.EPROM (27128, 16K) - Stores the program (read-only memory).
3.RAM (6264, 8K) - Used for temporary data storage (read/write memory).
4.74LS373 Latch - Temporarily holds the lower address byte.
5.Address and Data Buses - Used to transfer addresses and data between components.
6.Control Signals - ALE, PSEN, WR, and RD manage memory operations.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

Pin Connections and Functions


1. Address and Data Bus (Multiplexed)
•The 8031 microcontroller has Port 0 (P0) as multiplexed Address/Data (AD0–AD7).
•The lower 8-bits (A0–A7) of the address and data share the same pins.
•The higher 8-bits (A8–A15) are provided through Port 2 (P2).
2. Latch (74LS373) for Address Separation
•Since P0 is shared between address and data, we need to separate the lower address (A0–A7) from the
data.
•ALE (Address Latch Enable) signal controls this separation.
•The latch stores the lower address temporarily so that P0 can be used for data transfer afterward.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

3. EPROM (27128) - Program Storage


•Stores the program that the 8031 executes.
•Connected to A0–A13 (Address Lines).
•PSEN (Program Store Enable) is activated to read program
instructions from EPROM.
4. RAM (6264) - Data Storage
•Stores temporary data for calculations and variables.
•Connected to A0–A12 (Address Lines).
•Uses RD (Read) and WR (Write) control signals to access
data.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY

The image shows Figure 3.9 - External Memory Timing, which illustrates the timing sequence of accessing external
memory in the 8051 Microcontroller.
Explanation of the Timing Diagram
1.Address and Data Bus (Port 0 & Port 2)
1. Port 0 is multiplexed, meaning it carries lower address bits (A0–A7) initially and later switches to data lines
(D0–D7).
2. Port 2 provides the higher address bits (A8–A15).
2.ALE (Address Latch Enable) Pulse
1. The ALE (Address Latch Enable) signal is activated to latch the lower address (A0–A7) from Port 0 into an
external latch.
2. After latching, Port 0 is freed to be used for data transfer.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


BANGALORE INSTITUTE OF TECHNOLOGY
3.PSEN (Program Store Enable) Pulse
1. The PSEN signal is used when reading external ROM
(Program Memory).
Key Takeaways
2. When PSEN is low (active), the ROM contents are read
•The 8051 microcontroller can access
into the microcontroller. external memory by multiplexing Port 0.
•ALE helps to latch the lower address bits
3. This happens when the 8051 fetches instructions from
before Port 0 switches to data transfer.
external memory. •PSEN is used to enable external ROM,
ensuring instructions are fetched properly.
4. RD (Read) & WR (Write) Pulses
•RD and WR control access to external
1. These signals are used for accessing external RAM RAM, distinguishing between read and write
operations
(Data Memory).
2. RD (Read Enable) goes low when data is being read
from external RAM.
3. WR (Write Enable) goes low when writing data into
external RAM.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

You might also like