Difference between revisions of "1.8051 Architecture"
Line 70: | Line 70: | ||
===== IO port structure===== | ===== IO port structure===== | ||
{{Box|type=l_green_light|text=<br /> | {{Box|type=l_green_light|text=<br /> | ||
− | [[File:8051 pin write.jpg | + | [[File:8051 pin write.jpg]] |
− | [[File:Pin read 0.jpg | + | [[File:Pin read 0.jpg]] |
− | [[File:Pin read 1.jpg | + | [[File:Pin read 1.jpg]] |
}} | }} |
Revision as of 18:49, 11 December 2013
Contents
Introduction
As we have seen in the Previous tutorial, it basically consists of a ALU, RAM, ROM, IO Ports, Timers/Counters, Serial Port and Interrupt Structure. Well, it also has some internal resisters.
Let us start discussing the ALU, as it is the main unit. Understanding of ALU, will allow us to put other units in their place.
Arithmetic and Logical Unit (ALU)
ALU performs arithmetic like addition, subtraction, multiplication and Logical Operations like NAND, NOR etc. Since 8051 is an 8 bit microcontroller, it takes input from two 8 bit registers namely A and B and processes them. If would like a deeper insight as to how an ALU is built from basic building blocks(logic gates) you may go refer to this tutorial:(4 bit ALU in detail). It would give you a deeper understanding of the microcontrollers, and it it would link your basic concepts like logical gates to the microcontrollers.
Registers of 8051
8 bit Registers
The commonly used registers are R0 to R7, A, B, PSW These are all 8 bit registers. The registers associated with the ALU are A,Band PSW. In most operations, ALU performs specified operation on registers 'A' and 'B' and the result is stored back in 'A'. Hence Register 'A' is often called accumulator.
Program Status Word
'PSW' indicates various flags associated with the operation performed. Figure below shows the 8 bits of the PSW register and their function is shown in the table.
CY | Carry Flag |
AC | |
F0 | Available for general use |
RS1 | Register Bank Selection bit 1 |
RS0 | Register Bank Selection bit 0 |
OV | Overflow flag |
* | User Definable bit |
P | Parity flag |
16 bit Registers.
There are also some 16 bit registers in 8051 as shown in the figure. The program counter points to the next instruction that the CPU executes.
The DPTR and other special function registers like SCON, TCON,P0,P1,P2 etc will be discussed while using microcontroller features like timers, counter, serial communication, Interrupts etc.
Internal RAM in Detail
Figure Below show Internal RAM of 8051 it is divided into 3 main sections:
1. Register Banks
- There are 32 8-bit registers arranged in 4 groups. These are used as general purpose registers.
2. Bit Addressable RAM
- 8051 has 16 bytes of RAM, which is bit addressable. It is grouped as 16, 8 byte arrays and any of the 128 bits can also be set/cleared individually.
3. Scratch PAD RAM
- The third group of registers occupy addresses 2Fh-7Fh, i.e. 80 locations, and does not have any special functions or features. Scratch pad RAM is used by the ALU, while fetching, decoding and executing the instructions during operation of the microcontroller.
System Timing, Interrupts, Timers, Data Buffers and Memory Cotrol
IO port structure