312
CHAPTER 14 16-BIT RELOAD TIMER
14.5 Program Example of 16-Bit Reload Timer
This section explains the program example of the 16-bit reload timer.
■
Program example of 16-bit reload timer
Example of setting procedure
Software trigger output pulse from TOT0, duty1/2, normal
polarity
Program example
void RT_sample(void)
{
RT_initial();
RT_start();
}
<Initial setting>
•
Interrupt related
void RT_initial(void)
{
IO_TMRLR = 0xAA ;
/* Insert any value for reload value */
IO_TMCSR.word = 0x0050; /* Setting value =0000_0000_0101_0000 */
/* bit15-12=0000 Undefined bit */
/* bit11-10=00
CSL1,CSL0 internal clock
φ
/2 */
/* bit9-7=000
MOD software trigger */
/* bit6=1
Enable OUTE output */
/* bit5=0
OUTL external output level Low */
/* bit4=1
Enable RELD reload */
/* bit3=0
Disable INTE interrupt */
/* bit2=0
Clear UF interrupt request flag */
/* bit1=0
Stop CNTE count */
/* bit0=0
TRG software trigger */
IO_ICR12.byte =0x10;
/* Set interrupt level */
__EI();
/* Enable interrupt */
}
<Start>
•
Start reload timer
void RT_start(void)
{
IO_TMCSR.word = 0x005B;
/* bit3=1
Enable INTE interrupt */
/* bit2=0
Clear UF interrupt request flag */
/* bit1=1
Start CNTE count */
/* bit0=1
TRG software trigger */
}
<Interrupt>
•
Interrupt processing
__interrupt void RT_int(void)
/* Interrupt occurs at generation of underflow */
{
IO_TMCSR.bit.UF = 0;
/* bit2=0
Clear UF interrupt request flag */
........
/* Any processing operation */
}
Interrupt vector
•
Set vector table
#pragma intvect RT_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".
•
Setting
Register name. bit name
Set reload value
TMRLR
•
Control reload timer 0
Set control register
TMCSR
Select clock source>>
.CSL1,CSL0
Select trigger>>
.MOD
Enable output>>
.OUTE
Select output level>>
.OUTL
Select operation mode>>
.RELD
Disable interrupt>>
.INTE
Clear interrupt flag>>
.UF
Stop count>>
.CNTE
Software trigger>>
(no processing)
.TRG
Interrupt level of reload timer
ICR12
Set I flag
(CCR)
Register name. bit name
Start PPG
TMCSR
Clear interrupt flag>>
UF
Enable interrupt>>
.INTE
Enable count>>
.CNTE
Software trigger (start)>>
.TRG
(Arbitrary processing)
Clear interrupt request flag
TMCSR.UF
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: ......