243
CHAPTER 7 16-bit I/O timer
7.8
Program Example of 16-bit Input/Output Timer
This section gives a program example of the 16-bit input/output timer.
■
Processing of Program for Measuring Cycle Using Input Capture
•
The cycle of a signal input to the IN0 pin is measured.
•
The 16-bit free-run timer and input capture 0 are used.
•
The rising edge is selected as the edge to be detected.
•
The machine clock (
φ
) is 16 MHz and the count clock is
φ
/4 (0.25
µ
s).
•
The overflow interrupt and input capture interrupt of input capture 0 are used.
•
The overflow interrupt of the 16-bit free-run timer is counted beforehand and used for the cycle
calculation.
•
The cycle can be determined from the following equation:
Cycle = (overflow count x "10000
H
" + nth IPCP0 value - (n-1)th IPCP0 value) x count clock cycle
= (overflow count x 10000
H
+ nth IPCP0 value - (n-1)th IPCP0 value) x 0.25
µ
s
●
Coding example
DDR1 EQU 000011H ;Port direction register
TCCS EQU 000058H ;Timer counter control
;Status register
TCDT EQU 000056H ;Timer counter data register
ICS01 EQU 000054H ;Input capture control
;Status register 01
IPCP0 EQU 000050H ;Input capture data register 0
IVFE EQU TCCS:5 ;Over flow interrupt enable bit
ICP0 EQU ICS01:6 ;Input capture 0 interrupt request
;Flag bit
ICR04 EQU 0000B4H ;Interrupt cotrol register
16-bit free-run timer
ICR06 EQU 0000B6H ;Interrupt control register
16-bit inpu capture
DATA DSEG ABS=00H
ORG 0100H
OV_CNT RW 1 ;Over flow counter
DATA ENDS
;---------Main program-------------------------------------
CODE CSEG ABS=0FFH
START:
;Stack pointer (SP),
;already initialized
:
Summary of Contents for F2MC-16LX Series
Page 2: ......
Page 3: ...FUJITSU LIMITED F2MC 16LX 16 bit Microcontroller MB90895 series Hardware Manual ...
Page 4: ......
Page 8: ...iv ...
Page 10: ...vi ...
Page 36: ...18 CHAPTER 2 HANDLING DEVICES ...
Page 176: ...158 CHAPTER 3 CPU ...
Page 224: ...206 CHAPTER 5 Timebase timer ...
Page 294: ...276 CHAPTER 8 16 bit reload timer ...
Page 366: ...348 CHAPTER 12 DTP external interrupt ...
Page 398: ...380 CHAPTER 13 8 10 bit A D converter ...
Page 446: ...428 CHAPTER 14 UART0 ...
Page 588: ...570 CHAPTER 17 Address Match Detecting Function ...
Page 626: ...608 CHAPTER 19 512 KBIT FLASH MEMORY ...
Page 676: ...658 APPENDIX Table A 9 3 Bit Operation Instruction Map first byte 6CH ...
Page 678: ...660 APPENDIX Table A 9 5 2 byte Instruction Map first byte 6FH MUL MULW DIVU A A A ...
Page 680: ...662 APPENDIX Table A 9 7 ea Instruction 2 first byte 71H ...
Page 681: ...663 APPENDIX A Instructions Table A 9 8 ea Instruction 3 first byte 72H ...
Page 682: ...664 APPENDIX Table A 9 9 ea Instruction 4 first byte 73H ...
Page 683: ...665 APPENDIX A Instructions Table A 9 10 ea Instruction 5 first byte 74H ...
Page 684: ...666 APPENDIX Table A 9 11 ea Instruction 6 first byte 75H ...
Page 685: ...667 APPENDIX A Instructions Table A 9 12 ea Instruction 7 first byte 76H ...
Page 686: ...668 APPENDIX Table A 9 13 ea Instruction 8 first byte 77H ...
Page 687: ...669 APPENDIX A Instructions Table A 9 14 ea Instruction 9 first byte 78H ...
Page 688: ...670 APPENDIX Table A 9 15 MOVEA RWi ea Instruction first byte 79H ...
Page 689: ...671 APPENDIX A Instructions Table A 9 16 MOV Ri ea Instruction first byte 7AH ...
Page 690: ...672 APPENDIX Table A 9 17 MOVW RWi ea Instruction first byte 7BH ...
Page 691: ...673 APPENDIX A Instructions Table A 9 18 MOV ea Ri Instruction first byte 7CH ...
Page 692: ...674 APPENDIX Table A 9 19 MOVW ea Rwi Instruction first byte 7DH ...
Page 693: ...675 APPENDIX A Instructions Table A 9 20 XCH Ri ea Instruction first byte 7EH ...
Page 694: ...676 APPENDIX Table A 9 21 XCHW RWi ea Instruction first byte 7FH ...
Page 710: ......