Program Example Of 8/16-Bit Ppg Timer - Fujitsu MB90480 Series Hardware Manual

F2mc-16lx 16-bit microcontroller
Table of Contents

Advertisement

CHAPTER 15 8/16-BIT PPG TIMER
15.6

Program Example of 8/16-Bit PPG Timer

This section describes the program example of the 8/16-bit PPG timer.
Program Example of 8/16-bit PPG Timer
Example of setting procedure
Generate interval interrupt and output PPG.
(PPG output from PPG1 pin, software trigger)
<Initial setting>
Control PPG01
Set control register
Select count clock >>
Set control register
Enable pulse output >>
Enable interrupt >>
Select operation mode >>
Set duty
Set PPG01 duty
Interrupt related
Set PPG01 interrupt level
Set I flag
<Start>
Start PPG01
Enable interrupt
Start PPG01
<Interrupt>
Interrupt processing
Any processing
Clear interrupt request flag PPGC01.PUF1
<Interrupt vector>
Set vector table
<Other>
Note:
Setting related to clock and setting of _set_il (numeric
value) are required in advance. See the chapter of
clock and interrupt.
*1: io_PPG01 represents PPG1 register and PPG0 register.
*2: io_PPGC01 represents PPGC1 register and PPGC0 register.
*3: io_PRL0 represents PRLL0 register and PRLH0 register.
338
Program example
void PPG_sample(void)
{
PPG01_initial();
PPG01_start();
}
void PPG01_initial(void)
{
Register name. bit name
PPG01
.PCS2-0
IO_PPG01.bit.PCS = 1;
IO_PPGC01.word = 0x3101;/* bit15 = 0
PPGC01
.PE10
.PIE1
.MD1-0
IO_PRL0.word = 0x7f7f;
PRL0
IO_ICR05.byte = 0x10;
__EI();
ICR05
}
(CCR)
void PPG01_start(void)
{
Register name. bit name
IO_PPGC01.bit.PIE1 = 1; /* bit12= 1
PPGC01.PIE1
IO_PPGC01.bit.PEN1 = 1; /* bit15 = 1
PPGC01.PEN1
}
__interrupt void PPG01_int(void)
{
IO_PPGC01.bit.PUF1 = 0; /* bit11 = 0
}
#pragma intvect PPG01_int 22
Note:
For the description form of the register, see "SAMPLE I/O REGISTER FILES FOR
2
F
MC-16LX FAMILY MB90480 SERIES".
*1
/* bit7-5 = 0
Select PPG1 count clock */
*2
Stop PPG operation */
/* bit13 = 1
Enable PPG1/3/5 pulse output */
/* bit12 = 1
Enable PPG interrupt */
/* bit11 = 0
Clear PUF1 interrupt request flag */
/* bit10-9 = 00 8-bit PPG 2ch */
/* bit8 = 1
Reserved bit */
/* bit0 = 1
Reserved bit */
*3
/*
Set PPG duty ratio */
/* Interrupt level (arbitrary value) */
/* Enable interrupt */
Enable PIE1 interrupt request */
Start PEN1 PPG operation */
/* Any processing */
PUF1 interrupt request flag */

Advertisement

Table of Contents
loading

Table of Contents