0% found this document useful (0 votes)
25 views

UNIT 1 Architecture of Microcontroller 8051

The document provides an overview of the architecture and features of the 8051 microcontroller, highlighting its components such as CPU, memory, I/O ports, timers, and communication protocols. It also details the variants of the 8051 family, their applications, and the internal and external memory organization. Additionally, it explains the Special Function Registers (SFRs) and timer modes, emphasizing their role in embedded systems and real-time operations.

Uploaded by

sa6514941
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)
25 views

UNIT 1 Architecture of Microcontroller 8051

The document provides an overview of the architecture and features of the 8051 microcontroller, highlighting its components such as CPU, memory, I/O ports, timers, and communication protocols. It also details the variants of the 8051 family, their applications, and the internal and external memory organization. Additionally, it explains the Special Function Registers (SFRs) and timer modes, emphasizing their role in embedded systems and real-time operations.

Uploaded by

sa6514941
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/ 15

UNIT 1: Architecture of Microcontroller 8051

### 1.1 Features of Microcontrollers


Microcontrollers are compact integrated circuits designed to manage specific tasks in embedded systems.
Their key features include:
1. Central Processing Unit (CPU): Typically less powerful than a microprocessor but optimized for specific
tasks.
2. Memory:
- Program Memory (ROM/Flash): Stores firmware or program code.
- Data Memory (RAM): For temporary data storage during operation.
3. I/O Ports: Digital and analog input/output ports for interfacing with external devices such as sensors,
actuators, and displays.
4. Timers and Counters: Used for time-based operations, event counting, and generating delays.
5. Interrupt Control: Supports interrupt-driven operations for real-time responsiveness.
6. Serial Communication: Protocols like UART, SPI, and I²C enable communication with other devices.
7. Analog-to-Digital Converter (ADC): Converts analog signals to digital for processing.
8. Digital-to-Analog Converter (DAC): Converts digital signals to analog (in some microcontrollers).
9. Power Management: Includes low-power modes and features like watchdog timers for reliable operation.
10. Integrated Peripherals: Built-in components like PWM generators, Ethernet controllers, and motor
controllers.
11. Small Size and Low Power Consumption: Designed for embedded applications, emphasizing compact
form and energy e iciency.
12. Programmable: Can be reprogrammed for di erent tasks using specialized development environments.

### 1.2 Comparison of Microprocessors and Microcontrollers


### 1.3 Details of the 8051 Microcontroller Family Chips

The 8051 Microcontroller family, developed by Intel, is widely used in embedded systems. Key details
include:

#### Features of 8051 Microcontroller:


1. CPU: 8-bit processor.
2. Memory:
- 4 KB on-chip ROM (program memory).
- 128 bytes on-chip RAM (data memory).
3. I/O Ports:
- 4 I/O ports (each 8 bits wide).
- Supports both input and output functions.
4. Timers/Counters:
- Two 16-bit timers/counters for event counting and generating delays.
5. Interrupts:
- 5 interrupt sources (2 external and 3 internal).
6. Oscillator: Uses an external quartz crystal oscillator with a frequency range of 1 MHz to 12 MHz.
7. Serial Communication:
- UART for asynchronous serial communication.
8. Power Management:
- Idle mode and Power-down mode for energy e iciency.

#### Variants of 8051 Family Chips:


1. 8052: Enhanced version of 8051, with:
- 8 KB ROM, 256 bytes RAM.
- Three 16-bit timers.
- More interrupt sources.
2. 8031: ROM-less version; requires external program memory.
3. 8751: EPROM-based version, allowing reprogrammable memory.
4. AT89C51 (by Atmel): Flash memory-based version, widely used in modern applications.

#### Applications:
- Industrial automation.
- Consumer electronics (microwaves, washing machines).
- Robotics and IoT devices.
- Automotive systems.

### 1.4 Functional Block Diagram of the 8051 Microcontroller


The functional block diagram of the 8051 microcontroller includes the following key components. Below is a
description of their functions.
#### Components and Their Functions:

1. CPU (Central Processing Unit):


- Executes instructions fetched from the program memory.
- Manages operations, including arithmetic, logic, and control functions.

2. Program Memory (ROM/Flash):


- Stores the program code that the CPU executes.
3. Data Memory (RAM):
- Provides temporary storage for data and variables during execution.

4. I/O Ports (P0, P1, P2, P3):


- Four 8-bit ports (P0, P1, P2, P3) for interfacing with external devices, sensors, or actuators.

5. Timers and Counters:


- Two 16-bit timers/counters (T0 and T1) for timing operations and event counting.

6. Serial Port:
- Facilitates serial communication using UART (Universal Asynchronous Receiver-Transmitter).

7. Oscillator:
- Provides the clock signal for timing and synchronization using an external crystal.

8. Interrupt Control:
- Supports interrupt-driven operations with five interrupt sources (2 external and 3 internal).

9. Bus Control Unit:


- Manages data flow between CPU, memory, and peripherals using data, address, and control buses.

10. PSW (Program Status Word):


- Indicates the status of the CPU, including carry, auxiliary carry, parity, and overflow flags.

11. Accumulator (A):


- Primary register used for arithmetic and logic operations.

12. B Register:
- Auxiliary register used for multiplication and division operations.

13. Special Function Registers (SFRs):


- Control registers for I/O, timers, and interrupt configuration.
### 1.5 Pin Diagram of the 8051 Microcontroller

The 8051 microcontroller comes in a 40-pin DIP (Dual Inline Package). Each pin's function is specified as
follows:

#### Pin Functions:

1. Port 0 (Pins 32–39):


- Dual-purpose: General I/O or lower byte of the external address/data bus.
- Requires pull-up resistors when used as I/O.

2. Port 1 (Pins 1–8):


- Dedicated I/O port with no alternate functions.

3. Port 2 (Pins 21–28):


- Dual-purpose: General I/O or higher byte of the external address bus.

4. Port 3 (Pins 10–17):


- Dual-purpose: General I/O or specialized functions:
- P3.0 (RXD): Serial data input.
- P3.1 (TXD): Serial data output.
- P3.2 (INT0): External interrupt 0.
- P3.3 (INT1): External interrupt 1.
- P3.4 (T0): Timer 0 input.
- P3.5 (T1): Timer 1 input.
- P3.6 (WR): Write control signal for external memory.
- P3.7 (RD): Read control signal for external memory.

5. VCC (Pin 40):


- Power supply (+5V).

6. GND (Pin 20):


- Ground connection.

7. XTAL1 (Pin 19) and XTAL2 (Pin 18):


- Connections for the external crystal oscillator.

8. ALE (Pin 30):


- Address Latch Enable: Used to demultiplex the address/data bus.

9. PSEN (Pin 29):


- Program Store Enable: Reads external program memory.

10. EA (Pin 31):


- External Access Enable: Determines whether the microcontroller accesses internal or external program
memory.

11. RST (Pin 9):


- Reset: Resets the microcontroller to its initial state when activated.
### Internal Memory Organization of 8051

The 8051 microcontroller has internal memory comprising 128 bytes of RAM and 4 KB of ROM (on-chip
memory). The internal memory is divided into distinct sections for e icient operation. Here's an explanation
along with a diagram.

#### Internal RAM Organization (128 Bytes)


1. General-Purpose Registers (00H–1FH)
- The first 32 bytes (00H to 1FH) are divided into four banks, each containing 8 registers (R0 to R7).
- Bank selection is controlled by the PSW register (RS0 and RS1 bits).

2. Bit-Addressable Memory (20H–2FH)


- 16 bytes of memory (20H to 2FH) where each bit can be directly addressed.
- Used for flags, toggles, and bit-level control tasks.

3. General-Purpose RAM (30H–7FH)


- 80 bytes of memory for general-purpose data storage.

#### Special Function Registers (SFRs)


- Occupies the address range 80H to FFH.
- SFRs control specific microcontroller functions like timers, interrupts, I/O ports, and serial
communication.
- Not all addresses in this range are used.
#### Internal ROM Organization
- 4 KB on-chip ROM is used for storing program code.
- Program Counter (PC) accesses ROM, and its address space ranges from 0000H to 0FFFH.

### Diagram: Internal Memory Organization


### External Memory Organization of 8051

The 8051 microcontroller supports external memory interfacing to expand program and data memory
beyond its on-chip limits.

#### External Program Memory


- The 8051 can address up to 64 KB of external program memory.
- When program memory exceeds 4 KB, the EA pin (External Access) is set low, allowing the microcontroller
to fetch instructions from external ROM.

#### External Data Memory


- Up to 64 KB of external data memory can be addressed using the MOVX instruction.
- Data memory is accessed by:
- 16-bit Address Bus: Provides the address.
- Data Bus (8-bit): Transfers data between microcontroller and external memory.

#### Interfacing Modes


1. Separate External Program and Data Memory
- Program memory (ROM) and data memory (RAM) are interfaced separately.
- Separate control signals di erentiate between program and data memory operations.
2. Combined Program and Data Memory
- A single memory module stores both program and data.
- Address decoding di erentiates between program code and data.
### Diagram: External Memory Organization

This organization allows the 8051 to operate e iciently in embedded systems with larger memory
requirements, o ering flexibility in program and data storage.

### Special Function Registers (SFRs) in 8051


Special Function Registers (SFRs) are registers in the address range 80H to FFH. They control specific
operations and features of the microcontroller. Here's a list of the important SFRs and their functions:

#### List of SFRs and Functions

| SFR | Address | Function |


|----------|-------------|-----------------------------------------------------------------------------------------------|
| ACC | 0xE0 | Accumulator: Used for arithmetic and logic operations. |
|B | 0xF0 | Auxiliary register: Used in multiplication and division operations. |
| PSW | 0xD0 | Program Status Word: Stores flags (carry, auxiliary carry, overflow, etc.) and bank
selection bits. |
| SP | 0x81 | Stack Pointer: Points to the top of the stack in internal RAM. |
| DPTR | 0x82/83 | Data Pointer: A 16-bit register (DPL and DPH) used for addressing external memory.
|
| PCON | 0x87 | Power Control: Controls power modes and serial baud rate settings. |
| TCON | 0x88 | Timer Control: Controls the operation of timers and external interrupts. |
| TMOD | 0x89 | Timer Mode: Sets the operating modes of timers. |
| TL0 | 0x8A | Timer 0 Low Byte: Holds the lower 8 bits of Timer 0 count value. |
| TH0 | 0x8C | Timer 0 High Byte: Holds the upper 8 bits of Timer 0 count value. |
| TL1 | 0x8B | Timer 1 Low Byte: Holds the lower 8 bits of Timer 1 count value. |
| TH1 | 0x8D | Timer 1 High Byte: Holds the upper 8 bits of Timer 1 count value. |
| SCON | 0x98 | Serial Control: Configures serial communication (mode, enable, receive/transmit flags).
| SBUF | 0x99 | Serial Bu er: Holds data for serial transmission or reception. |
| P0 | 0x80 | Port 0 Latch: Used for data transmission/reception at Port 0. |
| P1 | 0x90 | Port 1 Latch: Used for data transmission/reception at Port 1. |
| P2 | 0xA0 | Port 2 Latch: Used for data transmission/reception at Port 2. |
| P3 | 0xB0 | Port 3 Latch: Used for data transmission/reception at Port 3. |
| IE | 0xA8 | Interrupt Enable: Enables or disables interrupts. |
| IP | 0xB8 | Interrupt Priority: Sets interrupt priority levels. |

### Explanation of PSW Register (Program Status Word)

The PSW (Program Status Word) is an 8-bit SFR located at address 0xD0. It holds flags and status bits used
to indicate the state of the processor and the results of operations.

#### Bitwise Representation of PSW:

| CY | AC | F0 | RS1 | RS0 | OV | 0 | P |

- CY (Carry Flag, Bit 7): Set when there's a carry in arithmetic operations or a borrow in subtraction.
- AC (Auxiliary Carry, Bit 6): Indicates carry/borrow between lower nibbles in binary addition/subtraction.
- F0 (User Flag, Bit 5): User-defined general-purpose flag.
- RS1, RS0 (Register Bank Select, Bits 4-3): Select one of the four register banks:
- 00: Bank 0 (00H–07H)
- 01: Bank 1 (08H–0FH)
- 10: Bank 2 (10H–17H)
- 11: Bank 3 (18H–1FH)
- OV (Overflow Flag, Bit 2): Set if an arithmetic operation causes an overflow.
- Bit 1 (Reserved): Always 0.
- P (Parity Flag, Bit 0): Set if the accumulator (ACC) contains an odd number of 1s (odd parity).

### SFRs Associated with Timer/Counters

The 8051 has two 16-bit timers/counters (Timer 0 and Timer 1) controlled by specific SFRs.

#### 1. TMOD (Timer Mode Register, 0x89)


- Configures the modes of Timer 0 and Timer 1.
- Bitwise Representation:

| GATE1 | C/T1 | M1 | M0 | GATE0 | C/T0 | M1 | M0 |

- GATE (Gate Control): Enables timer based on external interrupt.


- C/T (Counter/Timer): Selects mode (Timer: internal clock; Counter: external pulses).
- M1, M0: Timer mode selection.

#### 2. TCON (Timer Control Register, 0x88)


- Controls the start/stop of timers and monitors overflow flags.
- Bitwise Representation:

| TF1 | TR1 | TF0 | TR0 | IE1 | IT1 | IE0 | IT0 |

- TF (Timer Overflow): Set when timer overflows.


- TR (Timer Run): Starts/stops the timer.
- IE, IT (Interrupt Flags): Control external interrupts.

#### 3. TLx and THx (Timer Registers)


- TL0/TH0 (Timer 0 Low/High Bytes): Store the 16-bit timer count value for Timer 0.
- TL1/TH1 (Timer 1 Low/High Bytes): Store the 16-bit timer count value for Timer 1.

### SFR Usage in Timers Example

- To configure Timer 0 in Mode 2 (8-bit auto-reload) and start the timer:


- TMOD = 0x02 (0000 0010)
- TCON = 0x10 (0001 0000) --> TR0 bit set to start the timer.

These SFRs work together to provide flexible timer and counter functionalities in embedded applications.

### 1.11 Modes of Operations of Counters & Timers in 8051

The 8051 microcontroller has two timers, Timer 0 and Timer 1, which can operate in four di erent modes.
Each timer can be configured to operate as a timer (counting internal clock pulses) or a counter (counting
external pulses).

#### Timer Modes

The Timer Mode is set using the TMOD (Timer Mode) register. The four modes are:

1. Mode 0 (13-bit Timer Mode):


- The timer operates as a 13-bit timer/counter.
- It uses the lower 8 bits of the timer register (THx) and the lower 5 bits of TLx.
- Maximum count value is \(8192\) (13-bit), and when it overflows, it resets to zero.

2. Mode 1 (16-bit Timer Mode):


- The timer operates as a 16-bit timer/counter.
- Both TLx and THx registers are used as an unsigned 16-bit counter.
- Maximum count value is \(65,536\), after which it resets on overflow.

3. Mode 2 (8-bit Auto-Reload Mode):


- Only the lower 8 bits (TLx) are used, while THx holds the reload value.
- When TLx overflows, it automatically reloads with the value from THx.
- Maximum count value is \(256\).

4. Mode 3 (Split Timer Mode):


- Timer 0 is split into two 8-bit timers (TL0 and TH0), which can function independently.
- Timer 1 is una ected in this mode and can operate in any other mode.
- Only applicable to Timer 0.
#### Counter Mode

In Counter Mode, the timers count external events rather than internal clock pulses. This mode is selected
by setting the C/T (Counter/Timer) bit in the TMOD register to 1. The external pulses are fed through T0 (for
Timer 0) and T1 (for Timer 1) pins. When the C/T bit is 1, the timer functions as a counter, incrementing on
each pulse on the corresponding external pin.

### 1.12 Interrupts of 8051

The 8051 microcontroller has five interrupts:

1. INT0 (External Interrupt 0)


2. INT1 (External Interrupt 1)
3. Timer 0 Overflow Interrupt
4. Timer 1 Overflow Interrupt
5. Serial Communication Interrupt

Each interrupt has a designated priority and a vector address associated with it:

### 1.13 SFRs Associated with Interrupts of 8051

The 8051 has several Special Function Registers (SFRs) to manage interrupts:

1. IE (Interrupt Enable Register):


- Controls the enable/disable status of each interrupt.
- Bits in the IE register:
- EA (Enable All): Master enable/disable for all interrupts.
- ET2: Enable Timer 2 Interrupt (used in certain 8051 variants).
- ES: Enable Serial Port Interrupt.
- ET1: Enable Timer 1 Interrupt.
- EX1: Enable External Interrupt 1.
- ET0: Enable Timer 0 Interrupt.
- EX0: Enable External Interrupt 0.

plaintext
IE Register (Bit Addressable):
EA | — | ET2 | ES | ET1 | EX1 | ET0 | EX0

2. IP (Interrupt Priority Register):


- Determines the priority level of each interrupt.
- If an interrupt has a higher priority, it can interrupt a currently running interrupt with a lower priority.
- Bits in the IP register:
- PT2: Priority for Timer 2 Interrupt (only in certain variants).
- PS: Priority for Serial Port Interrupt.
- PT1: Priority for Timer 1 Interrupt.
- PX1: Priority for External Interrupt 1.
- PT0: Priority for Timer 0 Interrupt.
- PX0: Priority for External Interrupt 0.

plaintext
IP Register (Bit Addressable):
— | — | PT2 | PS | PT1 | PX1 | PT0 | PX0

3. TCON (Timer Control Register):


- Controls the external interrupts and timer overflow flags.
- Bits in the TCON register related to interrupts:
- IE0: External Interrupt 0 edge flag.
- IT0: Interrupt type control for INT0 (level/edge).
- IE1: External Interrupt 1 edge flag.
- IT1: Interrupt type control for INT1 (level/edge).

plaintext
TCON Register (Bit Addressable):
TF1 | TR1 | TF0 | TR0 | IE1 | IT1 | IE0 | IT0

### 1.14 SFRs Associated with Serial Communication of 8051

The 8051 microcontroller has several Special Function Registers (SFRs) specifically for handling serial
communication. The primary SFRs for serial communication are SBUF, SCON, and PCON.

1. SBUF (Serial Bu er Register):


- It is an 8-bit register used to hold data to be transmitted or received.
- When data is written to SBUF, it is sent out through the serial port.
- When data is received via the serial port, it is loaded into SBUF for reading.
- SBUF acts as two registers: one for transmit data and one for receive data.

2. SCON (Serial Control Register):


- Controls the configuration and status of serial communication.
- It is an 8-bit register that sets the serial communication mode, the reception/transmission status, and
various flags.

- SM0 and SM1: Together determine the serial communication mode (Mode 0, 1, 2, or 3).
- REN: Receiver Enable; allows reception of data when set to 1.
- TI: Transmit Interrupt flag; set to 1 when transmission is complete.
- RI: Receive Interrupt flag; set to 1 when data is received.

3. PCON (Power Control Register):


- Primarily used for power control, but PCON also contains the SMOD bit, which doubles the baud rate
when set.

### 1.15 Modes of Operation of Serial Communication with 8051

The 8051 microcontroller supports four modes for serial communication, determined by the SM0 and SM1
bits in the SCON register:

1. Mode 0 (Shift Register Mode):


- Operates as an 8-bit shift register.
- Uses RXD for both transmitting and receiving data, and TXD for clock pulses.
- Fixed baud rate: 1/12th of the oscillator frequency.
- Mostly used for synchronous communication.

2. Mode 1 (8-bit UART Mode):


- 8-bit data transmission with start and stop bits, making it suitable for UART (Universal Asynchronous
Receiver/Transmitter) communication.
- Variable baud rate, set by Timer 1 overflow rate.
- Commonly used for standard asynchronous communication.

3. Mode 2 (9-bit UART Mode, Fixed Baud Rate):


- 9-bit data transmission, with a 9th bit often used for address/data distinction in multiprocessor
communication.
- Fixed baud rate: 1/32nd or 1/64th of the oscillator frequency.
- Useful for multiprocessor communication environments.

4. Mode 3 (9-bit UART Mode, Variable Baud Rate):


- Similar to Mode 2 but with a variable baud rate.
- Baud rate set by Timer 1.
- Like Mode 2, it’s useful for multiprocessor communication.

### 1.16 Various I/O Ports of 8051

The 8051 microcontroller has four I/O ports (Port 0, Port 1, Port 2, and Port 3), each 8 bits wide, providing a
total of 32 I/O pins. Each port has special features beyond simple digital I/O.

1. Port 0 (P0.0 – P0.7):


- Functions as a general-purpose I/O port.
- Dual Function: When used as I/O, it needs external pull-up resistors because it is an open-drain port.
- In external memory access mode, it serves as the lower 8 bits of the address/data bus (AD0–AD7).
- This port is often used for multiplexed address and data bus in systems with external memory.

2. Port 1 (P1.0 – P1.7):


- Purely a general-purpose I/O port.
- Each pin has an internal pull-up resistor, so it can be directly used as digital I/O without external resistors.
- It does not have any alternate function, making it a dedicated I/O port.

3. Port 2 (P2.0 – P2.7):


- Functions as a general-purpose I/O port.
- In external memory access mode, it provides the higher 8 bits of the address bus (A8–A15).
- When not accessing external memory, it serves as a general I/O port.
- Contains internal pull-up resistors, so it can be used directly for digital I/O.

4. Port 3 (P3.0 – P3.7):


- General-purpose I/O port, but with alternate functions.
- Each pin has an alternate function related to serial communication, external interrupts, timers, and
control signals for external memory access.

You might also like