8051 Microcontroller Part 1
8051 Microcontroller Part 1
Introduction
P vs C Architecture Operation Registers
Introduction
A microcontroller is a microprocessor specifically designed
for control applications. The microcontroller has the CPU, RAM, ROM, timer/counter, parallel and serial ports and interrupt circuits fabricated into a single IC chip using VLSI technology. It is often called a computer on a chip. The microcontroller is most efficiently used in systems that has a fixed program for a dedicated application. Eg; in a keyboard, microwave oven, ATM, automobile engines and so on. Very often the terms embedded processor and microcontroller are used interchangeably.
digital computers whereas microcontrollers are intended to be special purpose digital controllers. Microprocessors contain a CPU, memory addressing circuits, and interrupt handling circuits whereas microcontrollers have these features as well as timers, parallel and serial I/O ports, and internal RAM and ROM. Microprocessors few pins are multiplexed whereas in microcontrollers most of the pins have dual functions.
microcontroller has high ROM to RAM ratio. Microprocessor has one or two types of bit handling instructions whereas microcontroller has many. Microprocessor cannot function as a computer without addition of many external parts whereas microcontroller can function as a computer with out addition of any external parts.
Features
8-bit CPU optimized for control applications Extensive Boolean processing (single-bit logic) capabilities 64K Program Memory address space 64K Data Memory address space Up to 4K bytes of on-chip Program Memory 128 bytes of on-chip Data RAM 32 bi-directional and individually addressable I/O lines Two 16-bit timer/counters
Features
P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RXD) P3.0
(Serial)
40
Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8)
Ext Memory Address Ext Memory Access Control Ext Memory Address
39
38
37
36
8051
35
34
33
32
10
31
11
30
12
29
13
28
14
27
15
26
16
25
17
24
18
23
XTAL 1 GND
19
22
20
21
8-bit registers -----------------16-bit registers ----------------Stack size ----------------------Internal ROM -----------------Internal RAM ----------------SFRs (RAM) -------------------Flags ---------------------------Timers -------------------------Parallel ports ------------------Serial port ----------------------
= 34 = 2 (PC and DPTR) = 128 Byte = 4KB = 128 Byte = 128 Byte =4 = Two 16-bit = Four 8-bit (P0-P3) =1
is used to hold the address of byte in memory. PC: points to the next instruction to be executed. The PC is automatically incremented after every instruction byte is fetched and may also be altered by certain instructions. As PC is 16 bits wide, the 8051 can access program addresses from 0000H to FFFFH. DPTR: register is made up of two 8-bit registers, named DPH, and DPL, which are used to provide memory addresses for internal and external code access and external data access. It can be specified by its 16-bit name, DPTR or by each individual byte name DPH & DPL.
A & B Registers
The 8051 contains 34 general-purpose or working
registers. Two of these registers A and B hold results of arithmetic and logical operations of the 8051 CPU. The register A is also used for all data transfers between the 8051 and any external memory. The register B is used with the A register for multiplication and division operations. The instruction MUL AB, multiplies the 8-bit unsigned values in A and B and leave the result in A (low byte) and B (high byte). The instruction DIV AB, divides A by B leaving quotient in A and remainder in B.
RAM in four banks, bank0 to bank3. The registers within each bank are labeled R0 through R7. The bank that is presently in use (active) is defined by the setting of two bank select bits in the PSW.
Memory Organization
Logical separation of data and program memory
Separate address spaces for Program (ROM) and Data (RAM)
Memory Allow Data Memory to be accessed by 8-bit addresses quickly and manipulated by 8-bit CPU
Data Memory RAM Includes 128 bytes of on-chip Data Memory which are more easily accessible directly by its instructions There is also a number of Special Function Registers (SFRs) Internal Data Memory contains four banks of eight registers and a special 32-byte long segment which is bit addressable by 8051 bit-instructions