Академический Документы
Профессиональный Документы
Культура Документы
Example
A,#0
MOV
R2,#10
AGAIN: ADD
A,#03
DJNZ
R2,AGAIN
MOV
R5,A
Action
JZ
Jump if A = 0
JNZ
Jump if A 0
DJNZ
CJNE A,byte
Jump if A byte
CJNE reg,#data
JC
Jump if CY = 1
JNC
Jump if CY = 0
JB
Jump if bit = 1
JNB
Jump if bit = 0
JBC
All conditional jumps are short jumps, meaning that the address of
the target must be within -128 and +127 bytes of the contents of the
program counter (PC).
CALL instructions
After
The frequency of the crystal connected to the 8051 family can vary
from 4MHz to 30MHz.
Example
Solution
1/11.0592MHz = period per oscillation
Machine cycle = 12x
= 1.085s
1/16MHz = period per oscillation
Machine cycle = 12x
= 0.75s
1/20MHz = period per oscillation
Machine cycle = 12x
= 0.6s
Question
R3,#55
(b) DEC
R3
(c) DJNZ
R2,target
Solution
(a) MOV
R3,#55
1x1.085s
(b) DEC
R3
1x1.085s
(c) DJNZ
R2,target
2x1.085s
Delay Calculation
Example
Find the size of the delay in the following program, if the crystal
frequency is 12MHz.
MOV
A,#55H
AGAIN: MOV
P1,A
ACALL
DELAY
CPL
A
SJMP
AGAIN
DELAY: MOV
R3,#200
HERE: DJNZ
R3,HERE
RET
What does the above program do?
Solution
Crystal Cycle
DELAY:
MOV
R3,#200
12
HERE:
DJNZ
R3,HERE
24
RET
12
Question
For a machine cycle of 1s, find the time delay of the following
subroutine.
DELAY:
AGAIN:
HERE:
MOV
MOV
NOP
NOP
DJNZ
DJNZ
RET
R2,#200
R3,#250
R3,HERE
R2,AGAIN
Solution
HERE Loop: 250x1s = 250 s
AGAIN Loop: Repeats the HERE loop 200 times i.e.
200x250s = 200ms