Dem Report On 8051 Microprocessor
Dem Report On 8051 Microprocessor
We are living in the Embedded World. You are surrounded with many
embedded products and your daily life largely depends on the proper
functioning of these gadgets. Television, Radio, CD player of your living
room, Washing Machine or Microwave Oven in your kitchen, Card
readers, Access Controllers, Palm devices of your work space enable you
to do many of your tasks very effectively. Apart from all these, many
controllers embedded in your car take care of car operations between the
bumpers and most of the times you tend to ignore all these controllers.
Theoretically, an embedded controller is a combination of a piece of
microprocessor based hardware and the suitable software to undertake a
specific task.
These days designers have many choices in microprocessors/
microcontrollers. Especially, in 8 bit and 32 bit, the available variety
really may overwhelm even an experienced designer. Selecting a right
microprocessor may turn out as a most difficult first step and it is getting
complicated as new devices continue to pop-up very often.
In the 8 bit segment, the most popular and used architecture is Intel's 8031.
Market acceptance of this particular family has driven many
semiconductor manufacturers to develop something new based on this
particular architecture. Even after 25 years of existence, semiconductor
manufacturers still come out with some kind of device using this 8031 core.
pg. 1
8051 Microcontrollers:-
pg. 2
8051 microcontroller Pin Diagram and
Pin Functions:-
pg. 3
ALE/PROG: Address Latch Enable output pulse for latching the low byte
of the address during accesses to external memory. ALE is emitted at a
constant rate of 1/6 of the oscillator frequency, for external timing or
clocking purposes, even when there are no accesses to external memory.
(However, one ALE pulse is skipped during each access to external Data
Memory.) This pin is also the program pulse input (PROG) during
EPROM programming.
pg. 4
to external memory. In this application it uses strong internal pull-ups
when emitting 1s. Port 0 emits code bytes during program verification. In
this application, external pull-ups are required.
Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Port
1 pins that have 1s written to them are pulled high by the internal pull-
ups, and in that state can be used as inputs. As inputs, port 1 pins that are
externally being pulled low will source current because of the internal
pull-ups.
Port 2: Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. Port
2 emits the high-order address byte during accesses to external memory
that use 16-bit addresses. In this application, it uses the strong internal
pull-ups when emitting 1s
.
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. It
also serves the functions of various special features of the 80C51 Family
as follows:
Port Pin Alternate Function
P3.0 RxD (serial input port)
P3.1 TxD (serial output port)
P3.2 INT0 (external interrupt 0)
P3.3 INT1 (external interrupt 1)
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
P3.6 WR (external data memory write strobe)
P3.7 RD (external data memory read strobe)
pg. 5
Special Function Registers
Accumulator:
ACC is the Accumulator register. The mnemonics for Accumulator-
Specific instructions, however, refer to the Accumulator simply as A.
B Register:
The B register is used during multiply and divide operations. For other
instructions it can be treated as another scratch pad register
.
Program Status Word:
The PSW register contains program status information as detailed in
Figure.
Stack Pointer:-
The Stack Pointer register is 8 bits wide. It is incremented before data is
stored during PUSH and CALL executions. While the stack may reside
anywhere in on-chip RAM, the Stack Pointer is initialized to 07H after a
reset. This causes the stack to begin at locations 08H.
Data Pointer:-
pg. 6
The Data Pointer (DPTR) consists of a high byte (DPH) and a low byte
(DPL). Its intended function is to hold a 16-bit address. It may be
manipulated as a 16-bit register or as two independent 8-bit registers.
pg. 7
Basic Registers:-
A number of 8052 registers can be considered "basic." Very little can be
done without them and a detailed explanation of each one is warranted to
make sure the reader understands these registers before getting into more
complicated areas of development.
The Accumulator:-
If you've worked with any other assembly language you will be familiar
with the concept of an accumulator register.
The Accumulator, as its name suggests, is used as a general register to
accumulate the results of a large number of instructions. It can hold an 8-
bit (1-byte) value and is the most versatile register the 8052 has due to the
sheer number of instructions that make use of the accumulator. More than
half of the 8052's 255 instructions manipulate or use the Accumulator in
some way.
For example, if you want to add the number 10 and 20, the resulting 30
will be stored in the Accumulator. Once you have a value in the
Accumulator you may continue processing the value or you may store it
in another register or in memory.
pg. 8
20 may be stored in, say, register R4. To process the addition you would
execute the command:
ADD A, R4
After executing this instruction the Accumulator will contain the value
30. You may think of the "R" registers as very important auxiliary, or
"helper", registers. The Accumulator alone would not be very useful if it
were not for these "R" registers.
The "R" registers are also used to store values temporarily. For example,
let’s say you want to add the values in R1 and R2 together and then
subtract the values of R3 and R4. One way to do this would be:
MOV A, R3 ; Move the value of R3 to accumulator
ADD A, R4 ; add the value of R4
MOV R5, A ; Store the result in R5
MOV A, R1 ; Move the value of R1 to Acc
ADD A, R2 ; add the value of R2 with A
SUBB A, R5 ; Subtract the R5 (which has R3+R4)
As you can see, we used R5 to temporarily hold the sum of R3 and R4.
Of course, this isn't the most efficient way to calculate (R1+R2) - (R3
+R4) but it does illustrate the use of the "R" registers as a way to store
values temporarily.
As mentioned earlier, there are four sets of "R" registers-register bank 0,
1, 2, and 3. When the 8052 is first powered up, register bank 0 (addresses
00h through 07h) is used by default. In this case, for example, R4 is the
same as Internal RAM address 04h. However, your program may instruct
the 8052 to use one of the alternate register banks; i.e., register banks 1,
2, or 3. In this case, R4 will no longer be the same as Internal RAM
address 04h. For example, if your program instructs the 8052 to use
register bank 1, register R4 will now be synonymous with Internal RAM
address 0Ch. If you select register bank 2, R4 is synonymous with 14h,
and if you select register bank 3 it is synonymous with address 1Ch.
pg. 9
The concept of register banks adds a great level of flexibility to the 8052,
especially when dealing with interrupts (we'll talk about interrupts later).
However, always remember that the register banks really reside in the first
32 bytes of Internal RAM.
The B Register:-
The "B" register is very similar to the Accumulator in the sense that it may
hold an 8-bit (1-byte) value. The "B" register is only used implicitly by
two 8052 instructions: MUL AB and DIV AB. Thus, if you want to
quickly and easily multiply or divide A by another number, you may store
the other number in "B" and make use of these two instructions.
Aside from the MUL and DIV instructions, the "B" register are often used
as yet another temporary storage register much like a ninth "R" register.
pg. 10
trick that may be used to determine the current value of PC. This trick will
be covered in a later chapter.
pg. 11