246
CHAPTER 12 16-BIT INPUT/OUTPUT TIMER
12.6
Program Example of 16-bit Input/Output Timer
This section describes the program example of the 16-bit input/output timer.
■
Program example of free-running timer
Example of setting procedure
Count number of times overflow by free-running timer,
clock =
φ
/2^4, and interrupt processing
Program example
void FREE_RUN_TIMER_sample(void)
{
FREERUN_initial();
FREERUN_start();
}
<Initial setting>
•
Control free-running timer
•
Interrupt related
•
Set variable
void FREERUN_initial(void)
{
IO_TCCS.word = 0x006C; /* Setting value=0000_0000_0110_1100 */
/* bit15 = 0 ECKE internal clock source */
/* bit7 = 0
IVF interrupt request flag */
/* bit6 = 1
Enable IVFE interrupt */
/* bit5 = 1
Disable STOP count */
/* bit4 = 0
Initialize by MODE reset, clear bit */
/* bit3 = 1 Initialize SCLR free-running timer value */
/* bit2-0 = 100 CLK2-0 count clock
φ
/16 */
IO_TCDT = 0x0000;
/* Initialize
timer data value */
IO_ICR12.byte = 0x00;
/* Set interrupt level of free-running timer (arbitrary value)
*/
__EI();
/* Enable interrupt */
count = 0;
}
<Start>
•
Start free-running timer ch.0
void FREERUN_start(void)
{
IO_TCCS.bit.STOP = 0; /* bit5 = 0
Enable STOP count */
}
<Interrupt>
•
Interrupt processing
__interrupt void FREE_RUN_TIMER_int(void)
{
IO_TCCS.bit.IVF = 0;
/* bit7 = 0
Clear IVF overflow flag */
count++;
}
<Interrupt vector>
•
Set vector table
#pragma intvect FREE_RUN_TIMER_int 35
Note:
Setting related to clock and setting of _set_il (numeric
value) are required in advance. See the chapter of
clock and interrupt.
Note:
For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR
F
2
MC-16LX FAMILY MB90480 SERIES".
Set control register
TCCS
Clock selection>>
.ECKE
Interrupt request flag>>
.IVF
Interrupt request enable>>
.IVFE
Count operation>>
.STOP
Initialization condition of timer>>
.MODE
TCDT clear>>
.SCLR
Count clock>>
.CLK2-0
Set timer data value
TCDT
Set interrupt level
ICR12
Set I flag
(CCR)
Register name. bit name
Start count operation
TCCS .STOP
Register name. bit name
Clear interrupt request flag
TCCS .IVF
(Arbitrary processing)
Count of variable
Summary of Contents for MB90480 Series
Page 2: ......
Page 4: ......
Page 10: ...vi ...
Page 128: ...106 CHAPTER 4 RESET ...
Page 174: ...152 CHAPTER 6 LOW POWER CONSUMPTION MODE ...
Page 198: ...176 CHAPTER 7 MODE SETTING ...
Page 220: ...198 CHAPTER 9 TIMEBASE TIMER ...
Page 238: ...216 CHAPTER 11 WATCH TIMER ...
Page 280: ...258 CHAPTER 12 16 BIT INPUT OUTPUT TIMER ...
Page 406: ...384 CHAPTER 17 8 10 BIT A D CONVERTER ...
Page 478: ...456 CHAPTER 20 CHIP SELECTION FACILITY ...
Page 494: ...472 CHAPTER 21 ADDRESS MATCH DETECTION FUNCTION ...
Page 498: ...476 CHAPTER 22 ROM MIRROR FUNCTION SELECTION MODULE ...
Page 526: ...504 CHAPTER 23 2M 3M BIT FLASH MEMORY ...
Page 536: ...514 CHAPTER 24 EXAMPLES OF MB90F481B MB90F482B MB90F488B MB90F489B SERIAL PROGRAMMING ...
Page 570: ...548 CHAPTER 25 PWC TIMER ONLY MB90485 SERIES ...
Page 688: ......