?? 定時器2.asm
字號:
org 0000h ;200MS方波,蜂鳴器鳴響5次,每隔1S顯示1--30
ajmp main
org 001bh
ajmp int_1
main: mov a, #0bbh
mov r5, #04h
acall led
clr p1.0
start: mov sp, #60h
mov tmod,#10h
mov tl1, #0b0h ;晶振為12M,每50MS溢出中斷一次
mov th1, #3ch ;若晶振為11.0592M時,時間常數為4C00H,若晶振為6M時,時間常數為9E58H
mov r0, #2h
mov r1, #00h
mov r2, #00h
mov r3, #00h
mov r4, #00h
mov 40h, #09h
setb tr1
setb et1
setb ea
here1: cjne r3,#01h,here
mov r3,#00h
mov 41h, r2
acall led1
acall led2
cjne r4,#01h,here
mov r4,#00h
clr p1.1
feng1: acall delay
cpl p1.1
djnz 40h,feng1
mov 40h,#09h
here: sjmp here1
int_1: push acc
push psw
clr tr1
mov tl1, #0b0h
mov th1, #3ch
setb tr1
djnz r0, e_end
mov r0, #02h
cpl p1.0
inc r1
cjne r1,#0ah,e_end
mov r1,#00h
mov r3,#01h
inc r2
cjne r2,#1eh,e_end
mov r2,#00h
mov r4,#01h
e_end: pop psw
pop acc
reti
led1: mov b, #0ah
mov a, 41h
div ab
mov r6,a
mov r7,b
mov dptr,#table
mov a,r7
movc a,@a+dptr
mov r5,#01h
acall led
mov dptr,#table
mov a,r6
movc a,@a+dptr
mov r5,#01h
acall led
ret
led: mov scon, #00h
mov sbuf, a
jnb ti, $
clr ti
djnz r5, led
ret
led2: mov r5, #02h
mov a, #00h
acall led
ret
delay: mov r6, #0ffh
a3: nop
djnz r6, a3
djnz r7, delay
ret
table: db 0bbh,09h,0eah,6bh,59h,73h,0f3h,0bh
db 0fbh,7bh,0dbh,0f1h,0b2h,0e9h,0f2h,0d2h
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -