Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
39 views49 pages

Unit II Microcontroller Architecture

Uploaded by

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

Unit II Microcontroller Architecture

Uploaded by

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

Microcontroller

Architecture
Introduction to 8051
Architecture
• Introduced by Intel in 1980.
• An 8-bit microcontroller, which consists of a CPU, RAM, ROM, I/O ports,
timers, and serial communication ports all combined on one chip.
• Features of 8051:
 ROM: 4K Bytes
 RAM: 128 bytes
 TIMERS: 2
 I/O Pins: 32
 Serial Ports: 1
 Interrupts: 6
8051 Architecture
Internal Basic Components of
8051 Architecture
• CPU: Coordinates and oversees every operation performed by the
microcontroller.
• Interrupts: High-priority program requests to access the system buses.
It contains five types of interrupts:
Timer 0 overflow interrupt (TF0)
Timer 1 overflow interrupt (TF1)
External hardware interrupt (INT0)
External hardware interrupt (INT1)
Serial communication interrupt (RI/TI)
• Memory: Store operands and data for brief periods of time. In addition
to 128 bytes of data memory (RAM), the microcontroller 8051 includes 4
KB of code or program memory, or 4 KB ROM.
The 8051 microcontroller is composed of 128 bytes of internal
RAM. This is a volatile memory since its contents will be lost if
power is switched off. These 128 bytes of internal RAM are
divided into 32 working registers which in turn constitute 4
register banks (Bank 0-Bank 3) with each bank consisting of 8
registers (R0 - R7). There are 128 addressable bits in the
internal RAM.
• Bus: Collection of wires that is used as a data transfer or communication
channel.
 Address Bus: The 16-bit address bus is a component of 8051
microcontrollers. Transferring data from the central processing unit to memory
is its usual use.
 Data Bus: The data bus of an 8051 microcontroller has eight bits.
Transferring data from one peripheral place to another is often the usage for
it.
Two 16-bit counters and timers
• Oscillator: Executes timer functions.
are operated by the 8051. The oscillator inside the
microcontroller is utilized to operate the timers and counters.
8051 Microcontroller Pin
Diagram
• Pins 1 to 8 − These pins are known as Port 1. This port doesn’t serve any other functions.
It is a bi-directional I/O port.
• Pin 9 − It is a RESET pin, which is used to reset the microcontroller to its initial values.
• Pins 10 to 17 − These pins are known as Port 3. This port serves some functions like
interrupts, timer input, control signals, serial communication signals RxD and TxD, etc.
• Pins 18 & 19 − These pins are used for interfacing an external crystal to get the system
clock.
• Pin 20 − This pin provides the power supply to the circuit.
• Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher order
address bus signals are also multiplexed using this port.
• Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a
signal from the external program memory.
• Pin 30 − This is EA pin which stands for External Access input. It is used to enable/disable
the external memory interfacing.
• Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used to demultiplex
the address-data signal of port.
• Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower order address
and data bus signals are multiplexed using this port.
• Pin 40 − This pin is used to provide power supply to the circuit.
• 8051 microcontrollers have 4 I/O ports each of 8-bit, which
can be configured as input or output. Hence, total 32
input/output pins allow the microcontroller to be connected
with the peripheral devices.
• Pin configuration, i.e. the pin can be configured as 1 for
input and 0 for output as per the logic state.

• Port 0 −
• When the external memory is used , then the lower address byte (addresses
A0-A7) is applied on it,
• else all bits of this port are configured as input/output.
• Port 1
• P1 is a true I/O port as it doesn’t have any alternative functions as in P0,
but this port can be configured as general I/O only.

• Port 2
• P2 is similar to P0 when the external memory is used. Pins of this port
occupy addresses intended for the external memory chip. This port can
be used for higher address byte with addresses A8-A15.
• When no memory is added then this port can be used as a general
input/output port similar to Port 1.

• Port 3
• In this port, functions are similar to other ports except that the logic 1
must be applied to appropriate bit of the P3 register.
8051 Interrupts
• Interrupts are the events that temporarily suspend the main program,
pass the control to the external sources and execute their task. It then
passes the control to the main program where it had left off.

• 8051 has 5 interrupt signals, i.e. INT0, TFO, INT1, TF1, RI/TI. Each
interrupt can be enabled or disabled by setting bits of the IE register and
the whole interrupt system can be disabled by clearing the EA bit of the
same register.

• IE (Interrupt Enable) Register


• This register is responsible for enabling and disabling the interrupt. EA
register is set to one for enabling interrupts and set to 0 for disabling the
interrupts. Its bit sequence and their meanings are shown in the
following figure.
It disables all interrupts. When EA = 0 no interrupt will be acknowledged
EA IE.7
and EA = 1 enables the interrupt individually.

- IE.6 Reserved for future use.

- IE.5 Reserved for future use.

ES IE.4 Enables/disables serial port interrupt.

ET1 IE.3 Enables/disables timer1 overflow interrupt.

EX1 IE.2 Enables/disables external interrupt1.

ET0 IE.1 Enables/disables timer0 overflow interrupt.

EX0 IE.0 Enables/disables external interrupt0.


IP (Interrupt Priority) Register
We can change the priority levels of the interrupts by changing the
corresponding bit in the Interrupt Priority (IP) register as shown in the following
figure.

•A low priority interrupt can only be interrupted by the high priority interrupt,
but not interrupted by another low priority interrupt.
•If two interrupts of different priority levels are received simultaneously, the
request of higher priority level is served.
•If the requests of the same priority levels are received simultaneously, then
the internal polling sequence determines which request is to be serviced.
- IP.6 Reserved for future use.
- IP.5 Reserved for future use.
PS IP.4 It defines the serial port interrupt priority level.

PT1 IP.3 It defines the timer1 interrupt priority.

PX1 IP.2 It defines the external interrupt priority level.

PT0 IP.1 It defines the timer0 interrupt priority level.

PX0 IP.0 It defines the external interrupt of 0 priority level.


Special Function Registers
(SFRs
1. Serial Port Data Buffer (SBUF)
2. Timer/Counter Control (TCON)
3. Timer/Counter Mode Control (TMOD)
4. Serial Port Control (SCON)
5. Power Control (PCON)
6. Interrupt Priority (IP)
7. Interrupt Enable Control (IE)
Examples of 8051 MicroController

• Industrial Automation: 8051 microcontroller is used


in the Robotics and control systems.

• Consumer electronics: microwave ovens, remote


controllers, washing machines

• Automotive: Dashboard screens and engine control


devices.

• Medical devices: infusion pumps, patient monitoring


systems, etc
Advantages

• Versatility: Suitable for all type of the functions.

• Integration: Every necessary part on a single chip.

• Economical: Cost-effective for large-scale manufacturing.

• Particularly low power consumption is the design's purpose.

• The great reliability of the 8051 Microcontroller Architecture is well known.

• It offers an easy-to-understand instruction set, straightforward programming, and


user-friendly development tools.

• There are multiple uses with the advance application.


Disadvantages
• Limited Processing Capacity: Unsuitable for intricate
calculations.

• Outdated Interfaces: Certain versions don't follow modern


communication guidelines.

• Ethernet or USB connectivity are essential advanced


peripherals.

• The instruction set presents difficulties for code optimization


and programming.

• Code development and debugging are challenging due to the


outdated development tools.
Instruction Sets
• A set of instructions that the microcontroller's CPU can execute.
• Acts as the interface between software (programs) and hardware
(processor).
• Classification of 8051 Instructions:
 Data Transfer Instructions: Move data between registers, memory,
and ports.
Examples:
1. MOV A, #55H – Move immediate value to accumulator.
2. MOV R0, A – Move data from accumulator to register R0.
Supports direct, indirect, and immediate addressing modes.
 Arithmetic Instructions: Perform mathematical operations like
addition, subtraction, multiplication, and division.
Examples:
1. ADD A, R1 – Add the value in R1 to accumulator A.
2. MUL AB – Multiply accumulator (A) with B register.
 Logical Instructions: Perform bitwise operations and rotate
operations.
Examples:
1. ANL A, #0F0H – Perform AND operation with an immediate value.
2. CLR C – Clear the carry flag.
 Branching Instructions: Used for decision-making and program flow
control.
Examples:
1. SJMP LABEL – Short jump to a specific label.
2. CJNE A, #55H, LABEL – Compare accumulator with immediate
value and jump if not equal.
 Bit Manipulation Instructions: Operates on single bits for setting,
clearing, and testing.
Examples:
1. SETB P1.0 – Set bit 0 of Port 1.
2. JNB P3.7, LABEL – Jump if bit 7 of Port 3 is not set.
8051 Peripherals
• Input/Output Ports
• Timers/Counters
• Serial Communication Interface
• Interrupt Controller
• On-Chip Oscillator and Clock Circuit
• Internal Memory
• Power Control Features
8051 I/O Ports
• 4 Parallel I/O Ports (P0, P1, P2, P3):

• Each port has 8 pins, making a total of 32 I/O lines.

• Used for interfacing with external devices such as sensors, LEDs,


motors, etc.

• Port-Specific Features:
• P0: Dual-purpose, acts as an address/data bus during external
memory access (- ).
• P1: General-purpose I/O.
• P2: Dual-purpose, acts as an address bus for external memory
access.
• P3: Supports special functions like UART (RXD/TXD), interrupts,
timers, read and write operations.
P0, P1, P2 and P3 in detail
Timer/Counters

H
Timer/Counter modes (Controlled by TMOD Registe
Mode Description Operation
Mode 13-bit timer/counter Counts from
0 0x0000 to
0x1FFF
Enable
Mode 16-bit timer/counter Full 16-bit
1 range (0x0000
to 0xFFFF)
Mode 8-bit Auto-Reload Reloads a pre-
2 set value
when it
overflows

Mode Split Timer Mode Timer 0 acts


3 as two 8-bit
timers; Timer
1 stops.
Serial Communication
Interface
• Serial communication enables the 8051 microcontroller to exchange
data bit-by-bit over a single line, reducing the number of required pins. It
supports full-duplex UART (Universal Asynchronous
Receiver/Transmitter) communication.
Key Features of Serial Communication
1.Pins for Serial Communication:
1. TXD (Transmit Data): Pin P3.1 is used to send data.
2. RXD (Receive Data): Pin P3.0 is used to receive data.
2.Modes of Operation:
1. Configurable via the Serial Control (SCON) register.
2. Supports four modes for flexibility in communication.
INTERRUPTs in 8051
• 8051 have 5 interrupts and all are vectored interrupts.
• Two hardware interrupts: and
• Two timer overflow internal interrupts: TF0 and TF1.
• Serial Communication internal interrupts: Common for RI and TI.
• All the interrupts are controlled by IE and IP registers.

INTERRUPT Handling
• EA: Enable All PT2: Reserved
• ET2: Reserved PS: Priority Serial
• ES: Enable Serial PT1: Priority Timer 1
• ET1: Enable Timer 1 PX1: Priority
• EX1: Enable PT0: Priority Timer 0
• ETO: Enable Timer 0 PX0: Priority
• EXO: Enable High Priority: 1
• Enable: 1 and Disable: 0 Low Priority: 0
8051 Microcontroller Programming
in Assembly Language
• The Elements of an Assembly Language Programming:

1. Assembler Directives: ORG, DB, EQU, END

2. Instruction Set: Data Transfer Instructions, Arithmetic Instructions,


Logical Instructions, Branching Instructions and Bit Manipulation Instructions

3. Addressing Modes: Immediate Addressing Mode, Register


Addressing Mode, Direct Addressing Mode, Indirect Addressing Mode,
Base Index Addressing Mode
• MNEMONICS OF ASSEMBLY LANGUAGE

• ASSEMBLER DIRECTIVES:
a) ORG(origin): This directive indicates the start of the program.
b) DB(define byte): allows a string of bytes.

c) EQU (equivalent): The equivalent directive is used to equate address


of the variable.

d) END: The END directive is used to indicate the end of the program.
8051 Addressing modes:
1. Immediate Addressing Modes: 4. Indirect Addressing Modes:

5. Base Index
Addressing Mode: This addressing mode is used to read the data from
the external memory or ROM memory. All addressing
modes cannot read the data from the code memory.
2. Register Addressing Modes: The code must read through the DPTR register. The
DPTR is used to point the data in the code or external
memory.

3. Direct Addressing Modes:


Instruction Set:
• Data Transfer Instructions

• Arithmetic Instructions

• Logical Instructions

• Call and Jump Instructions


Important Instructions
Conditional Call and
Jump
Instruction Instructions
s
8051 microcontroller program example
8051 Interfacing
• Interfacing is the process of connecting external devices or
peripherals to a microcontroller for data exchange and control.
• Importance:
•Enables real-world applications.
•Facilitates communication with sensors, displays, memory devices,
and other modules.

Types of Interfacing:
1. Input Devices: Keyboards, switches, and sensors.
2. Output Devices: LEDs, 7-segment displays, LCDs.
3. Communication Interfaces: Serial (UART), I2C, SPI, CAN, LIN.
4. Memory Interfacing: External RAM and ROM.
8051 interfacing LED & 7
segment display

Example code (Toggle an LED): Example code (Display ‘0’):


MOV P1, #00H ; Turn off all LEDs SETB P1.0 ; Turn MOV P2, #3FH ; Send 0011 1111 to display 0
on LED connected to P1.0 CLR P1.0 ; Turn off LED
connected to P1.0
Automotive-Grade Microcontrollers (AGM)
• Automotive-grade microcontrollers are specialized microcontrollers designed to meet
the stringent requirements of automotive applications.
• Purpose:
1. Enhance reliability, safety, and performance in automotive systems.
2. Operate under extreme environmental conditions like temperature, vibration, and
electromagnetic interference (EMI).
• Features of AGM:
1. Robust Design: Operate in a wide temperature range (-40°C to 150°C), Resistant to
electrical noise and voltage fluctuations.
2. Integrated Safety Mechanisms: ISO 26262 compliance for functional safety, Fault
detection and recovery features, Advanced Communication Protocols, Support for CAN,
LIN, FlexRay, and Ethernet.
3. Power Efficiency: Low-power modes to optimize fuel efficiency in electric vehicles
4. High-Performance Cores: Equipped with ARM Cortex cores or proprietary
architectures for real-time control.
AGM Examples:
• NXP S32K Series Infineon
AURIX Series

• Designed for body electronics and • Multi-core architecture for safety-critical systems.
motor control. • Focus on powertrain and ADAS.
• Integrated CAN and LIN support.
• Texas Instruments TMS570 Renesas RH850

• Functional safety and real-time performance. • High performance with low power consumption.
• Suitable for airbag systems and braking controls. • Ideal for engine control and safety systems.

You might also like