Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 14

LAB 7

Pin Description of the 8051 (Rev)


P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3
P1.4
4
5
8051 37
36
P0.2(AD2)
P0.3(AD3)
P1.5 6 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 33 P0.6(AD6)
RST 9 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
Power-On RESET Circuit (Rev)
Registers (Rev)

Program counter
Points to the address of the next instruction to be
executed.
As each instruction is executed, the program counter is
incremented
Org and End (Rev)
MOV destination, source
ADD A, source
UnConditional Loop
 Repeating a sequence of instructions is called a loop
 Unconditional Loop action is performed by
 Sjmp label
Conditional Loop
 Repeating a sequence of instructions is called a loop
 Loop action is performed by
 DJNZ reg, Label

 Steps
 The register is decremented
 If it is not zero, it jumps to the label

 At start of loop the register is loaded with the value for the number
of repetitions

 Counter can be R0 – R7 or RAM location


Loop
1. Write a program for loop which repeat ten times

2. Add 5 ten times using loop instruction


1. 5+5+5 - - - - - 5
Nested Loop

 If we want to repeat an action more times than 256,


we use a loop inside a loop, which is called nested
loop
Nested Loop

 Write a program to (a) load the accumulator with the


value 55H, and (b) complement the ACC
 CPL A is for complement

 Write a program to (a) load the accumulator with the


value 55H, and (b) complement the ACC 700 times
How to Introduce Delay (8051)
 Write a program of blinking by sending 00h and its
complement on P3 continuously by introducing
delay between both operations.

 Delay of
 700 times
 520000 times
 930000 times
Conditional Jump Instructions

Determine

•if P1 contains the value 0. Send 55H to P3 else send AAH


to P3
Format:
CJNE A,#20,LOOP
Compare accumulator with 20. If they are not equal, jump to the address marked as LOOP

You might also like