程序的功能是p1.0口恒输出方波,方波周期是5个357ms的方波和10个1.09s的方波,剩下的IO口从p0.0到p3.7依次输出与p1.0相同的方波,代码如下:
org 00h
ajmp main
org 30h
main: mov p0,#00h
mov p1,#00h
mov p2,#00h
mov p3,#00h
mov a, #01h
mark0:ljmp pulse0
ljmp pulse1
ljmp pulse2
ljmp pulse3
jmp mark0
pulse0:
point00: mov r0,#5
point01: mov r1,#74
mov p0,a
setb p1.0
point02: mov r2,#9
djnz r1,point03
jmp point04
point03: djnz r2,point03
jmp point02
point04: mov p0,#00h
clr p1.0
mov r1,#74
point05: mov r2,#9
djnz r1,point06
jmp point07
point06: djnz r2,point06
jmp point05
point07: djnz r0,point01
mov r0,#10
point08: mov r1,#227
mov p0,a
setb p1.0
point09: mov r2,#9
djnz r1,point10
jmp point11
point10: djnz r2,point10
jmp point09
point11: mov p0,#00h
clr p1.0
mov r1,#227
point12: mov r2,#9
djnz r1,point13
jmp point14
point13: djnz r2,point13
jmp point12
point14: djnz r0,point08
jc over0
rlc a
ljmp point00
over0: rlc a
ret
pulse1:
point15: mov r0,#5
point16: mov r1,#74
mov p1,a
setb p1.0
point17: mov r2,#9
djnz r1,point19
jmp point19
point18: djnz r2,point18
jmp point17
point19: mov p1,#00h
mov r1,#74
point20: mov r2,#9
djnz r1,point21
jmp point22
point21: djnz r2,point21
jmp point20
point22: djnz r0,point15
mov r0,#10
point23: mov r1,#227
mov p1,a
setb p1.0
point24: mov r2,#9
djnz r1,point25
jmp point26
point25: djnz r2,point25
jmp point24
point26: mov p1,#00h
mov r1,#227
point27: mov r2,#9
djnz r1,point28
jmp point29
point28: djnz r2,point28
jmp point27
point29: djnz r0,point23
jc over1
rlc a
ljmp point15
over1: rlc a
ret
pulse2:
point30: mov r0,#5
point31: mov r1,#74
mov p2,a
setb p1.0
point32: mov r2,#9
djnz r1,point33
jmp point34
point33: djnz r2,point33
jmp point32
point34: mov p2,#00h
clr p1.0
mov r1,#74
point35: mov r2,#9
djnz r1,point36
jmp point37
point36: djnz r2,point36
jmp point35
point37: djnz r0,point30
mov r0,#10
point38: mov r1,#227
mov p2,a
setb p1.0
point39: mov r2,#9
djnz r1,point40
jmp point41
point40: djnz r2,point40
jmp point39
point41: mov p2,#00h
clr p1.0
mov r1,#227
point42: mov r2,#9
djnz r1,point43
jmp point44
point43: djnz r2,point43
jmp point42
point44: djnz r0,point38
jc over2
rlc a
ljmp point30
over2: rlc a
ret
pulse3:
point45: mov r0,#5
point46: mov r1,#74
mov p3,a
setb p1.0
point47: mov r2,#9
djnz r1,point48
jmp point49
point48: djnz r2,point48
jmp point47
point49: mov p3,#00h
clr p1.0
mov r1,#74
point50: mov r2,#9
djnz r1,point51
jmp point52
point51: djnz r2,point51
jmp point50
point52: djnz r0,point45
mov r0,#10
point53: mov r1,#227
mov p3,a
setb p1.0
point54: mov r2,#9
djnz r1,point55
jmp point56
point55: djnz r2,point55
jmp point54
point56: mov p3,#00h
clr p1.0
mov r1,#227
point57: mov r2,#9
djnz r1,point58
jmp point59
point58: djnz r2,point58
jmp point57
point59: djnz r0,point53
jc over3
rlc a
ljmp point45
over3: rlc a
ret
end
现在通过proteus的仿真结果显示p1.0输出正常,但是其他IO口从p0.0开始一直循环到p0.7是正常的,但是之后又重新从p0.0开始循环,p1、p2和p3没有反应,请问是什么原因?代码好像没看出什么问题,谢谢!
一周热门 更多>