Fujitsu F2MC-8L MB89620 Series Hardware Manual page 198

8-bit microcontroller
Table of Contents

Advertisement

n Program Example 2 for Interval Timer Function (One-shot Timer Mode)
Processing description
l
Generates a single 3 ms interval timer interrupt (one-shot timer mode).
The WTO pin is output a pulse wave that inverts after each interval time cycle. The initial
value of a square wave is "H" level.
The following shows the RLBR register value that results in an interval time of approximately
3 ms for a 10 MHz source oscillation. The count clock is 32 t
oscillation).
Coding example
l
PCR1
PCR2
RLBR
EN
IE
UF
ILR2
INT_V
IRQ5
INT_V
;-----Main program----------------------------------------------------------------------------------------------------------------------------------------
;-----Interrupt processing routine----------------------------------------------------------------------------------------------------------------------
WARI
;---------------------------------------------------------------------------------------------------------------------------------------------------------------
MB89620 series
RLBR register value = 3 ms/(32 × 4/10 MHz) = 233.4 (0EAH)
EQU
0014H
EQU
0015H
EQU
0016H
EQU
PCR1:7
EQU
PCR1:5
EQU
PCR1:2
EQU
007DH
DSEG
ABS
ORG
0FFF0H
DW
WARI
ENDS
CSEG
:
CLRI
CLRB
EN
CLRB
IE
MOV
A,RLBR
MOV
ILR2,#11110111B
MOV
RLBR,#0EAH
MOV
PCR2,#01101000B
MOV
PCR1,#11100000B
SETI
:
CLRB
UF
PUSHW
A
XCHW
A,T
PUSHW
A
:
User processing
:
POPW
A
XCHW
A,T
POPW
A
RETI
ENDS
END
; Address of the PWC pulse width control register 1
; Address of the PWC pulse width control register 2
; Address of the PWC reload buffer register
; Define the counter operation enable bit.
; Define the interrupt request enable bit.
; Define the underflow (01
; Address of the interrupt level setting register 2
; [DATA SEGMENT]
; Set interrupt vector.
; [CODE SEGMENT]
; Stack pointer (SP) etc. are already initialized.
; Disable interrupts.
; Stop counter operation.
; Disable interrupt request output.
; Clear buffer full flag (PCR1: bit 0).
; Set interrupt level (level 1).
; Counter reload value (interval time)
; Select interval timer function, one-shot timer mode, initial output
value of the WTO pin, and 32 t
; Start counter operation, enable WTO pin output, enable interrupt
request output, clear underflow (01
flag, clear measurement complete interrupt request flag (bit 1).
; Enable interrupts.
; Clear interrupt request flag.
CHAPTER 8 PULSE WIDTH COUNT TIMER (PWC)
(t
: divide-by-four source
inst
inst
→ 00
) interrupt request flag bit.
H
H
.
inst
→ 00
) interrupt request
H
H
177

Advertisement

Table of Contents
loading

Table of Contents