Program Example Of 16-Bit Input/Output Timer - Fujitsu MB90480 Series Hardware Manual

F2mc-16lx 16-bit microcontroller
Table of Contents

Advertisement

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
<Initial setting>
Control free-running timer
Set control register
Clock selection>>
Interrupt request flag>>
Interrupt request enable>>
Count operation>>
Initialization condition of timer>>
TCDT clear>>
Count clock>>
Set timer data value
Interrupt related
Set interrupt level
Set I flag
Set variable
<Start>
Start free-running timer ch.0
Start count operation
<Interrupt>
Interrupt processing
Clear interrupt request flag
(Arbitrary processing)
Count of variable
<Interrupt vector>
Set vector table
Note:
Setting related to clock and setting of _set_il (numeric
value) are required in advance. See the chapter of
clock and interrupt.
246
Program example
void FREE_RUN_TIMER_sample(void)
{
FREERUN_initial();
FREERUN_start();
}
void FREERUN_initial(void)
{
IO_TCCS.word = 0x006C; /* Setting value=0000_0000_0110_1100 */
TCCS
.ECKE
.IVF
.IVFE
.STOP
.MODE
.SCLR
.CLK2-0
IO_TCDT = 0x0000;
TCDT
IO_ICR12.byte = 0x00;
ICR12
__EI();
(CCR)
count = 0;
}
void FREERUN_start(void)
{
Register name. bit name
IO_TCCS.bit.STOP = 0; /* bit5 = 0
TCCS .STOP
}
__interrupt void FREE_RUN_TIMER_int(void)
{
Register name. bit name
IO_TCCS.bit.IVF = 0;
TCCS .IVF
count++;
}
#pragma intvect FREE_RUN_TIMER_int 35
Note:
For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR
2
F
MC-16LX FAMILY MB90480 SERIES".
/* 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 */
/* Initialize
timer data value */
/* Set interrupt level of free-running timer (arbitrary value)
*/
/* Enable interrupt */
Enable STOP count */
/* bit7 = 0
Clear IVF overflow flag */

Advertisement

Table of Contents
loading

Table of Contents