HT47定时器应用
扫描二维码
随时随地手机看文章
HT47定时器应用
include ht47c20.inc
data .section 'data'
int_count db ?
io_count db ?
code .section at 0 'code'
org 00h
jmp start
org 04h
reti
org 08h
reti
org 0ch
reti
org 10h
jmp timer_int
;---------------------------------
org 20h
start:
clr iNTC0
clr intc1
clr adcr.1
set tmrc.5 ;系统时钟
MOV a,0ah
MOV int_count,a
clr io_count
MOV a,LOW(65536-12000) ;0.1秒产生中断
MOV tmral,a
MOV tmrbl,a
MOV a,HIGH(65536-12000)
MOV tmrah,a
MOV tmrbh,a
set tmrc.4
set intc1.0
set intc0.0
jmp $
;---------------------------------
timer_int:
sdz int_count
reti
inc io_count
swapa io_count
cpl aCC
MOV pa,a
MOV a,0ah
MOV int_count,a
reti
;*************************************************
;*************************************************
include ht47c20.inc
data .section 'data'
count db ?
code .section at 0 'code'
org 00h
jmp start
org 04h
reti
org 08h
reti
org 0ch
reti
org 10h
jmp timer_int
;---------------------------------
start: clr intc0
clr intc1
clr adcr.1 ;定时/计数器允许
set tmrc.7 ;计数外部时钟
clr count
MOV a,LOW(65536-1000);定时/计数器初值
MOV tmral,a
MOV tmrbl,a
MOV a,HIGH(65536-1000)
MOV tmrah,a
MOV tmrbh,a
set tmrc.4 ;打开定时/计数器
set intc1.0 ;定时/计数器中断允许
set intc0.0 ;总中断允许
jmp $
;---------------------------------
timer_int:
inc count
swapa count
cpl acc
MOV pa,a
reti
;************************************************
;************************************************
include ht47c20.inc
data .section 'data'
count db ?
code .section at 0 'code'
org 00h
jmp start
org 04h
reti
org 08h
reti
org 0ch
reti
org 10h
jmp timer_int
;---------------------------------
start: clr intc0
clr intc1
clr adcr.1
set tmrc.5
set tmrc.7
clr count
MOV a,LOW(65536-60000)
MOV tmral,a
MOV tmrbl,a
MOV a,HIGH(65536-60000)
MOV tmrah,a
MOV tmrbh,a
set tmrc.4
set intc1.0
set intc0.0
jmp $
;---------------------------------
timer_int:
inc count
swapa count
cpl acc
MOV pa,a
reti
;*********************************************