8051 Clock and Instruction Cycle
In 8051, one instruction cycle consists of twelve (12) clock cycles. Instruction cycle is sometimes called as Machine cycle by some authors.
Fig 4.5 : Instruction cycle of 8051
In 8051, each instruction cycle has six states (S 1 - S 6 ). Each state has two pulses (P1 and P2)
128 bytes of Internal RAM Structure (lower address space)
Fig 4.6: Internal RAM Structure
The lower 32 bytes are divided into 4 separate banks. Each register bank has 8 registers of one byte each. A register bank is selected depending upon two bank select bits in the PSW register. Next 16bytes are bit addressable. In total, 128bits (16X8) are available in bitaddressable area. Each bit can be accessed and modified by suitable instructions. The bit addresses are from 00H (LSB of the first byte in 20H) to 7FH (MSB of the last byte in 2FH). Remaining 80bytes of RAM are available for general purpose.
Internal Data Memory and Special Function Register (SFR) Map
Fig 4.6 : Internal Data Memory Map
The special function registers (SFRs) are mapped in the upper 128 bytes of internal data memory address. Hence there is an address overlap between the upper 128 bytes of data RAM and SFRs. Please note that the upper 128 bytes of data RAM are present only in the 8052 family. The lower128 bytes of RAM (00H - 7FH) can be accessed both by direct or indirect addressing while the upper 128 bytes of RAM (80H - FFH) are accessed by indirect addressing.The SFRs (80H - FFH) are accessed by direct addressing only. This feature distinguishes the upper 128 bytes of memory from the SFRs, as shown in fig 4.6.
SFR Map
The set of Special Function Registers (SFRs) contains important registers such as Accumulator, Register B, I/O Port latch registers, Stack pointer, Data Pointer, Processor Status Word (PSW) and various control registers. Some of these registers are bit addressable (they are marked with a * in the diagram below). The detailed map of various registers is shown in the following figure.
Address
F8H | ||||||||
F0H | B* | |||||||
E8H | ||||||||
E0H | ACC* | |||||||
D8H | ||||||||
D0H | PSW* | |||||||
C8H | (T2CON)* | (RCAP2L) | (RCAP2H) | (TL2) | (TH2) | |||
C0H | ||||||||
B8H | IP* | |||||||
B0H | P3* | |||||||
A8H | IE* | |||||||
A0H | P2* | |||||||
98H | SCON* | SBUF | ||||||
90H | P1* | |||||||
88H | TCON* | TMOD | TL0 | TL1 | TH0 | TH1 | ||
80H | P0* | SP | DPL | DPH | PCON |
Fig 4.7: SFR Map
It should be noted hat all registers appearing in the first column are bit addressable. The bit address of a bit in the register is calculated as follows. Bit address of 'b' bit of register 'R' is
Address of register 'R' + b
where 0 ≤ b ≤ 7
Processor Status Word (PSW) Address=D0H
CY | AC | F0 | RS1 | RS0 | OV | - | P |
Fi g 4.8: Processor Status Word
PSW register stores the important status conditions of the microcontroller. It also stores the bank select bits (RS1 & RS0) for register bank selection
Interfacing External Memory
If external program/data memory are to be interfaced, they are interfaced in the following way.
Fig 4.9: Circuit Diagram for Interfacing of External Memory
External program memory is fetched if either of the following two conditions are satisfied.
tells the outside world whether the external memory fetched is program memory or data memory.
is user configurable.
is processor controlled.
8051 Addressing Modes
8051 has four addressing modes.
1. Immediate Addressing :
Data is immediately available in the instruction.
For example -
ADD A, #77; Adds 77 (decimal) to A and stores in A
ADD A, #4DH; Adds 4D (hexadecimal) to A and stores in A
MOV DPTR, #1000H; Moves 1000 (hexadecimal) to data pointer
2. Bank Addressing or Register Addressing : This way of addressing accesses the bytes in the current register bank. Data is available in the register specified in the instruction. The register bank is decided by 2 bits of Processor Status Word (PSW).
For example-
ADD A, R0; Adds content of R0 to A and stores in A
3.. Direct Addressing :
The address of the data is available in the instruction.
For example -
MOV A, 088H; Moves content of SFR TCON (address 088H)to A
4. Register Indirect Addressing :
The address of data is available in the R0 or R1 registers as specified in the instruction.
For example -
MOV A, @R0 moves content of address pointed by R0 to A
External Data Addressing :
Pointer used for external data addressing can be either R0/R1 (256 byte access) or DPTR (64kbyte access).
For example -
MOVX A, @R0; Moves content of 8-bit address pointed by R0 to A
MOVX A, @DPTR; Moves content of 16-bit address pointed by DPTR to A
External Code Addressing :
Sometimes we may want to store non-volatile data into the ROM e.g. look-up tables. Such data may require reading the code memory. This may be done as follows -
MOVC A, @A+DPTR; Moves content of address pointed by A+DPTR to A
MOVC A, @A+PC; Moves content of address pointed by A+PC to A
1. What is the role of the clock in the 8051 microcontroller? | ![]() |
2. How does the clock affect the instruction cycle in the 8051 microcontroller? | ![]() |
3. Can the clock frequency be changed in the 8051 microcontroller? | ![]() |
4. What is the maximum clock frequency supported by the 8051 microcontroller? | ![]() |
5. How does the clock frequency affect the overall performance of the 8051 microcontroller? | ![]() |