200
CHAPTER 8 8/16-BIT CAPTURE TIMER/COUNTER
8.11
Program Example for 8/16-bit Capture Timer/Counter
This section provides program examples of the 8/16-bit capture timer/counter.
■
Program Example of Interval Timer Function
●
Processing specifications
•
In the 8-bit mode, only timer 0 is used to generate a 20 ms interval timer interrupt.
•
When the interval time has elapsed, the square wave to be inverted is output to the TO pin.
•
At 12.5-MHz oscillation (F
CH
), the TDR0 value whose interval time becomes 20 ms at the maximum
gear speed (1 instruction cycle = 4/F
CH
) is shown below. The count clock is 256t
INST
of the internal
count clock.
TDR0 value = 20 ms/(256
×
4/12.5 MHz) - 1 = 244 (F4
H
)
●
Coding example
TCCR
EQU
0019H
; Address of capture control register
TCR1
EQU
001AH
; Address of timer 1 control register
TCR0
EQU
001BH
; Address of timer 0 control register
TCR2
EQU
0020H
; Address of timer output control register
TDR1
EQU
001CH
; Address of timer 1 data register
TDR0
EQU
001DH
; Address of timer 0 data register
TIF0
EQU
TCR0:7
; Defines the timer 0 interrupt request flag bit.
ILR1
EQU
007BH
; Address of interrupt request setting register
INT_V DSEG
ABS
; [DATA SEGMENT]
ORG
0FFF0H
IRQD
DW
WARI
; Sets an interrupt vector.
ENDS
;------------------------Main program---------------------------------------------------------------------------------
CSEG
; [CODE SEGMENT]
; The stack pointer (SP), etc., is already initialized.
:
CLRI
; Disables the interrupt.
MOV
ILR1,#10111111B
; Sets the interrupt level to 2.
MOV
TCR0,#01001010B
; Clears the timer 0 interrupt request flag, increments the
counter at a rising edge, selects 256t
INST
, and stops the
operation.
MOV
TCR1,#01000010B
; Clears the timer 1 interrupt request flag, prohibits
interrupt request output, sets a mode other than the 16-
bit mode, and stops the operation.
MOV
TDR0,#F4H
; Sets the value (interval time) to be compared with the
counter value.
Содержание F2MC-8L F202RA
Страница 2: ......
Страница 4: ......
Страница 32: ...16 CHAPTER 1 OVERVIEW ...
Страница 90: ...74 CHAPTER 3 CPU ...
Страница 142: ...126 CHAPTER 5 TIME BASE TIMER POPW A RETI ENDS END ...
Страница 150: ...134 CHAPTER 6 WATCHDOG TIMER ...
Страница 174: ...158 CHAPTER 7 8 BIT PWM TIMER User processing POPW A XCHW A T Restoring A and T POPW A RETI ENDS ...
Страница 176: ...160 CHAPTER 7 8 BIT PWM TIMER ...
Страница 220: ...204 CHAPTER 8 8 16 BIT CAPTURE TIMER COUNTER ...
Страница 240: ...224 CHAPTER 9 12 BIT PPG TIMER ...
Страница 258: ...242 CHAPTER 10 EXTERNAL INTERRUPT CIRCUIT 1 EDGE PUSHW A User processing POPW A XCHW A T POPW A RETI ENDS END ...
Страница 274: ...258 CHAPTER 11 EXTERNAL INTERRUPT CIRCUIT 2 LEVEL ...
Страница 362: ...346 CHAPTER 15 BUZZER OUTPUT ...
Страница 371: ...355 CHAPTER 16 WILD REGISTER FUNCTION 16 3 5 Data Test Set Register WROR A test register Do not access this register ...
Страница 390: ...374 CHAPTER 17 FLASH MEMORY ...
Страница 419: ...403 INDEX INDEX The index follows on the next page This is listed in alphabetic order ...
Страница 434: ...418 INDEX ...
Страница 436: ......