Program Example Of Counter Function - Fujitsu F2MC-8L F202RA Hardware Manual

F2mc-8l 8-bit microcontroller
Hide thumbs Also See for F2MC-8L F202RA:
Table of Contents

Advertisement

CHAPTER 8 8/16-BIT CAPTURE TIMER/COUNTER

Program Example of Counter Function

● Processing specifications
In the 16-bit mode, timer 0 and timer 1 are used to generate an interrupt whenever the external clock to
be input to the EC pin is counted 5,000 times (1388
The sample program for reading the 16-bit counter value when the counter is in operation is shown
below (READ16).
● Coding example
DDR3
TCCR
TCR1
TCR0
TDR1
TDR0
TIF0
ILR1
INT_V
IRQD
;------------------------Main program---------------------------------------------------------------------------------
;------------------------Data read subroutine-------------------------------------------------------------------------
READ16
202
EQU
000DH
EQU
0019H
EQU
001AH
EQU
001BH
EQU
001CH
EQU
001DH
EQU
TCR0:7
EQU
007CH
DSEG
ABS
ORG
0FFF0H
DW
WARI
ENDS
CSEG
:
MOV
DDR3,#00000000B ; Sets the EC pin to input.
CLRI
MOV
ILR1,#10111111B
MOV
TDR0,#088H
MOV
TDR1,#013H
MOV
TCR1,#00001110B ; Sets timer 1 to 16-bit mode.
MOV
TCR0,#01101111B ; Clears the timer 0 interrupt request flag, allows interrupt
SETI
MOVW
A,TDR1
MOVW
A,TDR1
CMPW
A
BEQ
RET16
).
H
; Address of port 3-direction register
; Address of capture control register
; Address of timer 1 control register
; Address of timer 0 control register
; Address of timer 1 data register
; Address of timer 0 data register
; Defines the timer 0 interrupt request flag bit.
; Address of interrupt level setting register 2
; [DATA SEGMENT]
; Sets the interrupt vector.
; [CODE SEGMENT]
; The stack pointer (SP), etc., is already initialized.
; Disables the interrupt.
; Sets the interrupt level to 2.
; Sets the counter value and the lower 8 bits of the
compare value.
; Sets the counter value and the higher 8 bits of the
compare value.
request output, selects an external clock, clears the
counter, starts the operation, and increments the counter
at a rising edge.
; Enables a CPU interrupt.
; Reads 16 bits from TDR1 and TDR0.
; Reads 16 bits from TDR1 and TDR0 and stores the old
value in the T register.
; Executes double read check and compares A with T.
; Match and return

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

F2mc-8l mb89202Mb89202/f202ra series

Table of Contents