S1C88348/317/316/308 TECHNICAL SOFTWARE
EPSON
II-83
12 PROGRAMMABLE TIMER
Source List
Control of programmable timer 4
external
osc1toosc3,osc3toosc1
external
vdd_ngf
public
measure_init,measure_intr
public
count,ovf_flag,k1x_intr
;
measure_vector equ
000006h
;measure interrupt vector offset
k1x_vector
equ
00000ah
;k1x interrupt vector offset
pm
equ
003000h
;program start address offset
br_io
equ
0ffh
;base reg. address (set i/o area)
pt_mode0
equ
00ff30h
;pulse width measure mode set reg. 0
pt_mode1
equ
00ff31h
;pulse width measure mode set reg. 1
rld0
equ
00ff33h
;pulse width measure (low)
reload data
rld1
equ
00ff34h
;pulse width measure (high) reload data
ptd0
equ
00ff35h
;pulse width measure (low)
count data
ptd1
equ
00ff36h
;pulse width measure (high) count data
sik1
equ
00ff51h
;interrupt selection reg. for k1x
kcp1
equ
00ff53h
;interrupt comparison reg. for k1x
k1d
equ
00ff55h
;input data from k1x
;
intr_pr1
equ
00ff21h
;interrupt priority reg. 1
intr_en1
equ
00ff23h
;interrupt enable reg. 1
intr_fac1
equ
00ff25h
;interrupt factor flag reg. 1
;
data
count:
dw
[1]
;pulse width measured data
ovf_flag:
db
[1]
;event counter overflow flag
code
Vector address setting for 16-bit pulse width measurement timer interrupt
intr_vectors:
org
intr_vectors+measure_vector
dw
measure_intr
;pulse width measure overflow interrupt
;
org
intr_vectors+k1x_vector
dw
k1x_intr
;k1x interrupt processing routine
;
(4) Initialization for 16-bit pulse width measurement timer
org
intr_vectors+pm
;*************************************************************************
;*
*
;* 16-bit pulse width measurement (timer 0) between k10 "low" input term *
;*
*
;*************************************************************************
;*** initialize routine
measure_init:
ld
br,#br_io
;set br reg. address to 0ffxxh
carl
osc1toosc3
;change osc1 to osc3 ***
ld
a,[lod vdd_ngf]
;vdd ng flag
cp
a,#0ffh
jrl
z,measure_init01
;mode16=16-bit,chsel=timer 0,pulse output=off,cksel1=don't care,cksel0=fosc3
ld
[br:low pt_mode0],#00011001b
ld
ba,#0ffffh
ld
[lod rld0],ba
;set measure counter init data (max.)
;pt0:evcnt=timer,fcsel=pulse width measurement,plpol=low level measurement
;psc=fosc3/1,rlmd0=reload,pset0=preset,prrun0=stop
ld
[br:low pt_mode1],#01000110b
ld
[br:low kcp1],#00000001b
;k10 falling edge ("h" -> "l")
ld
[br:low sik1],#00000001b
;k10 interrupt enable
or
[br:low intr_pr1],#00001111b
;set pt & pk1=/irq3
or
[br:low intr_en1],#10100000b
;ept1 & ek1 intr. en.
or
[br:low pt_mode1],#00000001b
;start pulse measurement
ld
a,sc
and
a,#00111111b
or
a,#10000000b
ld
sc,a
;i0 flag clear (en. /irq3 intr.)
xor
a,a
ld
[lod ovf_flag],a
;overflow flag clear