II-80
EPSON
S1C88348/317/316/308 TECHNICAL SOFTWARE
12 PROGRAMMABLE TIMER
Source List
Control of programmable timer 3
external
osc1toosc3,osc3toosc1
external
vdd_ngf
public
evcnt_init,evcnt_intr,pt1_intr
public
pre_count,count,ovf_flag
;
pt1_vector
equ
000006h
;timer 1 interrupt vector offset
evcnt_vector
equ
000008h
;event counter interrupt vector offset
evcnt
equ
003000h
;program start address offset
br_io
equ
0ffh
;base reg. address (set i/o area)
pt_mode0
equ
00ff30h
;event counter timer mode set reg. 0
pt_mode1
equ
00ff31h
;event counter mode set reg. 1
pt_mode2
equ
00ff32h
;programmable timer mode set reg. 2
rld0
equ
00ff33h
;event counter reload data
rld1
equ
00ff34h
;programmable timer 1 reload data
ptd0
equ
00ff35h
;event counter counting data
ptd1
equ
00ff36h
;programmable timer 1 counter data
;
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
pre_count:
db
[1]
;previous event counter data
count:
db
[1]
;present event counter data
ovf_flag:
db
[1]
;event counter overflow flag
code
Vector address setting for 8-bit event counter interrupt
intr_vectors:
org
intr_vectors+pt1_vector
dw
pt1_intr
;
org
intr_vectors+evcnt_vector
dw
evcnt_intr
;event counter overflow interrupt
;
(3) Initialization for 8-bit event counter
org
intr_vectors+evcnt
timerdata8_2:
db
250
;timer 1 reload data (4msec at 4mhz/64)
;*************************************************************************
;*
*
;* 8-bit event counter (timer 0) counting between 4msec (reload timer 1) *
;*
*
;*************************************************************************
;*** initialize routine
evcnt_init:
ld
br,#br_io
;set br reg. address to 0ffxxh
carl
osc1toosc3
;change osc1 to osc3 ***
ld
a,[lod vdd_ngf]
cp
a,#0ffh
jrl
z,evcnt_init01
;
;mode16=8-bit,chsel=timer 0,pulse output=off,cksel1=fosc3,cksel0=don't care
ld
[br:low pt_mode0],#00000011b
ld
a,#0ffh
ld
[br:low rld0],a
;set event counter init data (max.)
ld
[lod pre_count],a
;pre event counter data set
ld
a,[loc timerdata8_2]
ld
[br:low rld1],a
;set reload data (timer 1)
;pt0:evcnt=event counter,fcsel=with noise rejector,plpol=falling edge
;psc1&0=don't care,rlmd0=reload,pset0=preset,prrun0=stop
ld
[br:low pt_mode1],#11000110b
;pt1:psc=fosc3/64,rlmd1=reload,pset1=preset
ld
[br:low pt_mode2],#00011110b
or
[br:low intr_pr1],#00001100b
;set pt=/irq3
or
[br:low intr_en1],#11000000b
;ept1&0 intr. en.
or
[br:low pt_mode1],#00000001b
;start event counter
or
[br:low pt_mode2],#00000001b
;start timer 1