II-76
EPSON
S1C88348/317/316/308 TECHNICAL SOFTWARE
12 PROGRAMMABLE TIMER
Control of programmable timer 1
external
osc1toosc3,osc3toosc1
external
vdd_ngf
public
timer2ch_init,pt1_intr,pt0_intr
;
pt1_vector
equ
000006h
;timer 0 interrupt vector offset
pt0_vector
equ
000008h
;timer 1 interrupt vector offset
pt
equ
003000h
;program start address offset
br_io
equ
0ffh
;base reg. address (set i/o area)
pt_mode0
equ
00ff30h
;programmable timer mode set reg. 0
pt_mode1
equ
00ff31h
;programmable timer mode set reg. 1
pt_mode2
equ
00ff32h
;programmable timer mode set reg. 2
rld0
equ
00ff33h
;programmable timer 0 reload data
rld1
equ
00ff34h
;programmable timer 1 reload 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
;
code
Vector address setting for programmable timer interrupt
intr_vectors:
org
intr_vectors+pt1_vector
dw
pt1_intr
;programmable timer 1 interrupt
;
org
intr_vectors+pt0_vector
dw
pt0_intr
;programmable timer 0 interrupt
;
(1) Initialization for 8-bit reload timer (two systems)
org
intr_vectors+pt
timerdata8_0:
db
200
;timer 0 reload data (800us at 4mhz/16)
timerdata8_1:
db
250
;timer 1 reload data (
1ms at 4mhz/64)
;
;************************************************************************
;*
*
;*
8-bit * 2-channel reload timer
*
;*
*
;************************************************************************
;*** initialize routine
timer2ch_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,timer2ch_init00
;
;mode16=8bit*2,chsel=timer0,ptout=off,cksel1&0=fosc3
ld
[br:low pt_mode0],#00000011b
ld
a,[loc timerdata8_0]
ld
[br:low rld0],a
;set reload data (timer 0)
ld
a,[loc timerdata8_1]
ld
[br:low rld1],a
;set reload data (timer 1)
;pt0:evcnt=timer,fcsel=normal timer,plpol=don't care,psc=fosc3/16,rlmd0=reload
;pset0=preset
ld
[br:low pt_mode1],#00010110b
;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 timer 0
or
[br:low pt_mode2],#00000001b
;start timer 1
ld
a,sc
and
a,#00111111b
or
a,#10000000b
ld
sc,a
;i0 flag clear (en. /irq3 intr.)
Source List