
II-60
EPSON
S1C88348/317/316/308 TECHNICAL SOFTWARE
11 STOPWATCH TIMER
Notes
(1) External routines are called for switching to OSC3 and OSC1. (external call: osc1toosc3, osc3toosc1)
(2) Switching the operating mode when the supply voltage is lower than the VD1 setting may cause a
malfunction. Hence, the example routine checks the supply voltage when switching to the normal
mode (OSC3) and terminates as a supply voltage error remains unprocessed if the supply voltage is
lower than the VD1 setting. For this determination, vdd_ngf flag is used. (See "4 OSCILLATION
CIRCUIT".)
(3) When switching from OSC3 to OSC1 (VD1 = 2.2 V
→ 1.3 V), the program example does not perform
special checking of the supply voltage of SVD if the supply voltage is already more than the VD1
setting.
(4) To reset the interrupt factor flag, write "1" into the corresponding flags alone, using the AND or LD
instruction. When the OR logic operation instruction has been used, "1" is written for the interrupt
factor flags that have been set to "1" within the same address and those flags are then clear.
(5) The interrupt flags (I1 and I0) have not been reset in the interrupt processing routine of this program
example, so an interrupt lower than IRQ1 level is disabled at the time of generation. When you wish
to accept the next interrupt after an interrupt has been generated, re-setting of the interrupt flags or
resetting the interrupt factor flag is necessary after due consideration for the nesting level.
(6) When stopping the stopwatch timer by writing "0" into the RUN/STOP control register for the
stopwatch timer, the stopwatch timer count actually stops when it advances one count with the
timing synchronized to the 256 Hz input clock.
For this reason, when the stopwatch timer stops, if the 100 Hz, 10 Hz, and 1 Hz interrupt factors are
generated, the respective interrupt factor flags are set and if interrupt is enabled, an interrupt is
generated. Thus, you should add an interrupt processing and interrupt factor flag resetting, if
necessary.
(7) In this program example for the stopwatch timer, the vector address setting and program have been
allocated from 003000H for the sake of convenience.
Source List
Control of stopwatch timer
external
osc1toosc3,osc3toosc1
external
vdd_ngf
public
sw_init,sw100_intr,sw10_intr,sw1_intr
;
sw100_vector
equ
000016h
;sw100hz interrupt vector offset
sw10_vector
equ
000018h
;sw10hz interrupt vector offset
sw1_vector
equ
00001ah
;sw1hz interrupt vector offset
sw
equ
003000h
;program start address offset
br_io
equ
0ffh
;base reg. address (set i/o area)
sw_mode
equ
00ff42h
;stopwatch mode set reg.
swd
equ
00ff43h
;stopwatch data
intr_pr0
equ
00ff20h
;interrupt priority reg. 0
intr_en0
equ
00ff22h
;interrupt enable reg. 0
intr_fac0
equ
00ff24h
;interrupt factor flag reg.
;
code