![](http://datasheet.mmic.net.cn/330000/MB90F562_datasheet_16437954/MB90F562_297.png)
MB90560 series
CHAPTER 11 16-BIT RELOAD TIMER
273
11.8 Sample Programs for the 16-Bit Reload Timer
This section contains sample programs for the 16-bit reload timer in internal clock
mode and event count mode.
I
Sample program in internal clock mode
G
Processing
A 25-ms interval timer interrupt is generated with 16-bit reload timer 0.
The timer is used in reload mode to repeatedly generate an interrupt.
The timer is started with a software trigger. External trigger input is not used.
EI
2
OS is not used.
16 MHz is used for the machine clock, and 2μs is used for the count clock.
G
Coding example
ICR09
TMCSR
TMR
TMRLR
UF
CNTE
TRG
;-------Main program------------------------------------------------------------------------------------------------
CODE
CSEG
START:
;
:
;
;
AND
CCR,#0BFH
;
MOV
I:ICR09,#00H
;
CLRB
I:CNTE
;
MOVW
I:TMRLR0,#30D4H
;
MOVW
I:TMCSR0,#00001000000011011B
;
;
;
;
MOV
ILM,#07H
;
OR
CCR,#40H
;
LOOP:
MOV
A,#00H
;
MOV
A,#01H
;
BRA
LOOP
;
;-------Interrupt program--------------------------------------------------------------------------------------------
WARI:
CLRB
I:UF
;
;
:
;
User processing
;
:
RETI
;
EQU
EQU
EQU
EQU
EQU
EQU
EQU
0000B9H
000082H
000084H
000084H
TMCSR0:2
TMCSR0:1
TMCSR0:0
;
;
;
;
;
;
;
Interrupt control register for the 16-bit reload timer
Timer control status register
16-bit timer register
16-bit reload register
Interrupt request flag bit
Counter operation enable bit
Software trigger bit
Assumes that stack pointer (SP) has already been
initialized.
Interrupt disable
Interrupt level 0 (strongest)
Temporary stopping of counter
Sets data for 25-ms timer.
Interval timer operation, 2 μs clock
Disables external trigger and external output.
Selects reload mode, and enables interrupts.
Clears interrupt flag, and starts counter.
Sets ILM in PS to level 7
Interrupt enable
Endless loop
Clears interrupt request flag.
Returns from interrupt