beautypg.com

7 sample program of 16-bit reload timer, Sample program of 16-bit reload timer – FUJITSU F2MCTM-16LX User Manual

Page 279

background image

263

CHAPTER 14 16-BIT RELOAD TIMER

14.7

Sample Program of 16-bit Reload Timer

This section gives a program example of the 16-bit reload timer operated in the internal
clock mode and the event count mode:

Program Example in Internal Clock Mode

Processing specification

The 24 ms interval timer interrupt is generated by the 16-bit reload timer 2.

The repeated interrupts are generated in the reload mode.

The timer is started using the software trigger instead of the external trigger input.

EI

2

OS is not used.

The machine clock is 24 MHz; the count clock is 1.33

µs.

Coding example

ICR04 EQU 0000B4H ;Interrupt control register for 16-bit

;reload timer

TMCSR2 EQU 000064H ;Timer control status register

TMR2 EQU 00794CH ;16-bit timer register

TMRLR2 EQU 00794CH ;16-bit reload register

UF2 EQU TMCSR2:2 ;Interrupt request flag bit

CNTE2 EQU TMCSR2:1 ;Counter operation enable bit

TRG2 EQU TMCSR2:0 ;Software trigger bit

;--------Main program------------------------------------

CODE CSEG

; : ;Stack pointer (SP), already initialized

AND CCR,#0BFH ;Interrupts disabled

MOV I:ICR04,#00H ;Interrupt level 0 (highest)

CLRB I:CNTE2 ;Counter suspended

MOVW I:TMRLR2,#4650H ;Set data for 24 ms timer

MOVW I:TMCSR2,#0000100000011011B

;Operation of interval timer,

clock = 1.33

µs

;External trigger disabled, external

output disabled

;Reload mode selected, interrupt enabled

;Interrupt flag cleared, count started

MOV ILM,#07H ;ILM in PS set to level 7

OR CCR,#40H ;Interrupts enabled

LOOP:

:

Processing by user

: