Fujitsu F2MC-8L Series Hardware Manual page 218

8-bit microcontroller
Hide thumbs Also See for F2MC-8L Series:
Table of Contents

Advertisement

Program Example for Pulse Counter Function
Processing description
Generates an interrupt for every 5000 (1388
using timers 1 and 2 in 16-bit mode.
The following coding example is a sample program for reading a 16-bit counter value during
operation of the counter. (READ16)
Coding example
DDR3
EQU
T2CR
EQU
T1CR
EQU
T2DR
EQU
T1DR
EQU
T1IF
EQU
ILR1
EQU
INT_V
DSEG
ORG
IRQ3
DW
ENDS
;-----Main program-------------------------------------------------------------------------------------------------------------------------------------
CSEG
:
MOV
CLRI
MOV
MOV
MOV
MOV
MOV
000DH
0018H
0019H
001AH
001BH
T1CR:7
007CH
ABS
FFF4H
WARI
DDR2, #00000000B
ILR1, #101111B
T1DR, #088H
T2DR, #013H
T2CR, #00001100B
T1CR, #01001101B
7.12 Program Examples for 8/16-bit Timer/Counter
) external clock pulses input to the EC pin
H
; Address of the port direction register
; Address of the timer 2 control register
; Address of the timer 1 control register
; Address of the timer 2 data register
; Address of the timer 1 data register
; Define the interrupt request flag bit in the timer 1.
; Address of the interrupt level setting register 2
; Set interrupt vector.
; [CODE SEGMENT]
; Stack pointer (SP) etc. are already initialized.
; Set P33/EC/SCO pin as an input.
; Disable interrupts.
; Set interrupt level (level2).
; Set lower eight bits of value to be compared with counter value.
; Set upper eight bits of value to be compared with counter value.
; Place timer 2 in 16-bit mode.
; Clear timer 1 interrupt request flag, enable interrupt request
; output, and set general-purpose port pin (P34).
; Select external clock, clear counter, and start operation.
191

Advertisement

Table of Contents
loading

Table of Contents