8051 Microcontroller Architecture
8051 Microcontroller Architecture
Module III
Microcontrollers
Microcontroller Overview
8051 Architecture
Microcontrollers
MIcrocontrollers
Microprocessor, memory and I/O devices are build on a single chip is came to known
as microcontroller.
It is a general purpose device like microprocessor, but it meant to read data, perform
limited calculations and control its environment based on that data.
It is used to control the operation of a machine using a fixed program stored in ROM.
It uses limited set of instructions to move data and code.
It’s pins are programmable.
It can handle data in bit, byte and word size.
Block Diagram of Microcontroller
Comparing Microprocessors and Microcontrollers
Microprocessors Microcontrollers
8051
Block diagram
The 8051 architecture
The oscillator circuit is considered as the heart of 8051 that generates the clock pulses by
which all internal operations are synchronized.
Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an oscillator.
The circuit consists of a quartz crystal and capacitors
State:
It is the basic time interval for discrete operations such as
fetching opcode, decoding opcode, executing opcode...
Machine Cycle:
The smallest time interval to accomplish any simple instruction
There are 2 ALE (Address Latch Enable) pulses per machine cycle and it is used to access
external memory.
In one machine cycle, 2 bytes of a single instruction is fetched and executed.
The 8051 architecture
8051
Programming Model
The 8051 architecture
A Register B Register
It is the most versatile of the two Used with ‘A’ register for
registers. multiplication and division
It is used for many operations operations
such as arithmetic, logic and bit For other instructions, it can be
manipulations. used as an 8 bit general purpose
Used for all data transfer register (ie, storing data)
between the 8051 and any
external memory.
The 8051 architecture
Flags
These are 1 bit registers provide to store the results of certain program instructions.
Other instructions can test the condition of flag and make decision based on the flag states.
flags are grouped inside the Program Status Word (PSW) & Power Control registers (PCON).
There are 4 Math flags and 3 General purpose user flags
Among the 3 user flags, GF0 & GF1 are stored in PCON and all the others are in PSW.
General purpose user flags are used by the programmer to record some event in the program.
All the flags can be set or reset by the user but math flags are also affected by math operations
The 8051 architecture
Internal Memory
It consists of internal ROM & internal RAM
They are also referred as Program Memory and Data Memory
Used for the permanent saving of the Used for the temporary storing of
code that is to be executed in intermediate results and variables
Program Counter (PC)
Internal RAM
There are 128 bytes of RAM in 8051.
The 128 bytes are divided into 3 different groups
16 bytes of bit addressable area from address 20h to 2Fh forms a total of
128 addressable bits.
An addressable bit can be specified by its bit address of 00h to 7Fh or by
its byte address from 20h to 2Fh
The SFR registers are located within the internal memory address range 80h to
FFh.
But not all addresses from 80h to FFh are used for SFR.
Some SFR’s are bit addressable, as is the for the bit area of RAM.
CPU and internal peripheral modules use SFR for controlling the desired
operation of the device.
The 8051 architecture
Internal ROM
Internal ROM consists of internal program code which occupies code address space 0000h to
0FFFh.
The Program Counter (PC) is used to address program code bytes from address 0000h to FFFFh.
Code bytes can also be fetched from an external memory.
If the program address is greater than 0FFFh, then 8051 automatically fetch code bytes from external
program memory.
The PC does not care where the code is; the circuit designer decides whether the code is found
totally in Internal ROM, External ROM or in a combination of internal or external ROM.