Renesas Network Card RJJ10J1643 0101 User Guide

REJ10J1502-0101  
Renesas Embedded  
Application Programming Interface  
Reference manual  
Rev.1.01  
Feb 16, 2007  
www.renesas.com  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Description of third argument in __CreateInputCapture corrected  
Wording “specified” unified to “specified”  
RAPI_BOTH deleted from the description of timer B1 count edges of H8/300H in  
__CreateEventCounter  
RAPI_FTIOA and RAPI_FTIOB added to __CreatePulsePeriodMeasurementMode and  
__CreatePulseWidthMeasurementMode  
All occurrences of the word “Tiny” deleted  
Description of second argument added to __GetPulsePeriodMeasurementMode,  
__GetPulseWidthMeasurementMode, and __GetEventCounter  
Description regarding timer V trigger of H8 in __CreateTimer, __CreateEventCounter,  
and __CreatePulseWidthMeasurementMode corrected  
Explanation of H8 interrupt settings and interrupt control register settings in  
__SetSerialInterrupt corrected  
Remarks on timer V of H8/300H in __EnableTimerRegister added  
Specification of timer RA input pins of R8C in __CreatePulsePeriodMeasurementMode  
and __CreatePulseWidthMeasurementMode as well as RAPI_TIOSEL_P1_7 and  
RAPI_TIOSEL_P1_5 added  
File name in program example corrected  
Item “Reference” in __BasicSetSerialFormat deleted  
__BasicSetSerialFormat added to “Reference” in __SetSerialFormat and  
__SetSerialInterrupt  
Error in writing of __CreateInput Capture and __CreateOutputCapture corrected  
Explanation added to Section 2.1, “Overview”  
Causes of clearing of timer W and timer RC counters in __CreateInputCapture deleted  
RAPI_COMPARE_MATCH_A_STOP and RAPI_STOP added to the item for the R8C in  
__CreateOutputCompare  
Changed to RAPI_INT_LV_0 and RAPI_INT_LV_1 for H8/300H in __SetSerialInterrupt  
Description relating to clock in __CreateTimer corrected  
RAPI_TRC_FILTER and RAPI_TRD_FILTER added to filter specification for H8 in  
__CreatePulsePeriodMeasurementMode and __CreatePulseWidthMeasurementMode  
RAPI_TIMER_RD2 and RAPI_TIMER_RD3 added to timer RD of H8/36109  
Description relating to timer V trigger input for H8/300H in __CreateTimer deleted  
Description of pulse output function added to the item for R8C in  
__CreateEventCounter  
Description of timer RE usage added to items data3 and data5 for R8C in  
__CreateOutputCompare  
Filter function of timer RC and timer RD in __CreatePulsePeriodMeasurementMode,  
__CreatePulseWidthMeasurementMode, and __CreateInputCapture corrected  
Description that multiple defined values can be set for data1 in __EnableInterrupt  
added  
Description that RAPI_WITHOUT_SAMPLE_HOLD is specifiable in delay trigger  
modes 0 and 1 of M16C in __CreateADC corrected  
Description that RAPI_FOCOF is specifiable in repeat mode of R8C in __CreateADC  
corrected  
Rev.1.01  
2007.02.16  
3
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_AN30, RAPI_AN31, RAPI_AN32, and RAPI_P9_GROUP added to the item for  
data1 of M16C in __CreateADC  
RAPI_AN30, RAPI_AN31, RAPI_AN32, and RAPI_P9_GROUP added to the item for  
data1 of M16C in __EnableADC  
Error in writing of H8/300H interrupt set values in __CreateOutputCompare corrected  
Error in writing of timer RD and timer RD symbol name corrected  
Description of gate function of M16C in __CreateEventCounter deleted  
Description of H8/300H noise rejection function in __BasicSetSerialFormat added  
Description  
of  
timer  
W
input  
pins  
of  
H8/300H  
in  
__CreatePulsePeriodMeasurementMode and __CreatePulseWidthMeasurementMode  
deleted  
Rev.1.01  
2007.02.16  
4
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Table of Contents  
Table of Contents ................................................................ 5  
1. Introduction................................................................... 8  
2. Driver ....................................................................... 9  
2.1 Overview.................................................................. 9  
2.2 Driver Features ............................................................ 10  
2.3 Serial Interface Driver....................................................... 11  
2.4 Timer Driver .............................................................. 12  
2.4.1 Timer Mode ........................................................... 12  
2.4.2 Event Counter Mode .................................................... 12  
2.4.3 Pulse Width Modulation Mode (PWM Mode)................................. 12  
2.4.4 Pulse Period Measurement Mode .......................................... 12  
2.4.5 Pulse Width Measurement Mode ........................................... 12  
2.4.6 Input Capture Mode..................................................... 12  
2.4.7 Output Compare Mode .................................................. 13  
2.5 I/O Port Driver ............................................................ 14  
2.6 External Interrupt Driver..................................................... 15  
2.7 A/D Converter Driver ....................................................... 16  
3. Standard Types ...............................................................18  
4. Library Reference ............................................................. 19  
4.1 API List by Peripheral Facility ................................................ 19  
4.2 Description of Each API ..................................................... 21  
4.2.1 Serial I/O ............................................................. 22  
__BasicOpenSerialDriver ................................................... 22  
__BasicCloseSerialDriver................................................... 23  
__BasicSetSerialFormat .................................................... 24  
__BasicStartSerialReceiving................................................. 29  
__BasicStartSerialSending .................................................. 30  
__BasicReceivingStatusRead ................................................ 31  
__BasicSendingStatusRead.................................................. 33  
__BasicStopSerialReceiving................................................. 34  
__BasicStopSerialSending .................................................. 35  
__OpenSerialDriver ....................................................... 36  
__CloseSerialDriver ....................................................... 37  
__ConfigSerialDriverNotify ................................................. 38  
__SetSerialFormat......................................................... 41  
__SetSerialInterrupt ....................................................... 42  
__StartSerialReceiving ..................................................... 45  
__StartSerialSending....................................................... 47  
__StopSerialReceiving ..................................................... 49  
__StopSerialSending....................................................... 50  
__PollingSerialReceiving ................................................... 51  
__PollingSerialSending..................................................... 52  
4.2.2 Timer ................................................................ 54  
Rev.1.01  
2007.02.16  
5
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreateTimer ........................................................... 54  
__EnableTimer ........................................................... 60  
__DestroyTimer .......................................................... 62  
__CreateEventCounter ..................................................... 64  
__EnableEventCounter ..................................................... 69  
__DestroyEventCounter .................................................... 71  
__GetEventCounter........................................................ 73  
__CreatePulseWidthModulationMode ......................................... 75  
__EnablePulseWidthModulationMode......................................... 80  
__DestroyPulseWidthModulationMode ........................................ 82  
__CreatePulsePeriodMeasurementMode ....................................... 83  
__EnablePulsePeriodMeasurementMode ....................................... 88  
__DestroyPulsePeriodMeasurementMode ...................................... 90  
__GetPulsePeriodMeasurementMode.......................................... 92  
__CreatePulseWidthMeasurementMode........................................ 94  
__EnablePulseWidthMeasurementMode ....................................... 99  
__DestroyPulseWidthMeasurementMode ..................................... 101  
__GetPulseWidthMeasurementMode ......................................... 103  
__CreateInputCapture..................................................... 105  
__EnableInputCapture .................................................... 115  
__DestroyInputCapture.................................................... 117  
__GetInputCapture ....................................................... 119  
__CreateOutputCompare .................................................. 121  
__EnableOutputCompare .................................................. 133  
__DestroyOutputCompare ................................................. 135  
__SetTimerRegister ...................................................... 137  
__EnableTimerRegister.................................................... 143  
__ClearTimerRegister..................................................... 145  
__GetTimerRegister ...................................................... 147  
4.2.3 I/O Port ............................................................. 153  
__SetIOPort ............................................................ 153  
__ReadIOPort ........................................................... 158  
__WriteIOPort........................................................... 162  
__SetIOPortRegister ...................................................... 166  
__ReadIOPortRegister .................................................... 168  
__WriteIOPortRegister .................................................... 170  
4.2.4 External interrupt ...................................................... 172  
__SetInterrupt ........................................................... 172  
__EnableInterrupt ........................................................ 176  
__GetInterruptFlag ....................................................... 178  
__ClearInterruptFlag...................................................... 180  
4.2.5 A/D converter......................................................... 182  
__CreateADC ........................................................... 182  
__EnableADC........................................................... 191  
__DestroyADC .......................................................... 196  
Rev.1.01  
2007.02.16  
6
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetADC ............................................................. 197  
__GetADCAll ........................................................... 198  
__GetADCStatus......................................................... 199  
__ClearADCStatus ....................................................... 200  
Rev.1.01  
2007.02.16  
7
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
1. Introduction  
The Renesas Embedded Application Programming Interface (API) is a unified API for  
the microcomputers made by Renesas Technology Corporation.  
Rev.1.01  
2007.02.16  
8
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2. Driver  
2.1 Overview  
The library described herein provides a peripheral facility control program (peripheral  
driver) for microcomputers. Use of the Renesas API permits the peripheral driver to be  
built into a user program.  
Configuration of Renesas APIs is shown below.  
File name  
rapi_xxx_yyy.lib  
Description  
This is the Renesas API library file. To use  
Renesas APIs, specify this file as input file  
for the linker.  
(xxx = family name, yyy = series name)  
rapi_ad_xxx_yyy.h  
This is the header file for A/D converter  
driver APIs. To use A/D converter driver  
APIs, be sure to include this file.  
This is the header file for I/O port driver  
APIs. To use I/O port driver APIs, be sure  
to include this file.  
(xxx = family name, yyy = series name)  
rapi_io_port_xxx_yyy.h  
(xxx = family name, yyy= series name)  
rapi_sif_xxx_yyy.h  
This is the header file for serial I/F driver  
APIs. To use serial I/F driver APIs, be sure  
to include this file.  
(xxx = family name, yyy= series name)  
rapi_timer_xxx_yyy.h  
This is the header file for timer driver  
APIs. To use timer driver APIs, be sure to  
include this file.  
(xxx = family name, yyy= series name)  
Interrupt_xxx_yyy.h  
This is the interrupt function source file for  
Renesas APIs. To use Renesas APIs that  
use interrupts, add this file to the user  
program.  
(xxx = family name, yyy= series name)  
rapi_io_xxx_yyy.h  
This is the CPU control register definition  
header file for Renesas APIs.  
(xxx = family name, yyy= series name)  
Rev.1.01  
2007.02.16  
9
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.2 Driver Features  
The library described herein has the following features available as a peripheral driver.  
(1) Serial I/O control feature  
It comprises a serial interface driver, which sets or clears the conditions of serial  
communication, as well as controls and manages the transmission/reception of  
communication data.  
(2) Timer control feature  
It comprises a timer driver, which sets or clears the operating conditions of timers,  
as well as controls the timer operation.  
(3) I/O port control feature  
It comprises an I/O port driver, which sets or clears the usage conditions of I/O ports, as  
well as control data read/write operation.  
(4) External interrupt control feature  
It comprises an external interrupt driver, which sets or clears the usage conditions of  
external interrupts, as well as controls interrupt operation.  
(5) A/D converter control feature  
It comprises an A/D converter driver, which sets or clears the usage conditions of A/D  
converters, as well as controls A/D converter operation.  
Rev.1.01  
2007.02.16  
10  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.3 Serial Interface Driver  
The serial interface driver sets serial communication, clears settings, transmit/receives  
data, and controls the status of serial communication.  
There are two kinds of serial interface driver: a single-data transmission/reception API  
and a multi-data transmission/reception API.  
Rev.1.01  
2007.02.16  
11  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.4 Timer Driver  
The timer driver sets the timer, clears timer settings, controls timer operation, and  
acquires a counter value with respect to the following modes:  
Timer mode  
Event counter mode  
Pulse width modulation mode (PWM mode)  
Pulse period measurement mode  
Pulse width measurement mode  
Input capture mode  
Output compare mode  
2.4.1 Timer Mode  
In this mode, the timer counts the internally generated count source. When an  
underflow or an overflow interrupt occurs, it calls a preset callback function.  
2.4.2 Event Counter Mode  
In this mode, the timer counts the external signal fed in from an input pin or an  
overflow or underflow from other timer. When an underflow or an overflow interrupt  
occurs, it calls a preset callback function.  
2.4.3 Pulse Width Modulation Mode (PWM Mode)  
In this mode, the timer outputs pulses in a given width successively. When an  
underflow or an overflow interrupt occurs, it calls a preset callback function.  
2.4.4 Pulse Period Measurement Mode  
In this mode, the timer measures the pulse period of an external signal fed in from an  
input pin. When an underflow or an overflow interrupt occurs, it calls a preset callback  
function.  
2.4.5 Pulse Width Measurement Mode  
In this mode, the timer measures the pulse width of an external signal fed in from an  
input pin. When an underflow or an overflow interrupt occurs, it calls a preset callback  
function.  
2.4.6 Input Capture Mode  
In this mode, the timer latches the timer value upon an active signal edge or clock  
pulse at an input pin, thereby generating an interrupt request. When an input capture  
interrupt or an underflow or an overflow interrupt occurs, it calls a preset callback  
function.  
Rev.1.01  
2007.02.16  
12  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.4.7 Output Compare Mode  
In this mode, the timer generates an interrupt request when the timer counter and a  
comparison value match. When a compare match interrupt or an underflow or an  
overflow interrupt occurs, it calls a preset callback function.  
Rev.1.01  
2007.02.16  
13  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.5 I/O Port Driver  
The I/O port driver sets the I/O port for input or output, writes data to the I/O port, and  
reads data from the I/O port.  
Rev.1.01  
2007.02.16  
14  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.6 External Interrupt Driver  
The external interrupt driver sets external interrupts, controls external interrupts,  
acquires the status of external interrupt flags, and clears external interrupt flags.  
Rev.1.01  
2007.02.16  
15  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
2.7 A/D Converter Driver  
The A/D converter driver sets the A/D converter, controls the A/D converter, clears  
settings of the A/D converter, acquires the A/D converter value, acquires the status of the  
A/D converter, and clears the status of the A/D converter.  
[A/D converter driver usage example (single-shot mode)]  
Here, a program example is shown for the A/D converter operating in single-shot mode  
under the conditions given below.  
CPU  
:
:
:
:
:
:
R8C  
Operating clock  
Resolution  
fAD divided by 2  
10 bits  
Analog input pin  
A/D conversion start condition  
Sample-and-hold  
AN0 pin  
Software trigger  
Enabled  
A program flow and a program example are shown below.  
(Program flow)  
main()  
Set the A/D converter in  
__CreateADC()  
single-shot mode  
Start A/D conversion  
__EnableADC()  
__GetADCStatus()  
__GetADC()  
No  
A/D interrupt?  
Yes  
Read out the A/D conversion value  
Clear the A/D interrupt flag  
__ClearADCStatus()  
Rev.1.01  
2007.02.16  
16  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Program example  
#include "rapi_ad_r8c_13.h"  
void main( void )  
{
unsigned int status, data;  
/* Set up A/D converter as one short mode */  
__CreateADC(  
RAPI_ONE_SHOT|RAPI_AN0|RAPI_FAD2|  
RAPI_WITH_SAMPLE_HOLD|  
RAPI_AD_OFF|RAPI_10BIT, 1, 0, 0 );  
while( 1 ){  
/* Disable A/D converter */  
__EnableADC( RAPI_AN0| RAPI_AD_ON, 1 );  
/* Check a flag bit of A/D converter interrupt */  
do{  
__GetADCStatus( &status );  
} while( (*status & 0x0001) == 0 )  
/* Get A/D convertered datas of A/D register */  
__GetADC( &data );  
/* Clear status of A/D convertered */  
__ClearADCStatus( 0 );  
}
}
Rev.1.01  
2007.02.16  
17  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
3. Standard Types  
This section describes the standard types defined in the library. For details about the  
set values, refer to the description of each API.  
Standard type  
Description  
Boolean  
The Boolean type represents the enum-type data that indicates  
whether successful (RAPI_TRUE (= 1)) or failed (RAPI_FALSE (=  
0)).  
VoidFuncNotify  
The VoidFuncNotify type represents the type of the notification  
function to be registered.  
Rev.1.01  
2007.02.16  
18  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4. Library Reference  
4.1 API List by Peripheral Facility  
The table below lists the Renesas Embedded APIs classified by peripheral facility.  
NO  
Facility  
API  
API operation  
classification  
Opens serial port  
Single-data  
serial I/O  
1
2
__BasicOpenSerialDriver  
__BasicCloseSerialDriver  
__BasicSetSerialFormat  
__BasicStartSerialReceiving  
__BasicStartSerialSending  
__BasicReceivingStatusRead  
__BasicSendingStatusRead  
__BasicStopSerialReceiving  
__BasicStopSerialSending  
__OpenSerialDriver  
Closes serial port  
Sets serial communication  
Receives 1 data  
3
4
Transmits 1 data  
5
Reads receive status  
Reads transmit status  
Stops reception  
6
7
8
Stops transmission  
9
Opens serial port  
Multi-data  
serial I/O  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
Closes serial port  
__CloseSerialDriver  
Registers notification function  
Sets serial communication  
Sets transmit/receive interrupt  
Starts reception  
__ConfigSerialDriverNotify  
__SetSerialFormat  
__SetSerialInterrupt  
__StartSerialReceiving  
__StartSerialSending  
__StopSerialReceiving  
__StopSerialSending  
__PollingSerialReceiving  
__PollingSerialSending  
__CreateTimer  
Starts transmission  
Stops reception  
Stops transmission  
Receives by polling  
Transmits by polling  
Sets timer mode  
Timer  
Controls timer mode operation  
Clears timer mode setting  
Sets event counter mode  
__EnableTimer  
__DestroyTimer  
__CreateEventCounter  
__EnableEventCounter  
Controls operation of event counter  
mode  
Clears setting of event counter  
mode  
Gets event counter mode counter  
value  
26  
27  
__DestroyEventCounter  
__GetEventCounter  
Sets pulse width modulation mode  
28  
29  
__CreatePulseWidthModulationMode  
__EnablePulseWidthModulationMode  
Controls operation of pulse width  
modulation mode  
Clears setting of pulse width  
modulation mode  
Sets pulse period measurement  
mode  
Controls operation of pulse period  
measurement mode  
Clears setting of pulse width  
measurement mode  
30  
31  
32  
33  
34  
__DestroyPulseWidthModulationMode  
__CreatePulsePeriodMeasurementMode  
__EnablePulsePeriodMeasurementMode  
__DestroyPulsePeriodMeasurementMode  
__GetPulsePeriodMeasurementMode  
Acquires measured value of pulse  
period measurement mode  
Rev.1.01  
2007.02.16  
19  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Sets pulse width measurement  
mode  
Controls operation of pulse width  
measurement mode  
Clears setting of pulse width  
measurement mode  
Acquires measured value of pulse  
width measurement mode  
Sets input capture mode  
35  
36  
37  
38  
__CreatePulseWidthMeasurementMode  
__EnablePulseWidthMeasurementMode  
__DestroyPulseWidthMeasurementMode  
__GetPulseWidthMeasurementMode  
Timer  
39  
40  
__CreateInputCapture  
__EnableInputCapture  
Controls operation of input capture  
mode  
Clears setting of input capture mode  
41  
42  
__DestroyInputCapture  
__GetInputCapture  
Acquires counter value of input  
capture mode  
Sets output compare mode  
43  
44  
__CreateOutputCompare  
__EnableOutputCompare  
Controls operation of output  
compare mode  
Clears setting of output compare  
mode  
45  
__DestroyOutputCompare  
Sets timer register  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
__SetTimerRegister  
__EnableTimerRegister  
__ClearTimerRegister  
__GetTimerRegister  
__SetIOPort  
Controls operation of timer register  
Clears timer register  
Gets timer register value  
Sets I/O port  
I/O port  
Reads from I/O port  
__ReadIOPort  
Writes to I/O port  
__WriteIOPort  
Sets I/O port register  
__SetIOPortRegister  
__ReadIOPortRegister  
__WriteIOPortRegister  
__SetInterrupt  
Reads from I/O port register  
Writes to I/O port register  
Sets external interrupt  
External  
interrupt  
Controls external interrupt  
Gets flag status of external interrupt  
Clears flag of external interrupt  
Sets A/D converter  
__EnableInterrupt  
__GetInterruptFlag  
__ClearInterruptFlag  
__CreateADC  
A/D converter  
Controls operation of A/D converter  
Discards settings of A/D converter  
__EnableADC  
__DestroyADC  
Gets A/D conversion value (register  
specified)  
__GetADC  
Gets A/D conversion value (all  
registers)  
64  
__GetADCAll  
Gets status of A/D converter  
65  
66  
__GetADCStatus  
__ClearADCStatus  
Clears status of A/D converter  
Rev.1.01  
2007.02.16  
20  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4.2 Description of Each API  
This section describes each API and explains how to use them, showing a program  
example for each.  
The description of each API is divided into the following items.  
• Synopsis  
:
Outlines the content of processing performed by the function. It  
also shows the syntax of the function, followed by a brief  
explanation of arguments.  
• Description  
• Return value  
• Functionality  
• Reference  
:
:
:
:
:
:
Describes the function and how to use it in detail.  
Explains the returned value of the function.  
Indicates the functional classification of the function.  
Indicates the related functions.  
• Remark  
Describes the precautions to be taken when using the API.  
Presents a program showing how to use the function.  
• Program example  
Rev.1.01  
2007.02.16  
21  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4.2.1 Serial I/O  
__BasicOpenSerialDriver  
Synopsis  
<Open a serial port>  
Boolean __BasicOpenSerialDriver(unsigned long data)  
data  
Setup data  
Description  
Opens and initializes a specified serial port.  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicCloseSerialDriver  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
When used for the H8/300H, this API opens and initializes a specified serial port  
when freeing it from module standby state.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
/* Open serial driver */  
return __BasicOpenSerialDriver( RAPI_COM1 );  
}
Rev.1.01  
2007.02.16  
22  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicCloseSerialDriver  
Synopsis  
<Close a serial port>  
Boolean __BasicCloseSerialDriver(unsigned long data)  
data  
Setup data  
Description  
Closes a specified serial port. For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicOpenSerialDriver  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
When used for the H8/300H, this API places a specified serial port into module  
standby state after closing it.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
/* Close serial driver */  
return Rapi_BasicCloseSerialDriver( RAPI_COM1 );  
}
Rev.1.01  
2007.02.16  
23  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicSetSerialFormat  
Synopsis  
<Set serial communication>  
Boolean __BasicSetSerialFormat(unsigned long data1, unsigned char data2)  
data1  
data2  
Setup data 1  
Setup data 2  
Description  
Sets serial communication according to specified parameters.  
[data1]  
For data1, the following values can be set. To set multiple definition values at the same  
time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
For serial communication mode, the following values can be set.  
(M16C) (UART0, UART1, UART2)  
RAPI_SM_SYNC  
RAPI_SM_ASYNC  
Clock synchronous serial communication mode  
Clock asynchronous serial communication mode  
(M16C)(SI/O3, SI/O4)  
RAPI_SIO_SM_SYNC  
Clock synchronous serial communication mode  
For the data length format of clock asynchronous serial communication, the following  
values can be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(M16C) (UART0, UART1, UART2)  
RAPI_BIT_7  
RAPI_BIT_9  
Transfer data length 7 bits RAPI_BIT_8  
Transfer data length 9 bits  
Transfer data length 8 bits  
For the clock source of serial communication, the following values can be set.  
(M16C) (UART0, UART1, UART2)  
RAPI_CKDIR_INT  
RAPI_CKDIR_EXT  
Internal clock is used as the clock source of serial communication.  
External clock is used as the clock source of serial communication.  
(M16C) (SI/O3, SI/O4)  
RAPI_SIO_CKDIR_INT  
Internal clock is used as the clock source of serial communication.  
RAPI_SIO_CKDIR_EXT External clock is used as the clock source of serial communication.  
For the stop bit length of clock asynchronous serial communication, the following  
values can be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(M16C) (UART0, UART1, UART2)  
RAPI_STPB_1  
1 stop bit  
RAPI_STPB_2  
2 stop bits  
For the parity bit of clock asynchronous serial communication, the following values can  
be set.  
Rev.1.01  
2007.02.16  
24  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(M16C) (UART0, UART1, UART2)  
RAPI_PARITY_NON No parity bit  
RAPI_PARITY_ODD Odd parity bit  
RAPI_PARITY_EVEN  
Even parity bit  
For the clock polarity of serial communication, the following values can be set.  
If the API is used in clock asynchronous serial communication mode, do not set these  
values.  
(M16C) (UART0, UART1, UART2)  
RAPI_DPOL_NON  
Polarity not inverted  
RAPI_DPOL_INV  
Polarity inverted  
(M16C) (SI/O3, SI/O4)  
RAPI_SIO_DPOL_NON Polarity not inverted  
RAPI_SIO_DPOL_INV  
Polarity inverted  
For the count source of the built-in baud rate generator, the following values can be set.  
(M16C) (UART0, UART1, UART2)  
RAPI_BCSS_F1  
RAPI_BCSS_F8  
f1SIO  
f8SIO  
RAPI_BCSS_F2  
RAPI_BCSS_F32  
f2SIO  
f32SIO  
(M16C) (SI/O3, SI/O4)  
RAPI_SIO_BCSS_F1  
RAPI_SIO_BCSS_F8  
f1SIO  
f8SIO  
RAPI_SIO_BCSS_F2  
f2SIO  
RAPI_SIO_BCSS_F32 f32SIO  
For the _CTS/_RTS function, the following values can be set.  
If the internal clock is selected for use in clock synchronous serial communication  
mode, the _RTS function has no effect.  
(M16C) (UART0, UART1, UART2)  
RAPI_CTSRTS_DIS  
RAPI_CTS_SEL  
RAPI_RTS_SEL  
_CTS/_RTS functions are not used.  
_CTS function is selected.  
_RTS function is selected.  
For the transfer format, the following values can be set.  
If the data length selected for use in clock asynchronous serial communication mode is  
7 or 9 bits long, do not set these values.  
(M16C) (UART0, UART1, UART2)  
RAPI_LSB_SEL  
LSB first  
RAPI_MSB_SEL  
MSB first  
MSB first  
(M16C) (SI/O3, SI/O4)  
RAPI_SIO_LSB_SEL  
LSB first  
RAPI_SIO_MSB_SEL  
For serial data logic switchover, the following values can be set.  
(M16C) (UART2)  
RAPI_LOGIC_NO_REV The value written in the transmit buffer register does not have its  
logic inverted.  
RAPI_LOGIC_REV  
The value written in the transmit buffer register is inverted before  
being transmitted.  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
UART1  
For serial communication mode, the following values can be set.  
Rev.1.01  
2007.02.16  
25  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(R8C) (UART0, UART1)  
RAPI_SM_SYNC  
Clock synchronous serial communication mode  
Clock asynchronous serial communication mode  
RAPI_SM_ASYNC  
For the data length format of clock asynchronous serial communication, the following  
values can be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(R8C) (UART0, UART1)  
RAPI_BIT_7  
RAPI_BIT_9  
Transfer data length 7 bits  
Transfer data length 9 bits  
RAPI_BIT_8  
Transfer data length 8 bits  
For the clock source of serial communication, the following values can be set.  
(R8C) (UART0, UART1)  
RAPI_CKDIR_INT  
RAPI_CKDIR_EXT  
Internal clock is used as the clock source of serial communication.  
External clock is used as the clock source of serial communication.  
For the stop bit length of clock asynchronous serial communication, the following  
values can be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(R8C) (UART0, UART1)  
RAPI_STPB_1  
1 stop bit  
RAPI_STPB_2  
2 stop bits  
For the parity bit of clock asynchronous serial communication, the following values can  
be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(R8C) (UART0, UART1)  
RAPI_PARITY_NON  
RAPI_PARITY_ODD  
No parity bit  
RAPI_PARITY_EVEN  
Even parity bit  
Odd parity bit  
For the clock polarity of serial communication, the following values can be set.  
If the API is used in clock asynchronous serial communication mode, do not set these  
values.  
(R8C) (UART0, UART1)  
RAPI_DPOL_NON  
Polarity not inverted  
RAPI_DPOL_INV  
Polarity inverted  
For the count source of the built-in baud rate generator, the following values can be set.  
(R8C) (UART0, UART1)  
RAPI_BCSS_F1  
RAPI_BCSS_F32  
f1SIO  
RAPI_BCSS_F8  
f8SIO  
f32SIO  
For the transfer format, the following values can be set.  
If the data length selected for use in clock asynchronous serial communication mode is  
7 or 9 bits long, do not set these values.  
(R8C) (UART0, UART1)  
RAPI_LSB_SEL  
LSB first  
RAPI_MSB_SEL  
RAPI_COM2  
MSB first  
(H8/300H)  
RAPI_COM1  
SCI3 channel 1  
SCI3 channel 2  
Rev.1.01  
2007.02.16  
26  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_COM3  
SCI3 channel 3  
For serial communication mode, the following values can be set.  
(H8/300H) (SCI3 channel 1, SCI3 channel 2, SCI3 channel 3)  
RAPI_SM_SYNC  
RAPI_SM_ASYNC  
Clock synchronous serial communication mode  
Clock asynchronous serial communication mode  
For the data length format of clock asynchronous serial communication, the following  
values can be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(H8/300H) (SCI3 channel 1, SCI3 channel 2, SCI3 channel 3)  
RAPI_BIT_7  
Transfer data length 7 bits  
RAPI_BIT_8  
Transfer data length 8 bits  
For the clock source of serial communication, the following values can be set.  
(H8/300H) (SCI3 channel 1, SCI3 channel 2)  
RAPI_CKDIR_INT  
RAPI_CKDIR_EXT  
Internal clock is used as the clock source of serial communication.  
External clock is used as the clock source of serial communication.  
For the stop bit length of clock asynchronous serial communication, the following  
values can be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(H8/300H) (SCI3 channel 1, SCI3 channel 2, SCI3 channel 3)  
RAPI_STPB_1  
1 stop bit  
RAPI_STPB_2  
2 stop bits  
For the parity bit of clock asynchronous serial communication, the following values can  
be set.  
If the API is used in clock synchronous serial communication mode, do not set these  
values.  
(H8/300H) (SCI3 channel 1, SCI3 channel 2, SCI3 channel 3)  
RAPI_PARITY_NON  
RAPI_PARITY_ODD  
No parity bit  
RAPI_PARITY_EVEN  
Even parity bit  
Odd parity bit  
For the count source of the built-in baud rate generator, the following values can be set.  
(H8/300H) (SCI3 channel 1, SCI3 channel 2 SCI3 channel 3)  
RAPI_BCSS_F1  
RAPI_BCSS_F16  
Φ clock  
RAPI_BCSS_F4  
RAPI_BCSS_F32  
φ/4 clock  
φ/16 clock  
φ/64 clock  
The noise rejection function can be set to be turned on or turned off.  
When used in clock synchronous serial communication mode, the noise rejection  
function has no effect.  
(H8/300H) (SCI3 channel 3)  
RAPI_NOISE_CANCEL_ON  
RAPI_NOISE_CANCEL_OFF  
[data2]  
Noise rejection function turned on  
Noise rejection function turned off  
Sets the divide-by-N value of a communication speed.  
Return value  
If serial communication was successfully set, RAPI_TRUE is returned; if settings failed,  
RAPI_FALSE is returned.  
Rev.1.01  
2007.02.16  
27  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Functionality  
Remark  
Serial I/O  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
Boolean func( void )  
{
/* Set the data of RAPI_COM1 to serial driver */  
return _BasicSetSerialFormat(RAPI_COM1 | RAPI_SM_SYNC | RAPI_CKDIR_INT  
|
RAPI_BCSS_F1 | RAPI_DPOL_NON | RAPI_LSB_SEL,  
20);  
}
Rev.1.01  
2007.02.16  
28  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicStartSerialReceiving  
Synopsis  
<Receive 1 data>  
Boolean __BasicStartSerialReceiving(unsigned long data)  
data  
Setup data  
Description  
Starts receiving 1 data of serial communication.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If data reception in serial communication was successfully started, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicReceivingStatusRead, __BasicStopSerialReceiving  
For the H8/300H, wait for at least a 1-bit period before calling this API after  
__BasicSetSerialFormat was called.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
..........  
__BasicStartSerialReceiving( RAPI_COM1 );  
..........  
}
Rev.1.01  
2007.02.16  
29  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicStartSerialSending  
Synopsis  
<Transmit 1 data>  
Boolean _BasicStartSerialSending(unsigned long data1, unsigned int data2)  
data  
data  
Setup data  
Transmit data  
Description  
Starts sending 1 data of serial communication.  
For data1, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SIC3 channel 3  
SCI3 channel 2  
Return value  
If data transmission in serial communication was successfully started, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicSendingStatusRead, __BasicStopSerialSending  
For the H8/300H, wait for at least a 1-bit period before calling this API after  
__BasicSetSerialFormat was called.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
Void func( void )  
{
..........  
__BasicStartSerialSending( RAPI_COM1, 0x00AA );  
..........  
}
Rev.1.01  
2007.02.16  
30  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicReceivingStatusRead  
Synopsis  
<Read receive status>  
unsigned int __BasicReceivingStatusRead(unsigned long data)  
data  
Setup data  
Description  
Returns the receive status of serial communication.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
The receive status of serial communication is returned. The returned value is one of  
the following.  
(M16C) (UART0, UART1, UART2)  
RAPI_RX_INCOMPLETE Reception not complete yet.  
Other than above  
Reception complete. The value read from the UARTi receive  
buffer register (i = 0 to 2).  
(M16C) (SI/O3, SI/O4)  
RAPI_RX_INCOMPLETE Reception not complete yet.  
Other than above Reception complete. Low-order 8 bits: The value read from the  
SI/Oi transmit/receive register (i = 3, 4).  
(R8C)  
RAPI_RX_INCOMPLETE Reception not complete yet.  
Other than above Reception complete. The value read from the UARTi receive  
buffer register (i = 0, 1).  
(H8/300H)  
RAPI_RX_INCOMPLETE Reception not complete yet.  
Other than above  
Reception complete.  
High-order 8 bits: The value read from the serial status register.  
Low-order 8 bits: The value read from the receive data register.  
(Not read if an error occurred.)  
Functionality  
Reference  
Serial I/O  
__BasicStartSerialReceiving, __BasicStopSerialReceiving  
Rev.1.01  
2007.02.16  
31  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Remark  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
unsigned int rcv_data;  
..........  
rcv_data = __BasicReceivingStatusRead( RAPI_COM1 );  
..........  
}
Rev.1.01  
2007.02.16  
32  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicSendingStatusRead  
Synopsis  
<Read transmit status>  
Boolean __BasicSendingStatusRead(unsigned long data)  
data  
Setup data  
Description  
Returns the transmit status of serial communication. For data, the following values can  
be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If no data exists in the transmit buffer, RAPI_TRUE is returned; if data exists,  
RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicStartSerialSending, __BasicStopSerialSending  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
..........  
if (__BasicSendingStatusRead( RAPI_COM1 ) == RAPI_TRUE) {  
/* Transmission completion */  
}
..........  
}
Rev.1.01  
2007.02.16  
33  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicStopSerialReceiving  
Synopsis  
<Stop reception>  
Boolean Rapi_BasicStopSerialReceiving(unsigned long data)  
data  
Setup data  
Description  
Stops receiving data in serial communication  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
UART0  
UART2  
RAPI_COM2  
UART1  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If data reception in serial communication was successfully stopped, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicStartSerialReceiving  
For the M16C SI/03 and SI/04, this API cannot be used.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
………………  
/* Stop receiving data in serial communication */  
__BasicStopSerialReceiving ( RAPI_COM1 );  
………………  
}
Rev.1.01  
2007.02.16  
34  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__BasicStopSerialSending  
Synopsis  
<Stop transmission>  
Boolean __BasicStopSerialSending(unsigned long data)  
data  
Setup data  
Description  
Stops transmitting data in serial communication.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
UART0  
UART2  
RAPI_COM2  
UART1  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
SIO3_COM3  
SCI3 channel 1  
SIO3 channel 3  
SCI3 channel 2  
Return value  
If data transmission in serial communication was successfully stopped, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicStartSerialSending  
For the M16C SI/03 and SI/04, this API cannot be used.  
The specifiable serial ports differ with each CPU used.  
When operating in clock synchronous serial communication mode, data reception is  
stopped at the same time by this API.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
………………  
/* Stop sending data in serial communication */  
__BasicStopSerialSending ( RAPI_COM1 );  
………………  
}
Rev.1.01  
2007.02.16  
35  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__OpenSerialDriver  
Synopsis  
<Open a serial port>  
Boolean __OpenSerialDriver(unsigned long data)  
data  
Setup data  
Description  
Opens and initializes a specified serial port.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
SIO3_COM3  
SCI3 channel 1  
SIO3 channel 3  
SCI3 channel 2  
Return value  
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__CloseSerialDriver  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
When used for the H8/300H, this API opens and initializes a specified serial port  
when freeing it from module standby state.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
………………  
/* Open serial driver */  
return __OpenSerialDriver( RAPI_COM1 );  
………………  
}
Rev.1.01  
2007.02.16  
36  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CloseSerialDriver  
Synopsis  
<Close a serial port>  
Boolean __CloseSerialDriver(unsigned long data)  
data  
Setup data  
Description  
Closes a specified serial port.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
SIO3_COM3  
SCI3 channel 1  
SIO3 channel 3  
SCI3 channel 2  
Return value  
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__OpenSerialDriver  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
When used for the H8/300H, this API places a specified serial port into module  
standby state after closing it.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
………………  
/* Close serial driver */  
return __CloseSerialDriver( RAPI_COM1 );  
………………  
}
Rev.1.01  
2007.02.16  
37  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__ConfigSerialDriverNotify  
Synopsis  
<Register a notification function>  
Boolean __ConfigSerialDriverNotify(unsigned long data, VoidFuncNotify *func)  
data  
func  
Setup data  
Function pointer to be registered  
Description  
Registers the notification function necessary to get various transmit/receive information  
of serial communication.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
[func]  
The function to be registered in func must be supplied to the serial I/O driver by the  
user.  
The serial I/O driver calls the function registered in func.  
The serial I/O driver notifies the user of the transmit/receive status by an argument.  
The type of the function to be registered is shown below.  
void “any function name” (unsigned char notify);  
The argument is detailed below.  
(M16C) (UART0, UART1, UART2)  
b7 b6 b5 b4 b3 b2 b1 b0  
0
0 X  
X
0 X  
X
X
0 No error  
1 Error occurred  
Overrun error  
Framing error  
Parity error  
0 No error  
1 Error occurred  
0 No error  
1 Error occurred  
0 Not completed  
1 Completed  
Transmission completed  
Reception completed  
0 Not completed  
1 Completed  
(M16C) (SI/O3,SI/O4)  
Rev.1.01  
2007.02.16  
38  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
b7 b6 b5 b4 b3 b2 b1 b0  
0 X X 0  
0
0
0
0
0 Not completed  
1 Completed  
Transmission completed  
Reception completed  
0 Not completed  
1 Completed  
(R8C)  
0
0 X  
X
0 X  
X
X
0 No error  
1 Error occurred  
Overrun error  
Framing error  
Parity error  
0 No error  
1 Error occurred  
0 No error  
1 Error occurred  
0 Not completed  
1 Completed  
Transmission completed  
Reception completed  
0 Not completed  
1 Completed  
(H8/300H)  
b7 b6 b5 b4 b3 b2 b1 b0  
0 X 0 X  
0
X
X
X
0 No error  
1 Error occurred  
Parity error  
0 No error  
1 Error occurred  
Framing error  
Overrun error  
0 No error  
1 Error occurred  
0 Not completed  
1 Completed  
Transmission completed  
Reception completed  
0 Not completed  
1 Completed  
Return value  
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__StartSerialReceiving, __StartSerialSending  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Rev.1.01  
2007.02.16  
39  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void Notify(unsigned char result) {  
if ((result&RAPI_OVER_ERR) == RAPI_OVER_ERR) {  
/* Overrun error */  
}
if ((result&RAPI_FRAMING_ERR) == RAPI_FRAMING_ERR) {  
/* Framing error */  
}
if ((result&RAPI_PARITY_ERR) == RAPI_PARITY_ERR) {  
/* Parity error */  
}
if ((result&RAPI_TX_END) == RAPI_TX_END) {  
/* Transmission completion */  
}
if ((result&RAPI_RX_END) == RAPI_RX_END) {  
/* Reception completion */  
}
}
Boolean func( void )  
{
………………  
/* Set callback functions of RAPI_COM1 to serial driver */  
return __ConfigSerialDriverNotify( RAPI_COM1, Notify );  
………………  
}
Rev.1.01  
2007.02.16  
40  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__SetSerialFormat  
Synopsis  
<Set serial communication>  
Boolean __SetSerialFormat(unsigned long data1, unsigned char data2)  
data1  
data2  
Setup data 1  
Setup data 2  
Description  
Sets serial communication according to specified parameters.  
For details about parameters, refer to the description of __BasicSetSerialFormat.  
Return value  
If serial communication was successfully set, RAPI_TRUE is returned; if settings failed,  
RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__BasicSetSerialFormat  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
Boolean func( void )  
{
………………  
/* Set the data of RAPI_COM1 to serial driver */  
return __SetSerialFormat(RAPI_COM1 | RAPI_SM_SYNC | RAPI_CKDIR_INT |  
RAPI_BCSS_F1|RAPI_DPOL_NON|RAPI_LSB_SEL,20);  
………………  
}
Rev.1.01  
2007.02.16  
41  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__SetSerialInterrupt  
Synopsis  
<Set serial interrupts>  
Boolean __SetSerialInterrupt(unsigned long data)  
data  
Setup data  
Description  
Sets serial interrupts according to specified parameters.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
For interrupt settings, the following values can set.  
(M16C) (UART0, UART1, UART2)  
RAPI_INT_TX_DIS  
RAPI_INT_TX_LV_1  
RAPI_INT_TX_LV_2  
RAPI_INT_TX_LV_3  
RAPI_INT_TX_LV_4  
RAPI_INT_TX_LV_5  
RAPI_INT_TX_LV_6  
RAPI_INT_TX_LV_7  
RAPI_INT_RX_DIS  
RAPI_INT_RX_LV_1  
RAPI_INT_RX_LV_2  
RAPI_INT_RX_LV_3  
RAPI_INT_RX_LV_4  
RAPI_INT_RX_LV_5  
RAPI_INT_RX_LV_6  
RAPI_INT_RX_LV_7  
(M16C) (SI/O3, SI/O4)  
RAPI_INT_SIO_DIS  
Transmit interrupt disabled  
Transmit interrupt priority level 1  
Transmit interrupt priority level 2  
Transmit interrupt priority level 3  
Transmit interrupt priority level 4  
Transmit interrupt priority level 5  
Transmit interrupt priority level 6  
Transmit interrupt priority level 7  
Receive interrupt disabled  
Receive interrupt priority level 1  
Receive interrupt priority level 2  
Receive interrupt priority level 3  
Receive interrupt priority level 4  
Receive interrupt priority level 5  
Receive interrupt priority level 6  
Receive interrupt priority level 7  
SI/O interrupt disabled  
RAPI_INT_SIO_LV_1 SI/O interrupt priority level 1  
RAPI_INT_SIO_LV_2 SI/O interrupt priority level 2  
RAPI_INT_SIO_LV_3 SI/O interrupt priority level 3  
RAPI_INT_SIO_LV_4 SI/O interrupt priority level 4  
RAPI_INT_SIO_LV_5 SI/O interrupt priority level 5  
RAPI_INT_SIO_LV_6 SI/O interrupt priority level 6  
RAPI_INT_SIO_LV_7 SI/O interrupt priority level 7  
(R8C)  
Rev.1.01  
2007.02.16  
42  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_COM1  
UART0  
RAPI_COM2  
UART1  
For interrupt settings, the following values can set.  
RAPI_INT_TX_DIS  
RAPI_INT_TX_LV_1  
RAPI_INT_TX_LV_2  
RAPI_INT_TX_LV_3  
RAPI_INT_TX_LV_4  
RAPI_INT_TX_LV_5  
RAPI_INT_TX_LV_6  
RAPI_INT_TX_LV_7  
RAPI_INT_RX_DIS  
RAPI_INT_RX_LV_1  
RAPI_INT_RX_LV_2  
RAPI_INT_RX_LV_3  
RAPI_INT_RX_LV_4  
RAPI_INT_RX_LV_5  
RAPI_INT_RX_LV_6  
RAPI_INT_RX_LV_7  
Transmit interrupt disabled  
Transmit interrupt priority level 1  
Transmit interrupt priority level 2  
Transmit interrupt priority level 3  
Transmit interrupt priority level 4  
Transmit interrupt priority level 5  
Transmit interrupt priority level 6  
Transmit interrupt priority level 7  
Receive interrupt disabled  
Receive interrupt priority level 1  
Receive interrupt priority level 2  
Receive interrupt priority level 3  
Receive interrupt priority level 4  
Receive interrupt priority level 5  
Receive interrupt priority level 6  
Receive interrupt priority level 7  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
RAPI_COM2  
SCI3 channel 2  
For interrupt settings, the following values can set.  
RAPI_INT_TX_DIS  
Transmit interrupt disabled  
RAPI_INT_TX_ENA  
RAPI_INT_RX_ENA  
Transmit interrupt enabled  
Receive interrupt enabled  
RAPI_INT_RX_DIS Receive interrupt disabled  
For the CPUs that have an interrupt control register, following values can be set to  
specify interrupt priority, in addition to ordinary interrupt settings.  
RAPI_INT_LV_0  
Transmit/Receive interrupt priority level0  
RAPI_INT_LV_1  
Transmit/Receive interrupt priority level1  
Return value  
If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Remark  
Serial I/O  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
Rev.1.01  
2007.02.16  
43  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Boolean func( void )  
{
………………  
/* Set interrupt of RAPI_COM1 to serial driver */  
return  
__SetSerialInterrupt(  
RAPI_COM1  
|
RAPI_INT_TX_LV_1  
|
RAPI_INT_RX_LV_2 );  
………………  
}
Rev.1.01  
2007.02.16  
44  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__StartSerialReceiving  
Synopsis  
<Start reception>  
Boolean __StartSerialReceiving(unsigned long data, unsigned char wordNum,  
unsigned int *RcvDtBuf)  
data  
Setup data  
wordNum  
RcvDtBuf  
Number of words received  
Pointer to the buffer in which received data is stored  
Description  
Starts reception of serial communication and gets received data by a specified number  
of words. When acquisition of received data is complete, this API calls a notification  
function (if a notification function is registered).  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If reception of serial communication was successfully started, RAPI_TRUE is returned;  
if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__ConfigSerialDriverNotify, __StopSerialReceiving  
For the H8/300H, wait for at least a 1-bit period before calling this API after  
__SetSerialFormat was called.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
For the H8/300H, the following values are stored in the receive buffer.  
High-order 8 bits: The value read from the serial status register.  
Low-order 8 bits: The value read from the receive data register.  
(Not read if an error occurred.)  
Program example  
#include ”rapi_sif_r8c_13.h”  
Rev.1.01  
2007.02.16  
45  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
unsigned int buffer[10];  
void func( void )  
{
………………  
/* Get 5 word data received in serial communication */  
__StartSerialReceiving( RAPI_COM1, 5, buffer );  
………………  
}
Rev.1.01  
2007.02.16  
46  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__StartSerialSending  
Synopsis  
<Start transmission>  
Boolean __StartSerialSending(unsigned long data, unsigned char wordNum,  
unsigned int *SndDtBuf)  
data  
Setup data  
wordNum  
SndDtBuf  
Number of words transmitted  
Pointer to the transmit data  
Description  
Starts transmission of serial communication and writes transmit data to the transmit  
buffer by a specified number of words. When transmission of all transmit data is  
complete, this API calls a notification function (if a notification function is registered).  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
(H8/300H)  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If transmission of serial communication was successfully started, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__ConfigSerialDriverNotify, __StopSerialSending  
For the H8/300H, wait for at least a 1-bit period before calling this API after  
__SetSerialFormat was called.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
Rev.1.01  
2007.02.16  
47  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
unsigned int buffer[10];  
void func( void )  
{
………………  
/* Set 5 word data to transmit buffer of serial communication */  
__StartSerialSending( RAPI_COM1, 5, buffer );  
………………  
}
Rev.1.01  
2007.02.16  
48  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__StopSerialReceiving  
Synopsis  
<Stop reception>  
Boolean __StopSerialReceiving(unsigned long data)  
data  
Setup data  
Description  
Stops reception of serial communication.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
UART0  
UART2  
RAPI_COM2  
UART1  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If reception of serial communication was successfully stopped, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__StartSerialSending  
For the M16C SI/03 and SI/04, this API cannot be used.  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
………………  
/* Stop receiving data in serial communication */  
__StopSerialReceiving ( RAPI_COM1 );  
………………  
}
Rev.1.01  
2007.02.16  
49  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__StopSerialSending  
Synopsis  
<Stop transmission>  
Boolean __StopSerialSending(unsigned long data)  
data  
Setup data  
Description  
Stops transmission of serial communication.  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
UART0  
UART2  
RAPI_COM2  
UART1  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
If transmission of serial communication was successfully stopped, RAPI_TRUE is  
returned; if failed, RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__StartSerialReceiving  
For the M16C SI/03 and SI/04, this API cannot be used.  
The specifiable serial ports differ with each CPU used.  
When operating in clock synchronous serial communication mode, data reception is  
stopped at the same time by this API.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
void func( void )  
{
………………  
/* Stop sending data in serial communication */  
__StopSerialSending ( RAPI_COM1 );  
………………  
}
Rev.1.01  
2007.02.16  
50  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__PollingSerialReceiving  
Synopsis  
<Polling reception>  
unsigned int __PollingSerialReceiving(unsigned long data)  
data  
Setup data  
Description  
Performs reception of serial communication by polling. This API gets received data by  
an amount specified by __StartSerialReceiving. When acquisition of received data is  
complete, it calls a notification function (if a notification function is registered).  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
Functionality  
Reference  
Remark  
Out of the receive data counts requested, the number of unreceived data is returned.  
Serial I/O  
__ConfigSerialDriverNotify, __SetSerialInterrupt, __StartSerialReceiving  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
unsigned int buffer[10], count;  
void func( void )  
{
………………  
/* Reception interrupt disable */  
__SetSerialInterrupt( RAPI_COM1 | RAPI_INT_TX_DIS | RAPI_INT_RX_DIS );  
/* Start reception */  
__StartSerialReceiving( RAPI_COM1, 5, buffer );  
do{  
count = __PollingSerialReceiving( RAPI_COM1 );  
}while(count)  
………………  
}
Rev.1.01  
2007.02.16  
51  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__PollingSerialSending  
Synopsis  
<Polling transmission>  
Unsigned __PollingSerialSending(unsigned long data)  
data  
Setup data  
Description  
Performs transmission of serial communication by polling. This API sends transmit data  
by an amount specified by __StartSerialSending from the transmit data buffer specified  
by __StartSerialSending. When transmission of all transmit data is complete, it calls a  
notification function (if a notification function is registered).  
[data]  
For data, the following values can be set.  
(M16C)  
RAPI_COM1  
RAPI_COM3  
RAPI_COM5  
UART0  
UART2  
SI/O4  
RAPI_COM2  
RAPI_COM4  
UART1  
SI/O3  
(R8C)  
RAPI_COM1  
UART0  
RAPI_COM2  
RAPI_COM2  
UART1  
(H8/300H)  
RAPI_COM1  
RAPI_COM3  
SCI3 channel 1  
SCI3 channel 3  
SCI3 channel 2  
Return value  
Out of the transmit data counts requested, the number of untransmitted data is  
returned.  
Functionality  
Reference  
Remark  
Serial I/O  
__ConfigSerialDriverNotify, __SetSerialInterrupt, __StartSerialReceiving  
The specifiable serial ports differ with each CPU used.  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Program example  
#include ”rapi_sif_r8c_13.h”  
Rev.1.01  
2007.02.16  
52  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
unsigned int buffer[10],count;  
void func( void )  
{
………………  
/* Transmission interrupt disable */  
__SetSerialInterrupt( RAPI_COM1 | RAPI_INT_TX_DIS | RAPI_INT_RX_DIS );  
/* Start transmission */  
__StartSerialSending( RAPI_COM1, 5, buffer );  
do{  
count = __PollingSerialSending( RAPI_COM1 );  
}while(count)  
………………  
}
Rev.1.01  
2007.02.16  
53  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4.2.2 Timer  
__CreateTimer  
Synopsis  
<Set timer mode>  
Boolean __CreateTimer(unsigned long data1, unsigned int data2, unsigned int  
data3, unsigned int data4, void* func)  
data1  
data2  
data3  
data4  
func  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets a specified timer to timer mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_F1  
Uses timer A channel 0.  
Uses timer A channel 1.  
Uses timer A channel 2.  
Uses timer A channel 3.  
Uses timer A channel 4.  
Uses timer B channel 0.  
Uses timer B channel 1.  
Uses timer B channel 2.  
Selects f1 for the count source.  
Selects f2 for the count source.  
Selects f8 for the count source.  
Selects f32 for the count source.  
Selects fc32 for the count source.  
Sets the timer to start operating in __CreateTimer.  
Sets the timer to stop operating in __CreateTimer.  
Selects a gate facility that counts a period during which input at  
TAiIN pin remains low.  
RAPI_F2  
RAPI_F8  
RAPI_F32  
RAPI_FC32  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_GATE_L  
RAPI_GATE_H  
Selects a gate facility that counts a period during which input at  
TAiIN pin remains high.  
RAPI_PULSE_ON  
RAPI_PULSE_OFF  
Selects that pulses are output from TAiIN pin.  
Selects that no pulses are output from TAiIN pin.  
• Specifiable definition values when timer A is used (RAPI_TIMER_A0 to  
RAPI_TIMER_A4 specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32,  
RAPI_FC32 }. The default value is RAPI_F2.  
Rev.1.01  
2007.02.16  
54  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Operating states set)  
(Pulse output state)  
(Gate facility)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
Specify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The  
default value is RAPI_PULSE_OFF.  
Specify one from { RAPI_GATE_L, RAPI_GATE_H }. If omitted,  
“No gate facility” is set.  
Specifiable definition values when timer B is used (RAPI_TIMER_B0 to  
RAPI_TIMER_B2 specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32,  
RAPI_FC32 }. The default value is RAPI_F2.  
(Operating states set)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
RAPI_F1  
Uses timer X.  
Uses timer Y.  
Uses timer Z.  
Uses timer RA.  
Uses timer RB.  
Selects f1 for the count source.  
Selects f2 for the count source.  
Selects f8 for the count source.  
Selects f32 for the count source.  
Selects fRING for the count source.  
Selects foco for the count source.  
Selects fC32 for the count source.  
Selects the underflow of timer Y for the count source.  
RAPI_F2  
RAPI_F8  
RAPI_F32  
RAPI_FRING  
RAPI_FOCO  
RAPI_FC32  
RAPI_TIMER_Y_  
UNDERFLOW  
RAPI_TIMER_RA_UN  
DERFLOW  
Selects the underflow of timer RA for the count source.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_WRITE_  
RELOAD_ONLY  
Sets the timer to start operating in __CreateTimer.  
Sets the timer to stop operating in __CreateTimer.  
Selects operation mode in which writing to the primary register and  
prescaler causes the set data to be written to only the reload  
register.  
RAPI_WRITE_  
Selects operation mode in which writing to the primary register and  
prescaler causes the set data to be written to both the reload  
register and the counter, respectively.  
RELOAD_BOTH  
Specifiable definition values when timer X is used (RAPI_TIMER_X specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32 }. The  
default value is RAPI_F1.  
(Operating states set)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
Specifiable definition values when timer Y is used (RAPI_TIMER_Y specified)  
Rev.1.01  
2007.02.16  
55  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Count source)  
Specify one from { RAPI_F1, RAPI_F8, RAPI_FRING }. The default  
value is RAPI_F1.  
(Operating states set)  
(Write control)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
Specify one from { RAPI_WRITE_RELOAD_ONLY,  
RAPI_WRITE_RELOAD_BOTH }. The default value is  
RAPI_WRITE_RELOAD_BOTH.  
Specifiable definition values when timer Z is used (RAPI_TIMER_Z specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8,  
RAPI_TIMER_Y_UNDERFLOW}. The default value is RAPI_F1.  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Operating states set)  
(Write control)  
Specify one from {RAPI_WRITE_RELOAD_ONLY,  
RAPI_WRITE_RELOAD_BOTH}. The default value is  
RAPI_WRITE_RELOAD_BOTH.  
Specifiable definition values when timer RA is used (RAPI_TIMER_RA specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_FOCO,  
RAPI_FC32}. The default value is RAPI_F1.  
(Operating states set)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
Specifiable definition values when timer RB is used (RAPI_TIMER_RB specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8,  
RAPI_TIMER_RA_UNDERFLOW}. The default value is RAPI_F1.  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Operating states set)  
(Write control)  
Specify one from {RAPI_WRITE_RELOAD_ONLY,  
RAPI_WRITE_RELOAD_BOTH}. The default value is  
RAPI_WRITE_RELOAD_BOTH.  
(H8/300H)  
RAPI_TIMER_A  
RAPI_TIMER_B1  
RAPI_TIMER_V  
RAPI_TA_F8  
Uses timer A.  
Uses timer B1.  
Uses timer V  
Supplies φ/8 clock to timer A.  
Supplies φ/32 clock to timer A.  
Supplies φ/128 clock to timer A.  
Supplies φ/256 clock to timer A.  
Supplies φ/512 clock to timer A.  
Supplies φ/2048 clock to timer A.  
Supplies φ/4096 clock to timer A.  
Supplies φ/8192 clock to timer A.  
Timer B1 counts with internal clock φ/4.  
Timer B1 counts with internal clock φ/16.  
Timer B1 counts with internal clock φ/64.  
RAPI_TA_F32  
RAPI_TA_F128  
RAPI_TA_F256  
RAPI_TA_F512  
RAPI_TA_F2048  
RAPI_TA_F4096  
RAPI_TA_F8192  
RAPI_TB1_F4  
RAPI_TB1_F16  
RAPI_TB1_F64  
Rev.1.01  
2007.02.16  
56  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TB1_F256  
RAPI_TB1_F512  
RAPI_TB1_F2048  
RAPI_TB1_F8192  
RAPI_TV_F4  
Timer B1 counts with internal clock φ/256.  
Timer B1 counts with internal clock φ/512.  
Timer B1 counts with internal clock φ/2048.  
Timer B1 counts with internal clock φ/8192.  
Timer V counts on falling edges of internal clock φ/4.  
Timer V counts on falling edges of internal clock φ/8.  
Timer V counts on falling edges of internal clock φ/16.  
Timer V counts on falling edges of internal clock φ/32.  
Timer V counts on falling edges of internal clock φ/64.  
Timer V counts on falling edges of internal clock φ/128.  
Sets the timer to start operating in __CreateTimer.  
Sets the timer to stop operating in __CreateTimer.  
Enables overflow interrupt.  
RAPI_TV_F8  
RAPI_TV_F16  
RAPI_TV_F32  
RAPI_TV_F64  
RAPI_TV_F128  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_OVERFLOW  
RAPI_OUT_F4  
RAPI_OUT_F8  
RAPI_OUT_F16  
RAPI_OUT_F32  
RAPI_OUT_8192  
RAPI_OUT_4096  
RAPI_OUT_2048  
RAPI_OUT_1024  
Outputs φ/4 clock.  
Outputs φ/8 clock.  
Outputs φ/16 clock.  
Outputs φ/32 clock.  
Outputs φW/4 clock.  
Outputs φW/8 clock.  
Outputs φW/16 clock.  
Outputs φW/32 clock.  
RAPI_AUTO_RELOAD Uses auto reload facility.  
• Specifiable definition values when timer A is used (RAPI_TIMER_A specified)  
(Clock)  
Specify one from { RAPI_TA_F8, RAPI_TA_F32, RAPI_TA_F128,  
RAPI_TA_F256, RAPI_TA_F512, RAPI_TA_F2048, RAPI_TA_F4096,  
RAPI_TA_F8192 }. The default value is RAPI_TA_F8192.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_OUT_F4, RAPI_OUT_F8, RAPI_OUT_F16,  
RAPI_OUT_F32, RAPI_OUT_8192, RAPI_OUT_4096,  
RAPI_OUT_2048, RAPI_OUT_1024 }. If this specification is omitted,  
“Clock output” is set.  
(Interrupt)  
(Output)  
• Specifiable definition values when timer B1 is used (RAPI_TIMER_B1 specified)  
(Clock)  
Specify one from { RAPI_TB1_F4, RAPI_TB1_F16, RAPI_TB1_F64,  
RAPI_TB1_F256, RAPI_TB1_F512, RAPI_TB1_F2048,  
RAPI_TB1_F8192 }. The default value is RAPI_TB1_F8192.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
(Interrupt)  
(Reload)  
To select the auto reload facility, specify RAPI_AUTO_RELOAD. If  
RAPI_AUTO_RELOAD is not specified, “Select interval facility” is set.  
• Specifiable definition values when timer V is used (RAPI_TIMER_V specified)  
(Clock) Specify one from RAPI_TV_F4, RAPI_TV_F8, RAPI_TV_F16,  
{
RAPI_TV_F32, RAPI_TV_F64, RAPI_TV_F128}. If this specification is  
omitted, “Disable clock input” is set.  
Rev.1.01  
2007.02.16  
57  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Operating  
states set)  
[data2]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register.  
For the CPUs that do not have an interrupt control register, specify 0.  
[data3]  
(M16C)  
Specify the value to be set in the timer register in 16 bits.  
(R8C)  
When using timer X, specify the set value for the timer register; when using timer Y  
or timer Z, specify the set value for the primary register in 8 bits.  
(H8/300H)  
Specify the set value for the timer reload register in 8 bits. This setting is effective  
only when timer B1 is used. If any timer other than B1 is used, specify 0.  
[data4]  
(M16C) (H8/300H)  
Specify 0.  
(R8C)  
Specify the set value for the prescaler register in 8 bits.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (timer mode)  
__EnableTimer, __DestroyTimer  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API specify when freeing it from module stanby.  
Program example  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc( void ){}  
Rev.1.01  
2007.02.16  
58  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Set up timer X as timer mode */  
__CreateTimer( RAPI_TIMER_X|RAPI_TIMER_ON|RAPI_F8, 5, 0x80, 0x80,  
TimerIntFunc );  
}
Rev.1.01  
2007.02.16  
59  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableTimer  
Synopsis  
<Control operation of timer mode>  
Boolean __EnableTimer(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified timer mode by starting or  
stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_ON  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Sets the timer that is set to timer mode to start operating.  
RAPI_TIMER_OFF Sets the timer that is set to timer mode to stop operating.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
RAPI_TIMER_ON  
Selects timer Y.  
Selects timer Z.  
Selects timer RA.  
Selects timer RB.  
Sets the timer that is set to timer mode to start operating.  
RAPI_TIMER_OFF Sets the timer that is set to timer mode to stop operating.  
(H8/300H)  
RAPI_TIMER_V  
Selects timer V.  
RAPI_TIMER_ON  
Sets the timer that is set to timer mode to start operating.  
RAPI_TIMER_OFF Sets the timer that is set to timer mode to stop operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Timer (timer mode)  
__CreateTimer, __DestroyTimer  
Rev.1.01  
2007.02.16  
60  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Remark  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Disable timer Y as timer mode */  
__EnableTimer( RAPI_TIMER_Y| RAPI_TIMER_OFF );  
}
Rev.1.01  
2007.02.16  
61  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyTimer  
Synopsis  
<Discard settings of timer mode>  
Boolean __DestroyTimer(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified timer mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
Selects timer X.  
Selects timer Y.  
Selects timer Z.  
Selects timer RA.  
Selects timer RB.  
(H8/300H)  
RAPI_TIMER_A  
RAPI_TIMER_B1  
RAPI_TIMER_V  
Selects timer A.  
Selects timer B1.  
Selects timer V.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (timer mode)  
__CreateTimer, __EnableTimer  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_timer_r8c_13.h"  
Rev.1.01  
2007.02.16  
62  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Destroy the setting of timer Z as timer mode */  
__DestroyTimer( RAPI_TIMER_Z );  
}
Rev.1.01  
2007.02.16  
63  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreateEventCounter  
Synopsis  
<Set event counter mode>  
Boolean __CreateEventCounter(unsigned long data1, unsigned int data2,  
unsigned int data3, unsigned int data4, void* func)  
data1  
data2  
data3  
data4  
func  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets a specified timer to event counter mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_EV_EXTERNAL  
Uses timer A channel 0.  
Uses timer A channel 1.  
Uses timer A channel 2  
Uses timer A channel 3.  
Uses timer A channel 4.  
Uses timer B channel 0.  
Uses timer B channel 1.  
Uses timer B channel 2.  
Selects the external signal input to TAiIN pin (when using timer Ai)  
or TBiIN pin (when using timer Bi) for the count source.  
Selects overflow or underflow of timer Aj (j = i 1, however j = 4 if i =  
0) for the count source.  
RAPI_EV_TIMER_AJ  
RAPI_EV_TIMER_AK  
Selects overflow or underflow of timer Ak (k = i 1, however k = 0 if i  
= 4) for the count source.  
RAPI_EV_TIMER_B2  
RAPI_EV_TIMER_BJ  
Selects overflow or underflow of timer B2 for the count source.  
Selects overflow or underflow of timer Bj (j = i – 1, however j = 2 if i  
= 0) for the count source.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_PULSE_ON  
RAPI_PULSE_OFF  
RAPI_AUTO_RELOAD  
RAPI_FREE_RUN  
RAPI_UP_COUNT  
RAPI_DOWN_COUNT  
Sets the timer to start operating in __CreateEventCounter.  
Sets the timer to stop operating in __CreateEventCounter.  
Selects that pulses are output from TAiIN pin.  
Selects that no pulses are output from TAiIN pin.  
Selects reload type for the count type.  
Selects free-run type for the count type.  
Selects up-count for the count operation.  
Selects down-count for the count operation.  
Rev.1.01  
2007.02.16  
64  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_UDF_REGISTER Selects the UDF register for the cause of up/down switching.  
RAPI_TAIOUT  
Selects the input signal at TAiOUT pin for the cause of up/down  
switching.  
RAPI_RISING  
RAPI_FALLING  
RAPI_BOTH  
Selects the rising edge of count source as active edge.  
Selects the falling edge of count source as active edge.  
Selects both rising and falling edges of count source as active  
edges.  
• Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4  
specified)  
(Count source)  
Specify one from  
{
RAPI_EV_EXTERNAL, RAPI_EV_TIMER_AJ,  
RAPI_EV_TIMER_AK, RAPI_EV_TIMER_B2 }. The default value is  
RAPI_EV_EXTERNAL.  
(Operating  
states set)  
(Pulse output  
facility)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The default  
value is RAPI_PULSE_OFF.  
(Gate facility)  
Specify one from { RAPI_GATE_L, RAPI_GATE_H }. If omitted, “No gate  
facility” is set.  
(Count type)  
Specify one from { RAPI_AUTO_RELOAD, RAPI_FREE_RUN }. The  
default value is RAPI_AUTO_RELOAD.  
(Count  
Specify one from { RAPI_UP_COUNT, RAPI_DOWN_COUNT }. The  
default value is RAPI_DOWN_COUNT. The count direction can only be set  
when the UDF register is used.  
direction)  
(Count direction Specify one from { RAPI_UDF_REGISTER, RAPI_TAIOUT }. The default  
switching)  
value is RAPI_UDF_REGISTER.  
(Count edge)  
Specify one from { RAPI_RISING, RAPI_FALLING }. The default value is  
RAPI_FALLING.  
• Specifiable definition values when timer B is used (RAPI_TIMER_B0 to RAPI_TIMER_B2  
specified)  
(Count source)  
Specify one from { RAPI_EV_EXTERNAL, RAPI_EV_TIMER_BJ }. The  
default value is RAPI_EV_EXTERNAL.  
(Operating  
states set)  
(Count edge)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_RISING, RAPI_FALLING, RAPI_BOTH }. The  
default value is RAPI_FALLING.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_RA  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_WRITE_  
Uses timer X.  
Uses timer Y.  
Uses timer RA.  
Sets the timer to start operating in __CreateEventCounter.  
Sets the timer to stop operating in __CreateEventCounter.  
Selects operation mode in which writing to the primary register and  
prescaler causes the set data to be written to only the reload  
register.  
RELOAD_ ONLY  
Rev.1.01  
2007.02.16  
65  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_WRITE_  
Selects operation mode in which writing to the primary register and  
prescaler causes the set data to be written to both the reload  
register and the counter, respectively.  
RELOAD_ BOTH  
RAPI_RISING  
Selects the rising edge of count source as active edge.  
Selects the falling edge of count source as active edge.  
Use sampling frequency f1 for digital filter function  
Use sampling frequency f8 for digital filter function  
Use sampling frequency f32 for digital filter function  
Sets count source input pin to P1_7.  
RAPI_FALLING  
RAPI_FILTER_F1  
RAPI_FILTER_F8  
RAPI_FILTER_F32  
RAPI_TIOSEL_P1_7  
RAPI_TIOSEL_P1_5  
RAPI_PULSE_ON  
RAPI_PULSE_OFF  
Sets count source input pin to P1_5.  
Selects that pulses are output from TRA0 pin.  
Selects that no pulses are output from TRA0 pin.  
• Specifiable definition values when timer X is used (RAPI_TIMER_X specified)  
(Operating  
states set)  
(Count edge)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_RISING, RAPI_FALLING }. The default value is  
RAPI_FALLING.  
• Specifiable definition values when timer Y is used (RAPI_TIMER_Y specified)  
(Operating  
states set)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Write control)  
Specify one from { RAPI_WRITE_RELOAD_ONLY,  
RAPI_WRITE_RELOAD_BOTH }.  
The default value is RAPI_WRITE_RELOAD_BOTH.  
Specify one from { RAPI_RISING, RAPI_FALLING }. The default value is  
RAPI_FALLING.  
(INT2/CNTR1  
input)  
• Specifiable definition values when timer RA is used (RAPI_TIMER_RA specified)  
(Operating  
states set)  
(Count edge)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_RISING, RAPI_FALLING }. The default value is  
RAPI_FALLING.  
(Filter)  
Specify one from { RAPI_FILTER_F1, RAPI_FILTER_F8,  
RAPI_FILTER_F32}. The default value is no filter.  
Specify one from { RAPI_TIOSEL_P1_7, RAPI_TIOSEL_P1_5 }. The  
default value is RAPI_TIOSEL_P1_7.  
(Input pin)  
(Pulse  
output Specify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The default  
value is RAPI_PULSE_OFF.  
function)  
(H8/300H)  
RAPI_TIMER_B1  
RAPI_TIMER_V  
Uses timer B1.  
Uses timer V.  
RAPI_TIMER_ON  
Sets the timer to start operating in __CreateEventCounter.  
Sets the timer to stop operating in __CreateEventCounter.  
Enables overflow interrupt.  
RAPI_TIMER_OFF  
RAPI_OVERFLOW  
RAPI_AUTO_RELOAD  
Uses auto reload facility.  
Rev.1.01  
2007.02.16  
66  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_RISING  
RAPI_FALLING  
RAPI_BOTH  
Selects the rising edge of count source as active edge.  
Selects the falling edge of count source as active edge.  
Selects both rising and falling edges of count source as active  
edges.  
RAPI_TRGV_RISING  
Selects the rising edge of TRGV pin input signal as active edge.  
RAPI_ TRGV_FALLING Selects the falling edge of TRGV pin input signal as active edge.  
RAPI_ TRGV_BOTH  
Selects both rising and falling edges of TRGV pin input signal as  
active edges.  
RAPI_TRGV_PROHIBI  
TED  
Selects that trigger input from TRGV pin is disabled.  
• Specifiable definition values when timer B1 is used (RAPI_TIMER_B1 specified)  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
RAPI_OVERFLOW is not specified, “No overflow interrupt request” is set.  
To select the auto reload facility, specify RAPI_AUTO_RELOAD. If no  
interrupts are specified, “No interrupt request” is set.  
(Reload)  
(Count edge)  
Specify one from { RAPI_RISING, RAPI_FALLING }. The default value is  
RAPI_FALLING.  
• Specifiable definition values when timer V is used (RAPI_TIMER_V specified)  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If no  
interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Operating  
states set)  
(Count edge)  
Specify one from { RAPI_RISING, RAPI_FALLING, RAPI_BOTH }. The  
default value is RAPI_FALLING.  
(TRGV  
input)  
pin Specify one from { RAPI_TRGV_RISING, RAPI_ TRGV_FALLING, RAPI_  
TRGV_BOTH, RAPI_TRGV_PROHIBIT }. The default value is RAPI_T  
RGV_PROHIBIT.  
[data2]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register. For  
the CPUs that do not have an interrupt control register, specify 0.  
[data3]  
(M16C)  
Specify the value to be set in the timer register in 16 bits.  
(R8C)  
When using timer X, specify the set value for the timer register; when using timer Y,  
specify the set value for the primary register in 8 bits.  
(H8/300H)  
Specify the set value for the timer reload register in 8 bits. This setting is effective  
only when timer B1 is used. If any timer other than B1 is used, specify 0.  
Rev.1.01  
2007.02.16  
67  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[data4]  
(M16C) (H8/300H)  
Specify 0.  
(R8C)  
Specify the set value for the prescaler register in 8 bits.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (event counter mode)  
__EnableEventCounter, __DestroyEventCounter, __GetEventCounter  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API specify when freeing it from module stanby  
state.  
Program example  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc( void ){}  
void func( void )  
{
/* Set up timer Y as event counter mode */  
__CreateEventCounter( RAPI_TIMER_Y|RAPI_TIMER_ON|RAPI_FALLING, 5,  
0x80, 0x80, TimerIntFunc );  
}
Rev.1.01  
2007.02.16  
68  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableEventCounter  
Synopsis  
<Control operation of event counter mode>  
Boolean __EnableEventCounter(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified timer mode by starting or  
stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_ON  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Sets the timer that is set to event counter mode to start  
operating.  
RAPI_TIMER_OFF  
Sets the timer that is set to event counter mode to stop  
operating.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_RA  
RAPI_TIMER_ON  
Selects timer X.  
Selects timer Y.  
Selects timer RA.  
Sets the timer that is set to event counter mode to start  
operating.  
RAPI_TIMER_OFF  
Sets the timer that is set to event counter mode to stop  
operating.  
(H8/300H)  
RAPI_TIMER_V  
Selects timer V.  
RAPI_TIMER_ON  
Sets the timer that is set to event counter mode to start  
operating.  
RAPI_TIMER_OFF  
Sets the timer that is set to event counter mode to stop  
operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Rev.1.01  
2007.02.16  
69  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Functionality  
Reference  
Remark  
Timer (event counter mode)  
__CreateEventCounter, __DestroyEventCounter, __GetEventCounter  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c.h"  
void func( void )  
{
/* Disable timer Y as event counter mode */  
__EnableEventCounter( RAPI_TIMER_Y|RAPI_TIMER_OFF );  
}
Rev.1.01  
2007.02.16  
70  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyEventCounter  
Synopsis  
<Discard settings of event counter mode>  
Boolean __DestroyEventCounter(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified timer mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_RA  
Selects timer X.  
Selects timer Y.  
Selects timer RA.  
(H8/300H)  
RAPI_TIMER_B1  
RAPI_TIMER_V  
Selects timer B1.  
Selects timer V.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (event counter mode)  
__CreateEventCounter, __EnableEventCounter, __GetEventCounter  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_timer_r8c.h"  
Rev.1.01  
2007.02.16  
71  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Destroy the setting of timer Y as event counter mode */  
__DestroyEventCounter( RAPI_TIMER_Y );  
}
Rev.1.01  
2007.02.16  
72  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetEventCounter  
Synopsis  
<Get event counter mode counter value>  
Boolean __GetEventCounter(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the buffer in which counter value is stored  
Description  
Gets the counter value of the timer that is set to specified event counter mode.  
[data1]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_RA  
Selects timer X.  
Selects timer Y.  
Selects timer RA.  
(H8/300H)  
RAPI_TIMER_B1  
RAPI_TIMER_V  
Selects timer B1.  
Selects timer V.  
[data2]  
Specify a pointer to the array in which the acquired counter value is stored.  
(M16C)  
• When using timer A (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified)  
[0]: The value of timer Ai register (i = 0–4) is stored.  
• When using timer B (RAPI_TIMER_B0 to RAPI_TIMER_B2 specified)  
[0]: The value of timer Bi register (i = 0–2) is stored.  
(R8C)  
• When using timer X (RAPI_TIMER_X specified)  
[0]: The value of prescaler X register is stored.  
[1]: The value of timer X register is stored.  
• When using timer Y (RAPI_TIMER_Y specified)  
[0]: The value of prescaler Y is stored.  
[1]: The value of timer Y primary register is stored.  
• When using timer RA (RAPI_TIMER_RA specified)  
[0]: The value of timer RA prescaler register is stored.  
Rev.1.01  
2007.02.16  
73  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[1]: The value of timer RA register is stored.  
(H8/300H)  
• When using timer B1 (RAPI_TIMER_B1 specified)  
[0]: The value of timer counter B1 is stored.  
• When using timer V (RAPI_TIMER_V specified)  
[0]: The value of timer counter V is stored.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (event counter mode)  
__CreateEventCounter, __EnableEventCounter, __DestroyEventCounter  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
unsigned int data[2];  
/* Get the counter of timer Y as event counter mode */  
__GetEventCounter(RAPI_TIMER_Y, data );  
}
Rev.1.01  
2007.02.16  
74  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreatePulseWidthModulationMode  
Synopsis  
<Set pulse width modulation mode>  
Boolean __CreatePulseWidthModulationMode(unsigned long data1, unsigned int  
data2, unsigned int* data3, void* data4)  
data1  
data2  
data3  
func  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets a specified timer to pulse width modulation mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_F1  
Uses timer A channel 0.  
Uses timer A channel 1.  
Uses timer A channel 2.  
Uses timer A channel 3.  
Uses timer A channel 4.  
Selects f1 for the count source.  
Selects f2 for the count source.  
Selects f8 for the count source.  
Selects f32 for the count source.  
Selects fC32 for the count source.  
Sets the timer to start operating in __CreatePulseWidthModulationMode.  
RAPI_F2  
RAPI_F8  
RAPI_F32  
RAPI_FC32  
RAPI_TIMER_ON  
RAPI_TIMER_OFF Sets the timer to stop operating in __CreatePulseWidthModulationMode.  
RAPI_TG_TAIIN  
RAPI_EV_  
Selects external trigger input from TAiIN pin for the count start condition.  
Selects overflow or underflow of timer Aj (j = i – 1, however j = 4 if i = 0)  
as the trigger for the timer to start counting.  
TIMER_AJ  
RAPI_EV_TIMER_ Selects overflow or underflow of timer Ak (k = i + 1, however k = 0 if i =  
AK 4) as the trigger for the timer to start counting.  
RAPI_EV_TIMER_ Selects overflow or underflow of timer B2 as the trigger for the timer to  
B2  
start counting.  
RAPI_TG_TAIS  
Only writing 1 to the TAiS bit of the TABSR register causes the timer to  
start counting.  
RAPI_PULSE_ON  
Selects that pulses are output from TAiIN pin. Selectable only when timer  
Ai is used.  
RAPI_PULSE_OFF Selects that no pulses are output from TAiIN pin. Selectable only when  
timer Ai is used.  
RAPI_PWM_16  
RAPI_PWM_8  
Selects operation as a 16-bit pulse width modulator.  
Selects operation as an 8-bit pulse width modulator.  
Rev.1.01  
2007.02.16  
75  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_RISING  
Selects the rising edge of TAiIN pin input signal as active edge.  
Selects the falling edge of TAiIN pin input signal as active edge.  
RAPI_FALLING  
• Specifiable definition values when timer A is used (RAPI_TIMER_A0 to  
RAPI_TIMER_A4 specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F32, RAPI_FC32 }.  
The default value is RAPI_F2.  
(Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Count start condition) Specify one from { RAPI_TG_TAIS, RAPI_TG_TAIIN,  
RAPI_EV_TIMER_AJ, RAPI_EV_TIMER_AK,  
RAPI_EV_TIMER_B2 }. The default value is RAPI_TG_TAIIN.  
(Pulse output facility) Specify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The  
default value is RAPI_PULSE_OFF.  
(Modulator)  
Specify one from { RAPI_PWM_16, RAPI_PWM_8 }. The default  
value is RAPI_PWM_16.  
(TAiIN pin input)  
Specify one from { RAPI_RISING, RAPI_FALLING }. The default  
value is RAPI_FALLING. The active edge of TAiIN pin input can only  
be set when RAPI_TG_TAIIN is selected.  
(R8C)  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RB  
RAPI_F1  
Uses timer Y.  
Uses timer Z.  
Uses timer RB.  
Selects f1 for the count source.  
Selects f2 for the count source.  
Selects f8 for the count source.  
Selects fRING for the count source.  
Selects underflow of timer Y for the count source.  
RAPI_F2  
RAPI_F8  
RAPI_FRING  
RAPI_TIMER_Y_  
UNDERFLOW  
RAPI_TIMER_RA_ Selects underflow of timer RA for the count source.  
UNDERFLOW  
RAPI_TIMER_ON  
Sets the timer to start operating in __CreatePulseWidthModulationMode.  
RAPI_TIMER_OFF Sets the timer to stop operating in __CreatePulseWidthModulationMode.  
RAPI_H_L_L  
Sets to output a high during the primary period, a low during the  
secondary period, and a low when the timer is idle.  
RAPI_L_H_H  
Sets to output a low during the primary period, a high during the  
secondary period, and a high when the timer is idle.  
• Specifiable definition values when timer Y is used (RAPI_TIMER_Y specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F8, RAPI_FRING }. The default  
value is RAPI_F1.  
(Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Output)  
Specify one from { RAPI_H_L_L, RAPI_L_H_H }. The default value is  
RAPI_H_L_L.  
• Specifiable definition values when timer Z is used (RAPI_TIMER_Z specified)  
Rev.1.01  
2007.02.16  
76  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8,  
RAPI_TIMER_Y_UNDERFLOW}. The default value is RAPI_F1.  
(Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Output)  
Specify one from { RAPI_H_L_L, RAPI_L_H_H }. The default value is  
RAPI_H_L_L.  
• Specifiable definition values when timer RB is used (RAPI_TIMER_RB specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8,  
RAPI_TIMER_RA_UNDERFLOW}. The default value is RAPI_F1.  
(Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Output)  
Specify one from { RAPI_H_L_L, RAPI_L_H_H }. The default value is  
RAPI_H_L_L.  
(H8/300H)  
RAPI_TIMER_V  
Uses timer V.  
RAPI_TV_F4  
RAPI_TV_F8  
RAPI_TV_F16  
RAPI_TV_F32  
RAPI_TV_F64  
RAPI_TV_F128  
Timer V counts on falling edges of internal clock φ/4.  
Timer V counts on falling edges of internal clock φ/8.  
Timer V counts on falling edges of internal clock φ/16.  
Timer V counts on falling edges of internal clock φ/32.  
Timer V counts on falling edges of internal clock φ/64.  
Timer V counts on falling edges of internal clock φ/128.  
RAPI_TIMER_ON Sets the timer to start operating in __CreatePulseWidthModulationMode.  
RAPI_TIMER_OFF Sets the timer to stop operating in __CreatePulseWidthModulationMode.  
RAPI_COMPARE  
_MATCH_A  
Enables compare match A interrupt.  
RAPI_COMPARE  
_MATCH_B  
Enables compare match B interrupt.  
RAPI_OUT_H_L  
Sets to output a high the during primary period and a low during the  
secondary period.  
RAPI_OUT_L_H  
Sets to output a low the during primary period and a high during the  
secondary period.  
RAPI_RISING  
RAPI_FALLING  
RAPI_BOTH  
Selects the rising edge of TRGV pin input signal as active edge.  
Selects the falling edge of TRGV pin input signal as active edge.  
Selects both rising and falling edges of TRGV pin input signal as active  
edge.  
RAPI_TRGV_RIS Selects the rising edge of TRGV pin input signal as active edge.  
ING  
RAPI_  
Selects the falling edge of TRGV pin input signal as active edge.  
TRGV_FALLING  
RAPI_  
Selects both rising and falling edges of TRGV pin input signal as active  
edges.  
TRGV_BOTH  
RAPI_TRGV_  
PROHIBITED  
Selects that trigger input from TRGV pin is disabled.  
Rev.1.01  
2007.02.16  
77  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
• Specifiable definition values when timer V is used (RAPI_TIMER_V specified)  
(Clock)  
Specify one from { RAPI_TV_F4, RAPI_TV_F8, RAPI_TV_F16,  
RAPI_TV_F32, RAPI_TV_F64, RAPI_TV_F128 }. If clock  
specification is omitted, specify “Disable clock input.”  
(Interrupt)  
If compare match  
A
interrupt requests are enabled, specify  
RAPI_COMPARE_MATCH_A. If compare match B interrupt requests  
are enabled, specify RAPI_COMPARE_MATCH_B. If no interrupts  
are specified, “No interrupt request” is set.  
(Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The  
default value is RAPI_TIMER_OFF.  
(Output)  
Specify one from { RAPI_OUT_H_L, RAPI_OUT_L_H }. Always be  
sure to specify this output.  
(TRGV pin input)  
Specify one from { RAPI_TRGV_RISING, RAPI_ TRGV_FALLING,  
RAPI_ TRGV_BOTH, RAPI_TRGV_PROHIBITED }.  
The default value is RAPI_TRGV_PROHIBITED.  
[data2]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register.  
For the CPUs that do not have an interrupt control register, specify 0.  
[data3]  
(M16C)  
Specify a pointer to the 16-bit variable in which the set value for the timer register is  
stored.  
For 16-bit PWM, specify the value of ‘n’ in “high-level width n/fj, period 65535/fj” in  
16 bits.  
For 8-bit PWM, specify the values of ‘n’ and ‘m’ in “high-level width n (m + 1)/f,  
period 255 (m + 1)/fj” in the 8 high-order bits and the 8 low-order bits, respectively.  
(R8C)  
Specify a pointer to the array in which the set value is stored.  
[0]: Specify the set value for the primary register in 8 bits.  
[1]: Specify the set value for the secondary register in 8 bits.  
[2]: Specify the set value for the prescaler in 8 bits.  
(H8/300H)  
Specify a pointer to the array in which the set value is stored.  
[0]: Specify the comparison value A in 8 bits.  
[1]: Specify the comparison value B in 8 bits.  
Return value  
Functionality  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Timer (pulse width modulation mode (PWM mode))  
Rev.1.01  
2007.02.16  
78  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Reference  
Remark  
__EnablePulseWidthModulationMode, __DestroyPulseWidthModulationMode  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
For the H8/300H, make sure that comparison value A < comparison value B.  
When used for the H8/300H, this API specify when freeing it from module stanby  
state.  
Program example  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc( void ){}  
void func( void )  
{
unsigned int p_tim[] = {0xAA, 0xBB, 0xCC};  
/* Set up timer Z as pulse width modulation mode */  
__CreatePulseWidthModulationMode( RAPI_TIMER_Z|RAPI_TIMER_ON|RAPI_F8,  
5, p_tim, TimerIntFunc);  
}
Rev.1.01  
2007.02.16  
79  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnablePulseWidthModulationMode  
Synopsis  
<Control operation of pulse width modulation mode>  
Boolean __EnablePulseWidthModulationMode(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified pulse width modulation mode by  
starting or stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_ON  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Sets the timer that is set to pulse width modulation mode to  
start operating.  
RAPI_TIMER_OFF  
Sets the timer that is set to pulse width modulation mode to  
stop operating.  
(R8C)  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RB  
RAPI_TIMER_ON  
Selects timer Y.  
Selects timer Z.  
Selects timer RB.  
Sets the timer that is set to pulse width modulation mode to  
start operating.  
RAPI_TIMER_OFF  
Sets the timer that is set to pulse width modulation mode to  
stop operating.  
(H8/300H)  
RAPI_TIMER_V  
Selects timer V.  
RAPI_TIMER_ON  
Sets the timer that is set to pulse width modulation mode to  
start operating.  
RAPI_TIMER_OFF  
Sets the timer that is set to pulse width modulation mode to  
stop operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse width modulation mode (PWM mode))  
__CreatePulseWidthModulationMode, __DestroyPulseWidthModulationMode  
Rev.1.01  
2007.02.16  
80  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Remark  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Enable timer Y as pulse width modulation mode */  
__EnablePulseWidthModulationMode( RAPI_TIMER_Y|RAPI_TIMER_ON );  
}
Rev.1.01  
2007.02.16  
81  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyPulseWidthModulationMode  
Synopsis  
<Discard settings of pulse width modulation mode>  
Boolean __DestroyPulseWidthModulationMode(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified pulse width modulation mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
(R8C)  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RB  
Selects timer Y.  
Selects timer Z.  
Selects timer RB.  
(H8/300H)  
RAPI_TIMER_V  
Selects timer V.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (pulse width modulation mode (PWM mode))  
__CreatePulseWidthModulationMode, __EnablePulseWidthModulationMode  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Destroy the setting of timer Z as pulse width modulation mode */  
__DestroyPulseWidthModulationMode( RAPI_TIMER_Z );  
}
Rev.1.01  
2007.02.16  
82  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreatePulsePeriodMeasurementMode  
Synopsis  
<Set pulse period measurement mode>  
Boolean __CreatePulsePeriodMeasurementMode(unsigned long data1, unsigned  
int data2, unsigned int data3, unsigned int data4, void* func)  
data1  
data2  
data3  
data4  
func  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets a specified timer to pulse period measurement mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at the  
same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_F1  
Uses timer B channel 0.  
Uses timer B channel 1.  
Uses timer B channel 2.  
Selects f1 for the count source.  
RAPI_F2  
Selects f2 for the count source.  
RAPI_F8  
Selects f8 for the count source.  
RAPI_F32  
Selects f32 for the count source.  
Selects fC32 for the count source.  
Sets the timer to start operating in  
__CreatePulsePeriodMeasurementMode.  
Sets the timer to stop operating in  
__CreatePulsePeriodMeasurementMode.  
Selects measurement of an interval from the rise to the next rise of a  
measurement pulse.  
RAPI_FC32  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_RISING_  
RISING  
RAPI_FALLING_  
FALLING  
Selects measurement of an interval from the fall to the next fall of a  
measurement pulse.  
• Specifiable definition values when timer B is used (RAPI_TIMER_B0 to RAPI_TIMER_B2  
specified)  
(Count source)  
Specify one from  
{
RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32,  
RAPI_FC32 }. The default value is RAPI_F2.  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Operating  
set)  
(Measurement  
pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_FALLING_FALLING.  
(R8C)  
RAPI_TIMER_X  
Uses timer X.  
Rev.1.01  
2007.02.16  
83  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TIMER_RA  
RAPI_F1  
Uses timer RA.  
Selects f1 for the count source.  
RAPI_F2  
Selects f2 for the count source.  
RAPI_F8  
Selects f8 for the count source.  
RAPI_F32  
Selects f32 for the count source.  
RAPI_FC32  
Selects fC32 for the count source.  
RAPI_FOCO  
Selects fOCO for the count source.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_RISING_  
RISING  
Sets the timer to start operating in __CreatePulsePeriodMeasurementMode.  
Sets the timer to stop operating in __CreatePulsePeriodMeasurementMode.  
Selects measurement of an interval from the rise to the next rise of a  
measurement pulse.  
RAPI_FALLING_  
FALLING  
Selects measurement of an interval from the fall to the next fall of a  
measurement pulse.  
RAPI_FILTER_F1  
RAPI_FILTER_F8  
RAPI_FILTER_F32  
RAPI_TIOSEL_P1_7  
RAPI_TIOSEL_P1_5  
Use sampling frequency f1 for digital filter function  
Use sampling frequency f8 for digital filter function  
Use sampling frequency f32 for digital filter function  
Sets count source input pin to P1_7.  
Sets count source input pin to P1_5.  
• Specifiable definition values when timer X is used (RAPI_TIMER_X specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32 }. The  
default value is RAPI_F1.  
(Operating  
set)  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Measurement  
pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_FALLING_FALLING.  
• Specifiable definition values when timer RA is used (RAPI_TIMER_RA specified)  
(Count source)  
Specify one from  
{
RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32,  
RAPI_FOCO }. The default value is RAPI_F1.  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Operating  
set)  
(Measure pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_FALLING_FALLING.  
(Filter)  
Specify one from { RAPI_FILTER_F1, RAPI_FILTER_F8,  
RAPI_FILTER_F32}. The default value is no filter.  
(Input pin)  
Specify one from { RAPI_TIOSEL_P1_7, RAPI_TIOSEL_P1_5 }. The  
default value is RAPI_TIOSEL_P1_7.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
Uses timer W.  
Uses timer Z channel 0.  
Uses timer Z channel 1.  
Uses timer RC.  
Uses timer RD0 channel 0.  
Uses timer RD0 channel 1.  
Uses timer RD0 channel 2.  
Rev.1.01  
2007.02.16  
84  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TIMER_RD3  
RAPI_TW_F1  
RAPI_TW_F2  
RAPI_TW_F4  
RAPI_TW_F8  
RAPI_TZ_F1  
RAPI_TZ_F2  
RAPI_TZ_F4  
RAPI_TZ_F8  
RAPI_TRC_F1  
Uses timer RD0 channel 3.  
Timer W counts with internal clock φ.  
Timer W counts with internal clock φ/2.  
Timer W counts with internal clockφ/4.  
Timer W counts with internal clock φ/8.  
Timer Z counts with internal clock φ.  
Timer Z counts with internal clock φ/2.  
Timer Z counts with internal clock φ/4.  
Timer Z counts with internal clock φ/8.  
Timer RC counts with internal clock φ.  
RAPI_TRC_F2  
Timer RC counts with internal clock φ/2.  
Timer RC counts with internal clockφ/4.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ40M.  
Timer RD counts with internal clock φ.  
RAPI_TRC_F4  
RAPI_TRC_F8  
RAPI_TRC_F32  
RAPI_TRC_F40M  
RAPI_TRD_F1  
RAPI_TRD_F2  
Timer RD counts with internal clock φ/2.  
Timer RD counts with internal clockφ/4.  
Timer RD counts with internal clock φ/8.  
Timer RD counts with internal clock φ/32.  
Timer RD counts with internal clock φ40M.  
Sets the timer to start operating in __CreatePulsePeriodMeasurementMode.  
Sets the timer to stop operating in __CreatePulsePeriodMeasurementMode.  
Enables overflow interrupt.  
RAPI_TRD_F4  
RAPI_TRD_F8  
RAPI_TRD_F32  
RAPI_TRD_F40M  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_OVERFLOW  
RAPI_RISING_  
RISING  
Selects measurement of an interval from the rise to the next rise of a  
measurement pulse.  
RAPI_FALLING_  
FALLING  
Selects measurement of an interval from the fall to the next fall of a  
measurement pulse.  
RAPI_TRC_FILTER_F  
1
Use sampling frequency f1 for timer RC digital filter function  
RAPI_TRC_FILTER_F  
8
Use sampling frequency f8 for timer RC digital filter function  
Use sampling frequency f32 for timer RC digital filter function  
RAPI_TRC_FILTER_F  
32  
RAPI_TRD_FILTER_F  
RAPI_TRD_FILTER_F  
1
Use sampling frequency f for timer RC digital filter function  
Use sampling frequency f1 for timer RD digital filter function  
RAPI_TRD_FILTER_F  
8
Use sampling frequency f8 for timer RD digital filter function  
Use sampling frequency f32 for timer RD digital filter function  
RAPI_TRD_FILTER_F  
32  
RAPI_TRD_FILTER_F  
RAPI_FTIOA  
Use sampling frequency f for timer RD digital filter function  
Use FTIOA pin as input pin.  
Rev.1.01  
2007.02.16  
85  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_FTIOB  
Use FTIOB pin as input pin.  
• Specifiable definition values when timer W is used (RAPI_TIMER_W specified)  
(Count source)  
Specify one from  
{
RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4,  
RAPI_TW_F8 }. The default value is RAPI_TW_F1.  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Operating  
set)  
(Measurement  
pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_RISING_RISING.  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
• Specifiable definition values when timer Z is used (RAPI_TIMER_Z0 to RAPI_TIMER_Z1  
specified)  
(Count source)  
Specify one from { RAPI_TZ_F1, RAPI_TZ_F2, RAPI_TZ_F4,  
RAPI_TZ_F8 }. The default value is RAPI_TZ_F1.  
(Operating  
set)  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Measurement  
pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_RISING_RISING.  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_FTIOA, RAPI_FTIOB }. The default value is  
RAPI_FTIOA.  
(Input pin)  
• Specifiable definition values when timer RC is used (RAPI_TIMER_RC specified)  
(Count source)  
Specify one from { RAPI_TRC_F1, RAPI_TRC_F2, RAPI_TRC_F4,  
RAPI_TRC_F8, RAPI_TRC_F32 }. The default value is RAPI_RC_F1.  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Operating  
set)  
(Measurement  
pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_RISING_RISING.  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_FTIOA, RAPI_FTIOB }. The default value is  
RAPI_FTIOA.  
(Input pin)  
(Clock for digital Specify one from { RAPI_TRC_FILTER_F1, RAPI_TRC_FILTER_F8,  
filter)  
RAPI_TRC_FILTER_F32, RAPI_TRC_FILTER_F }. The default value is  
RAPI_TRC_FILTER_F32.  
• Specifiable definition values when timer RD is used (RAPI_TIMER_RD specified)  
(Count source)  
Specify one from { RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M }. The default value  
is RAPI_RC_F1.  
(Operating  
set)  
states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(Measurement  
pulse)  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_RISING_RISING.  
Rev.1.01  
2007.02.16  
86  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Interrupt)  
(Input pin)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
no interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_FTIOA, RAPI_FTIOB }. The default value is  
RAPI_FTIOA.  
(Clock for digital Specify one from { RAPI_TRC_FILTER_F1, RAPI_TRC_FILTER_F8,  
filter)  
RAPI_TRC_FILTER_F32, RAPI_TRC_FILTER_F }. The default value is  
RAPI_TRC_FILTER_F32.  
[data2]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register. For  
the CPUs that do not have an interrupt control register, specify 0.  
[data3]  
(M16C) (H8/300H)  
Specify 0.  
(R8C)  
When using timer X, specify the set value for the timer register.  
[data4]  
(M16C) (H8/300H)  
Specify 0.  
(R8C)  
Specify the set value for the prescaler register.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is  
returned.  
Functionality  
Reference  
Timer (pulse period measurement mode)  
__EnablePulsePeriodMeasurementMode, __DestroyPulsePeriodMeasurementMode,  
__GetPulsePeriodMeasurementMode  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API specify when freeing it from module stanby  
state.  
Program example  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc( void ){}  
void func( void )  
{
/* Set up timer X as pulse period measurement mode */  
__CreatePulsePeriodMeasurementMode(  
RAPI_TIMER_X|RAPI_TIMER_ON|RAPI_FALLING_FALLING|RAPI_F8,  
5, 0x80, 0x80, TimerIntFunc);  
}
Rev.1.01  
2007.02.16  
87  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnablePulsePeriodMeasurementMode  
Synopsis  
<Control operation of pulse period measurement mode>  
Boolean __EnablePulsePeriodMeasurementMode(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified pulse period measurement mode  
by starting or stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_ON  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Sets the timer that is set to pulse period measurement mode to start  
operating.  
RAPI_TIMER_OFF Sets the timer that is set to pulse period measurement mode to stop  
operating.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
RAPI_TIMER_RA  
RAPI_TIMER_ON  
Selects timer RA.  
Sets the timer that is set to pulse period measurement mode to start  
operating.  
RAPI_TIMER_  
OFF  
Sets the timer that is set to pulse period measurement mode to stop  
operating.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD  
0
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
RAPI_TIMER_RD  
1
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
RAPI_TIMER_RD  
2
RAPI_TIMER_RD  
3
RAPI_TIMER_ON  
Sets the timer that is set to pulse period measurement mode to start  
operating.  
Rev.1.01  
2007.02.16  
88  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TIMER_  
OFF  
Sets the timer that is set to pulse period measurement mode to stop  
operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse period measurement mode)  
__CreatePulsePeriodMeasurementMode, __DestroyPulsePeriodMeasurementMode,  
__GetPulsePeriodMeasurementMode  
Remark  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Enable timer X as pulse period measurement mode */  
__EnablePulsePeriodMeasurementMode( RAPI_TIMER_X|RAPI_TIMER_ON );  
}
Rev.1.01  
2007.02.16  
89  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyPulsePeriodMeasurementMode  
Synopsis  
<Discard settings of pulse period measurement mode>  
Boolean __DestroyPulsePeriodMeasurementMode(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified pulse period measurement mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
RAPI_TIMER_RA  
Selects timer RA.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD  
0
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
RAPI_TIMER_RD  
1
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
RAPI_TIMER_RD  
2
RAPI_TIMER_RD  
3
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse period measurement mode)  
__CreatePulsePeriodMeasurementMode, __EnablePulsePeriodMeasurementMode,  
__GetPulsePeriodMeasurementMode  
Remark  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Rev.1.01  
2007.02.16  
90  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Destroy the setting of timer X as pulse period measurement mode */  
__DestroyPulsePeriodMeasurementMode( RAPI_TIMER_X );  
}
Rev.1.01  
2007.02.16  
91  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetPulsePeriodMeasurementMode  
Synopsis  
<Get measured value in pulse period measurement mode>  
Boolean __GetPulsePeriodMeasurementMode(unsigned long data1, unsigned  
int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the buffer in which counter value is stored  
Description  
Gets the counter value of the timer that is set to specified pulse period measurement  
mode.  
[data1]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
RAPI_TIMER_RA  
Selects timer RA.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD  
0
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
RAPI_TIMER_RD  
1
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
RAPI_TIMER_RD  
2
RAPI_TIMER_RD  
3
[data2]  
Specify a pointer to the array in which the acquired counter value is stored.  
(M16C)  
• When using timer B (RAPI_TIMER_B0 to RAPI_TIMER_B2 specified)  
[0]: The value of timer Bi register (i = 0–2) is stored.  
(R8C)  
• When using timer X (RAPI_TIMER_X specified)  
[0]: The value of prescaler X register is stored.  
[1]: The value of timer X register is stored.  
• When using timer RA (RAPI_TIMER_RA specified)  
Rev.1.01  
2007.02.16  
92  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[0]: The value of timer RA prescaler register is stored.  
[1]: The value of timer RA register is stored.  
(H8/300H)  
• When using timer W (RAPI_TIMER_W specified)  
[0]: (The value of general register A) – (The value of general register C) is stored.  
[1]: (The value of general register B) – (The value of general register D) is stored.  
• When using timer Z (RAPI_TIMER_Z0 - RAPI_TIMER_Z1 specified)  
[0]: (The value of general register Ai(i=0,1)) – (The value of general register C  
i(i=0,1)) is stored.  
[1]: (The value of general register B i(i=0,1)) – (The value of general register D  
i(i=0,1)) is stored.  
• When using timer RC (RAPI_TIMER_RC specified)  
[0]: (The value of general register A) – (The value of general register C) is stored.  
[1]: (The value of general register B) – (The value of general register D) is stored.  
• When using timer RD (RAPI_TIMER_RD specified)  
[0]: (The value of general register A) – (The value of general register C) is stored.  
[1]: (The value of general register B) – (The value of general register D) is stored.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse period measurement mode)  
__CreatePulsePeriodMeasurementMode, __EnablePulsePeriodMeasurementMode,  
__DestroyPulsePeriodMeasurementMode  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
unsigned int data[2];  
/* Get the measured value of timer X as pulse period measurement mode  
*/  
__GetPulsePeriodMeasurementMode( RAPI_TIMER_X, data );  
}
Rev.1.01  
2007.02.16  
93  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreatePulseWidthMeasurementMode  
Synopsis  
<Set pulse width measurement mode>  
Boolean __CreatePulseWidthMeasurementMode(unsigned long data1, unsigned  
int data2, unsigned int data3, unsigned int data4, void* func)  
data1  
data2  
data3  
data4  
func  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets a specified timer to pulse with measurement mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_F1  
Uses timer B channel 0.  
Uses timer B channel 1.  
Uses timer B channel 2.  
Selects f1 for the count source.  
Selects f2 for the count source.  
Selects f8 for the count source.  
Selects f32 for the count source.  
Selects fC32 for the count source.  
Sets the timer to start operating in  
__CreatePulseWidthMeasurementMode.  
RAPI_F2  
RAPI_F8  
RAPI_F32  
RAPI_FC32  
RAPI_TIMER_ON  
RAPI_TIMER_OFF Sets the timer to stop operating in  
__CreatePulseWidthMeasurementMode.  
• Specifiable definition values when timer B is used (RAPI_TIMER_B0 to  
RAPI_TIMER_B2 specified)  
(Count source) Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32, RAPI_FC32 }.  
The default value is RAPI_F2.  
(Operating  
states set)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
(R8C)  
RAPI_TIMER_X  
RAPI_TIMER_RA  
RAPI_F1  
Uses timer X.  
Uses timer RA.  
Selects f1 for the count source.  
Selects f2 for the count source.  
Selects f8 for the count source.  
Selects f32 for the count source.  
Selects fC32 for the count source.  
RAPI_F2  
RAPI_F8  
RAPI_F32  
RAPI_FC32  
Rev.1.01  
2007.02.16  
94  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_FOCO  
Selects fOCO for the count source.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_RISING_  
RISING  
Sets the timer to start operating in __CreatePulsePeriodMeasurementMode.  
Sets the timer to stop operating in __CreatePulsePeriodMeasurementMode.  
Selects measurement of an interval from the rise to the next rise of a  
measurement pulse.  
RAPI_FALLING_  
FALLING  
Selects measurement of an interval from the fall to the next fall of a  
measurement pulse.  
RAPI_FILTER_F1  
RAPI_FILTER_F8  
Use sampling frequency f1 for digital filter function  
Use sampling frequency f8 for digital filter function  
RAPI_FILTER_F32 Use sampling frequency f32 for digital filter function  
RAPI_TIOSEL_P1  
Sets count source input pin to P1_7.  
_7  
RAPI_TIOSEL_P1  
_5  
Sets count source input pin to P1_5.  
• Specifiable definition values when timer X is used (RAPI_TIMER_X specified)  
(Count source) Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32 }. The default  
value is RAPI_F1.  
(Operating  
states set)  
(Measurement  
pulse)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_FALLING_RISING, RAPI_RISING_FALLING }.  
The default value is RAPI_FALLING_RISING.  
• Specifiable definition values when timer RA is used (RAPI_TIMER_RA specified)  
(Count source) Specify one from RAPI_F1, RAPI_F2, RAPI_F8, RAPI_F32,  
{
RAPI_FOCO }. The default value is RAPI_F1.  
(Operating  
states set)  
(Measure  
pulse)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_RISING_RISING, RAPI_FALLING_FALLING }.  
The default value is RAPI_FALLING_FALLING.  
(Filter)  
Specify one from { RAPI_FILTER_F1, RAPI_FILTER_F8,  
RAPI_FILTER_F32}. The default value is no filter.  
(Input pin)  
Specify one from { RAPI_TIOSEL_P1_7, RAPI_TIOSEL_P1_5 }. The  
default value is RAPI_TIOSEL_P1_7.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
Uses timer W.  
Uses timer Z channel 0.  
Uses timer Z channel 1.  
Uses timer RC.  
RAPI_TIMER_RD0 Uses timer RD0 channel 0.  
RAPI_TIMER_RD1 Uses timer RD0 channel 1.  
RAPI_TIMER_RD2 Uses timer RD0 channel 2.  
RAPI_TIMER_RD3 Uses timer RD0 channel 3.  
RAPI_TW_F1  
RAPI_TW_F2  
RAPI_TW_F4  
Timer W counts with internal clock φ.  
Timer W counts with internal clock φ/2.  
Timer W counts with internal clock φ/4.  
Rev.1.01  
2007.02.16  
95  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TW_F8  
RAPI_TZ_F1  
RAPI_TZ_F2  
RAPI_TZ_F4  
RAPI_TZ_F8  
RAPI_TRC_F1  
RAPI_TRC_F2  
RAPI_TRC_F4  
RAPI_TRC_F8  
RAPI_TRC_F32  
RAPI_TRC_F40M  
RAPI_TRD_F1  
RAPI_TRD_F2  
RAPI_TRD_F4  
RAPI_TRD_F8  
RAPI_TRD_F32  
RAPI_TRD_F40M  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_OVERFLOW  
RAPI_RISING_  
RISING  
Timer W counts with internal clock φ/8.  
Timer Z counts with internal clock φ.  
Timer Z counts with internal clock φ/2.  
Timer Z counts with internal clock φ/4.  
Timer Z counts with internal clock φ/8.  
Timer RC counts with internal clock φ.  
Timer RC counts with internal clock φ/2.  
Timer RC counts with internal clockφ/4.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ40M.  
Timer RD counts with internal clock φ.  
Timer RD counts with internal clock φ/2.  
Timer RD counts with internal clockφ/4.  
Timer RD counts with internal clock φ/8.  
Timer RD counts with internal clock φ/32.  
Timer RD counts with internal clock φ40M.  
Sets the timer to start operating in __CreatePulsePeriodMeasurementMode.  
Sets the timer to stop operating in __CreatePulsePeriodMeasurementMode.  
Enables overflow interrupt.  
Selects measurement of an interval from the rise to the next rise of a  
measurement pulse.  
RAPI_FALLING_  
FALLING  
Selects measurement of an interval from the fall to the next fall of a  
measurement pulse.  
RAPI_TRC_FILTE  
R_F1  
Use sampling frequency f1 for timer RC digital filter function  
RAPI_TRC_FILTE  
R_F8  
Use sampling frequency f8 for timer RC digital filter function  
Use sampling frequency f32 for timer RC digital filter function  
Use sampling frequency f for timer RC digital filter function  
Use sampling frequency f1 for timer RD digital filter function  
Use sampling frequency f8 for timer RD digital filter function  
Use sampling frequency f32 for timer RD digital filter function  
Use sampling frequency f for timer RD digital filter function  
RAPI_TRC_FILTE  
R_F32  
RAPI_TRD_FILTE  
R_F  
RAPI_TRD_FILTE  
R_F1  
RAPI_TRD_FILTE  
R_F8  
RAPI_TRD_FILTE  
R_F32  
RAPI_TRD_FILTE  
R_F  
RAPI_FTIOA  
RAPI_FTIOB  
Use FTIOA pin as input pin.  
Use FTIOB pin as input pin.  
• Specifiable definition values when timer W is used (RAPI_TIMER_W specified)  
Rev.1.01  
2007.02.16  
96  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Count source) Specify one from { RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4,  
RAPI_TW_F8 }. The default value is RAPI_TW_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If no  
interrupts are specified, No interrupt requestis set.  
• Specifiable definition values when timer Z is used (RAPI_TIMER_Z0 to  
RAPI_TIMER_Z1 specified)  
(Count source) Specify one from { RAPI_TZ_F1, RAPI_TZ_F2, RAPI_TZ_F4,  
RAPI_TZ_F8 }. The default value is RAPI_TZ_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If no  
interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_FTIOA, RAPI_FTIOB }. The default value is  
RAPI_FTIOA.  
(Input pin)  
• Specifiable definition values when timer RC is used (RAPI_TIMER_RC specified)  
(Count  
Specify one from { RAPI_TRC_F1, RAPI_TRC_F2, RAPI_TRC_F4,  
RAPI_TRC_F8, RAPI_TRC_F32, RAPI_TRC_F40M }. The default value is  
RAPI_RC_F1.  
source)  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If no  
interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_FTIOA, RAPI_FTIOB }. The default value is  
RAPI_FTIOA.  
(Input pin)  
(Clock  
for Specify one from  
{
RAPI_TRC_FILTER_F1, RAPI_TRC_FILTER_F8,  
digital filter)  
RAPI_TRC_FILTER_F32, RAPI_TRC_FILTER_F }. The default value is  
RAPI_TRC_FILTER_F32.  
• Specifiable definition values when timer RD is used (RAPI_TIMER_RD specified)  
(Count  
Specify one from { RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M }. The default value is  
RAPI_RC_F1.  
source)  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If no  
interrupts are specified, “No interrupt request” is set.  
Specify one from { RAPI_FTIOA, RAPI_FTIOB }. The default value is  
RAPI_FTIOA.  
(Input pin)  
(Clock  
for Specify one from  
{
RAPI_TRC_FILTER_F1, RAPI_TRC_FILTER_F8,  
digital filter)  
RAPI_TRC_FILTER_F32, RAPI_TRC_FILTER_F }. The default value is  
RAPI_TRC_FILTER_F32.  
[data2]  
(M16C) (R8C)  
Rev.1.01  
2007.02.16  
97  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register. For  
the CPUs that do not have an interrupt control register, specify 0.  
[data3]  
(M16C)(H8/300H)  
Specify 0.  
(R8C)  
When using timer X, specify the set value for the timer register.  
[data4]  
(M16C) (H8/300H)  
Specify 0.  
(R8C)  
Specify the set value for the prescaler register.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse width measurement mode)  
__EnablePulseWidthMeasurementMode, __DestroyPulseWidthMeasurementMode,  
__GetPulseWidthMeasurementMode  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API specify when freeing it from module stanby  
state.  
Program example  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc( void ){}  
void func( void )  
{
/* Set up timer X as pulse width measurement mode */  
__CreatePulseWidthMeasurementMode(  
RAPI_TIMER_X|RAPI_TIMER_ON|RAPI_RISING_FALLING|RAPI_F8,  
5, 0x80, 0x80, TimerIntFunc);  
}
Rev.1.01  
2007.02.16  
98  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnablePulseWidthMeasurementMode  
Synopsis  
<Control operation of pulse width measurement mode>  
Boolean __EnablePulseWidthMeasurementMode(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified pulse width measurement mode.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_ON  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Sets the timer that is set to pulse width measurement mode to start  
operating.  
RAPI_TIMER_OFF Sets the timer that is set to pulse width measurement mode to stop  
operating.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
RAPI_TIMER_RA  
RAPI_TIMER_ON  
Selects timer RA.  
Sets the timer that is set to pulse width measurement mode to start  
operating.  
RAPI_TIMER_OFF Sets the timer that is set to pulse width measurement mode to stop  
operating.  
(H8/300H)  
RAPI_TIMER_W  
Selects timer W.  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD  
0
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
RAPI_TIMER_RD  
1
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
RAPI_TIMER_RD  
2
RAPI_TIMER_RD  
3
RAPI_TIMER_ON  
Sets the timer that is set to pulse width measurement mode to start  
operating.  
RAPI_TIMER_OFF Sets the timer that is set to pulse width measurement mode to stop  
operating.  
Rev.1.01  
2007.02.16  
99  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse width measurement mode)  
__CreatePulseWidthMeasurementMode, __DestroyPulseWidthMeasurementMode,  
__GetPulseWidthMeasurementMode  
Remark  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Disable timer X as pulse width measurement mode */  
__EnablePulseWidthMeasurementMode( RAPI_TIMER_X|RAPI_TIMER_OFF );  
}
Rev.1.01  
2007.02.16  
100  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyPulseWidthMeasurementMode  
Synopsis  
<Discard settings of pulse width measurement mode>  
Boolean __DestroyPulseWidthMeasurementMode(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified pulse width measurement mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD  
0
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
RAPI_TIMER_RD  
1
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
RAPI_TIMER_RD  
2
RAPI_TIMER_RD  
3
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse width measurement mode)  
__CreatePulseWidthMeasurementMode, __EnablePulseWidthMeasurementMode,  
__GetPulseWidthMeasurementMode  
Remark  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Rev.1.01  
2007.02.16  
101  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Destroy the setting of timer X as pulse width measurement mode */  
__DestroyPulseWidthMeasurementMode( RAPI_TIMER_X );  
}
Rev.1.01  
2007.02.16  
102  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetPulseWidthMeasurementMode  
Synopsis  
<Get measured value in pulse width measurement mode>  
Boolean __GetPulseWidthMeasurementMode(unsigned long data1, unsigned int  
*data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the buffer in which counter value is stored  
Description  
Gets the counter value of the timer that is set to specified pulse width measurement  
mode.  
[data1]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
(R8C)  
RAPI_TIMER_X  
Selects timer X.  
RAPI_TIMER_RA  
Selects timer RA.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD  
0
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
RAPI_TIMER_RD  
1
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
RAPI_TIMER_RD  
2
RAPI_TIMER_RD  
3
[data2]  
Specify a pointer to the array in which the acquired counter value is stored.  
(M16C)  
• When using timer B (RAPI_TIMER_B0 to RAPI_TIMER_B2 specified)  
[0]: The value of timer Bi register (i = 0–2) is stored.  
(R8C)  
• When using timer X (RAPI_TIMER_X specified)  
[0]: The value of prescaler X register is stored.  
[1]: The value of timer X register is stored.  
• When using timer RA (RAPI_TIMER_RA specified)  
Rev.1.01  
2007.02.16  
103  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[0]: The value of timer RA prescaler register is stored.  
[1]: The value of timer RA register is stored.  
(H8/300H)  
• When using timer W (RAPI_TIMER_W specified)  
[0]: (The value of general register A) – (The value of general register C) is stored.  
[1]: (The value of general register B) – (The value of general register D) is stored.  
• When using timer Z (RAPI_TIMER_Z0 - RAPI_TIMER_Z1 specified)  
[0]: (The value of general register Ai(i=0,1)) – (The value of general register C  
i(i=0,1)) is stored.  
[1]: (The value of general register B i(i=0,1)) – (The value of general register D  
i(i=0,1)) is stored.  
• When using timer RC (RAPI_TIMER_RC specified)  
[0]: (The value of general register A) – (The value of general register C) is stored.  
[1]: (The value of general register B) – (The value of general register D) is stored.  
• When using timer RD (RAPI_TIMER_RD specified)  
[0]: (The value of general register A) – (The value of general register C) is stored.  
[1]: (The value of general register B) – (The value of general register D) is stored.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Timer (pulse width measurement mode)  
__CreatePulseWidthMeasurementMode, __EnablePulseWidthMeasurementMode,  
__DestroyPulseWidthMeasurementMode  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
unsigned int data[2];  
/* Get the measured value of timer X as pulse width measurement mode  
*/  
__GetPulseWidthMeasurementMode( RAPI_TIMER_X, data );  
}
Rev.1.01  
2007.02.16  
104  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreateInputCapture  
Synopsis  
<Set input capture mode>  
Boolean __CreateInputCapture(unsigned long data1, unsigned int* data2,  
unsigned int* data3, unsigned int* data4, void** data5)  
data1  
data2  
data3  
data4  
data5  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
Setup data 5 (content differs with MCU type)  
Description  
Sets a specified timer to input capture mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_S  
RAPI_F1  
Uses timer S.  
Selects f1 for the count source.  
RAPI_F2  
Selects f2 for the count source.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Sets the timer to start operating in __CreateInputCapture.  
Sets the timer to stop operating in __CreateInputCapture.  
RAPI_OVERFLOW_BIT14 Selects overflow of bit 14 for the base timer interrupt.  
RAPI_OVERFLOW_BIT15 Selects overflow of bit 15 for the base timer interrupt.  
• Specifiable definition values when timer S is used (RAPI_TIMER_S specified)  
(Count source) Specify one from { RAPI_F1, RAPI_F2 }. The default value is RAPI_F2.  
(Operating  
states set)  
(Base timer)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_OVERFLOW_BIT14, RAPI_OVERFLOW_BIT15 }.  
The default value is RAPI_OVERFLOW_BIT15.  
(R8C)  
RAPI_TIMER_C  
Uses timer C.  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TRD_F1  
Uses timer RD channel 0.  
Uses timer RD channel 1.  
Selects f1 for the timer RD count source.  
Selects f2 for the timer RD count source.  
Selects f8 for the timer RD count source.  
Selects f32 for the timer RD count source.  
Selects fOCO40M for the timer RD count source.  
Selects fRING-fast for the count source.  
RAPI_TRD_F2  
RAPI_TRD_F8  
RAPI_TRD_F32  
RAPI_TRD_F40M  
RAPI_FRING_FAST  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_RISING  
Sets the timer to start operating in __CreateInputCapture.  
Sets the timer to stop operating in __CreateInputCapture.  
Selects the rising edge of measurement pulse as active edge.  
Rev.1.01  
2007.02.16  
105  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_FALLING  
RAPI_BOTH  
Selects the falling edge of measurement pulse as active edge.  
Selects both rising and falling edges of measurement pulse as  
active edge.  
RAPI_FILTER_F1  
RAPI_FILTER_F8  
RAPI_FILTER_F32  
Uses the digital filter facility that has a sampling frequency f1.  
Uses the digital filter facility that has a sampling frequency f8.  
Uses the digital filter facility that has a sampling frequency f32.  
RAPI_INT3_TRIGGER Selects the trigger facility of TCIN input.  
RAPI_FRING128  
RAPI_OVERFLOW  
RAPI_INPUT_CAPTU  
RE_A  
Selects the trigger facility of fRING128 input.  
Enable overflow interrupt.  
Enable GRA input capture interrupt.  
RAPI_INPUT_CAPTU  
RE_B  
Enable GRB input capture interrupt.  
RAPI_INPUT_CAPTU  
RE_C  
Enable GRC input capture interrupt.  
RAPI_INPUT_CAPTU  
RE_D  
Enable GRD input capture interrupt.  
RAPI_COUNT_CLEA  
R_A  
Selects GRA input capture to counter clear factor  
Selects GRB input capture to counter clear factor  
Selects GRC input capture to counter clear factor  
Selects GRD input capture to counter clear factor  
Clear counter in sync with the synchronized other timer counter  
Synchronize timer on channels A and B.  
RAPI_COUNT_CLEA  
R_B  
RAPI_COUNT_CLEA  
R_C  
RAPI_COUNT_CLEA  
R_D  
RAPI_COUNT_CLEA  
R_SYNC  
RAPI_TIMER_SYNC  
RAPI_TRD_FILTER_F Use sampling frequency f1 for digital filter function  
1
RAPI_TRD_FILTER_F Use sampling frequency f8 for digital filter function  
8
RAPI_TRD_FILTER_F Use sampling frequency f32 for digital filter function  
32  
RAPI_TRD_FILTER_F Use sampling frequency f for digital filter function  
• Specifiable definition values when timer C is used (RAPI_TIMER_C specified)  
(Count source) Specify one from [RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M]. The default is  
RAPI_TRD_F1.  
(Operating  
states set)  
Specify one from [RAPI_TIMER_ON, RAPI_TIMER_OFF]. The default is  
RAPI_TIMER_OFF  
Rev.1.01  
2007.02.16  
106  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
input capture A, input capture B, input capture C, or input capture D interrupt  
requests  
are  
enabled,  
specify  
RAPI_INPUT_CAPURE_A,  
or  
RAPI_INPUT_CAPURE_B,  
RAPI_INPUT_CAPURE_C,  
RAPI_INPUT_CAPURE_D, respectively. When not specifying interrupts,  
select “No interrupt requests.”  
(Counter  
clear)  
To specify GRA, GRB, GRC, or GRD input capture for the cause for which  
the counter is cleared, select RAPI_COUNT_CLEAR_A,  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively. If cleared at the same time a  
synchronously operating counter on another channel is cleared, select  
RAPI_COUNT_CLEAR_SYNC.  
(Synchronizati If timers on channels  
0
and  
1
are to be synchronized, select  
on)  
RAPI_TIMER_SYNC. When not specifying synchronization, select  
“Channels 0 and 1 operate independently.”  
(Clock  
for Specify one from [RAPI_TRD_FILTER_F1, RAPI_TRD_FILTER_F8,  
digital filter)  
RAPI_TRD_FILTER_F32,  
RAPI_TRD_FILTER_F32.  
RAPI_TRD_FILTER_F].  
The  
default  
is  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
RAPI_TW_F1  
RAPI_TW_F2  
RAPI_TW_F4  
RAPI_TW_F8  
RAPI_TZ_F1  
Uses timer W.  
Uses timer Z channel 0.  
Uses timer Z channel 1.  
Uses timer RC.  
Uses timer RD0 channel 0.  
Uses timer RD0 channel 1.  
Uses timer RD0 channel 2.  
Uses timer RD0 channel 3.  
Timer W counts with internal clock φ.  
Timer W counts with internal clock φ/2.  
Timer W counts with internal clock φ/4.  
Timer W counts with internal clock φ/8.  
Timer Z counts with internal clock φ.  
Timer Z counts with internal clock φ/2.  
Timer Z counts with internal clock φ/4.  
Timer Z counts with internal clock φ/8.  
Timer RC counts with internal clock φ.  
Timer RC counts with internal clock φ/2.  
Timer RC counts with internal clockφ/4.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ40M.  
Timer RD counts with internal clock φ.  
Timer RD counts with internal clock φ/2.  
RAPI_TZ_F2  
RAPI_TZ_F4  
RAPI_TZ_F8  
RAPI_TRC_F1  
RAPI_TRC_F2  
RAPI_TRC_F4  
RAPI_TRC_F8  
RAPI_TRC_F32  
RAPI_TRC_F40M  
RAPI_TRD_F1  
RAPI_TRD_F2  
Rev.1.01  
2007.02.16  
107  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TRD_F4  
Timer RD counts with internal clockφ/4.  
Timer RD counts with internal clock φ/8.  
Timer RD counts with internal clock φ/32.  
Timer RD counts with internal clock φ40M.  
Sets the timer to start operating in __CreateInputCapture.  
Sets the timer to stop operating in __CreateInputCapture.  
Enables overflow interrupt.  
RAPI_TRD_F8  
RAPI_TRD_F32  
RAPI_TRD_F40M  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_OVERFLOW  
RAPI_INPUT_  
Enables GRA input capture interrupt.  
CAPTURE_A  
RAPI_INPUT_  
Enables GRB input capture interrupt.  
Enables GRC input capture interrupt.  
Enables GRD input capture interrupt.  
CAPTURE_B  
RAPI_INPUT_  
CAPTURE_C  
RAPI_INPUT_  
CAPTURE_D  
RAPI_COUNT_CLEAR_A  
RAPI_COUNT_CLEAR_B  
RAPI_COUNT_CLEAR_C  
RAPI_COUNT_CLEAR_D  
RAPI_COUNT_CLEAR_S  
YNC  
Specifies GRA input capture for the cause of counter clear.  
Specifies GRB input capture for the cause of counter clear.  
Specifies GRC input capture for the cause of counter clear.  
Specifies GRD input capture for the cause of counter clear.  
Clear counter in sync with the synchronized other timer counter  
RAPI_TIMER_SYNC  
RAPI_TRC_FILTER_F1  
RAPI_TRC_FILTER_F8  
RAPI_TRC_FILTER_F32  
RAPI_TRC_FILTER_F  
RAPI_TRD_FILTER_F1  
RAPI_TRD_FILTER_F8  
RAPI_TRD_FILTER_F32  
RAPI_TRD_FILTER_F  
Synchronizes timer on channels 0 and 1.  
Use sampling frequency f1 for timer RC digital filter function  
Use sampling frequency f8 for timer RC digital filter function  
Use sampling frequency f32 for timer RC digital filter function  
Use sampling frequency f for timer RD digital filter function  
Use sampling frequency f1 for timer RD digital filter function  
Use sampling frequency f8 for timer RD digital filter function  
Use sampling frequency f32 for timer RD digital filter function  
Use sampling frequency f for timer RD digital filter function  
• Specifiable definition values when timer W is used (RAPI_TIMER_W specified)  
(Count source) Specify one from { RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4,  
RAPI_TW_F8 }. The default value is RAPI_TW_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW.  
Similarly, if input capture A, input capture B, input capture C, or input capture  
D interrupt requests are enabled, specify RAPI_INPUT_CAPTURE_A,  
RAPI_INPUT_CAPTURE_B, RAPI_INPUT_CAPTURE_C, or  
RAPI_INPUT_CAPTURE_D, respectively. If no interrupts are specified, “No  
interrupt request” is set.  
Rev.1.01  
2007.02.16  
108  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Counter  
clear)  
To specify GRA, GRB, GRC, or GRD input capture for the cause for which  
the counter is cleared, select RAPI_COUNT_CLEAR_A,  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively. If cleared at the same time a  
synchronously operating counter on another channel is cleared, select  
RAPI_COUNT_CLEAR_SYNC.  
• Specifiable definition values when timer Z is used (RAPI_TIMER_Z0 to  
RAPI_TIMER_Z1 specified)  
(Count source)  
Specify one from { RAPI_TZ_F1, RAPI_TZ_F2, RAPI_TZ_F4,  
RAPI_TZ_F8 }. The default value is RAPI_TZ_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW.  
Similarly, if input capture A, input capture B, input capture C, or input  
capture D interrupt requests are enabled, specify  
RAPI_INPUT_CAPTURE_A, RAPI_INPUT_CAPTURE_B,  
RAPI_INPUT_CAPTURE_C, or RAPI_INPUT_CAPTURE_D,  
respectively. If no interrupts are specified, “No interrupt request” is set.  
To specify GRA, GRB, GRC, or GRD input capture for the cause of  
counter clear, specify RAPI_COUNT_CLEAR_A,  
(Counter clear)  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively.  
(Synchronization) If the timer is synchronized on channels 0 and 1, specify  
RAPI_TIMER_SYNC. If synchronization is not specified, “Channels 0 and  
1 operate independently” is set.  
• Specifiable definition values when timer RC is used (RAPI_TIMER_RC specified)  
(Count source)  
Specify one from [RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M]. The default is  
RAPI_TRD_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from [RAPI_TIMER_ON, RAPI_TIMER_OFF]. The default is  
RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
input capture A, input capture B, input capture C, or input capture D  
interrupt requests are enabled, specify RAPI_INPUT_CAPURE_A,  
RAPI_INPUT_CAPURE_B,  
RAPI_INPUT_CAPURE_C,  
or  
RAPI_INPUT_CAPURE_D, respectively. When not specifying interrupts,  
select “No interrupt requests.”  
(Clock for digital Specify one from [RAPI_TRD_FILTER_F1, RAPI_TRD_FILTER_F8,  
filter)  
RAPI_TRD_FILTER_F32, RAPI_TRD_FILTER_F]. The default is  
RAPI_TRD_FILTER_F32.  
• Specifiable definition values when timer RD is used (RAPI_TIMER_RD specified)  
(Count source)  
Specify one from [RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M]. The default is  
RAPI_TRD_F1.  
Rev.1.01  
2007.02.16  
109  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Operating  
states set)  
(Interrupt)  
Specify one from [RAPI_TIMER_ON, RAPI_TIMER_OFF]. The default is  
RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
input capture A, input capture B, input capture C, or input capture D  
interrupt requests are enabled, specify RAPI_INPUT_CAPURE_A,  
RAPI_INPUT_CAPURE_B,  
RAPI_INPUT_CAPURE_C,  
or  
RAPI_INPUT_CAPURE_D, respectively. When not specifying interrupts,  
select “No interrupt requests.”  
(Counter clear)  
To specify GRA, GRB, GRC, or GRD input capture for the cause for  
which the counter is cleared, select RAPI_COUNT_CLEAR_A,  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively. If cleared at the same time a  
synchronously operating counter on another channel is cleared, select  
RAPI_COUNT_CLEAR_SYNC.  
(Synchronization If timers on channels  
0
and  
1
are to be synchronized, select  
)
RAPI_TIMER_SYNC. When not specifying synchronization, select  
“Channels 0 and 1 operate independently.”  
(Clock for digital Specify one from [RAPI_TRD_FILTER_F1, RAPI_TRD_FILTER_F8,  
filter)  
RAPI_TRD_FILTER_F32, RAPI_TRD_FILTER_F]. The default is  
RAPI_TRD_FILTER_F32.  
[data2]  
(M16C)  
Specify a pointer to the array in which the interrupt priority level is stored.  
[0]: Specify the IC/OC base timer interrupt priority level (07).  
[1]: Specify the IC/OC interrupt 0 priority level (07).  
[2]: Specify the IC/OC interrupt 1 priority level (07).  
(R8C)  
When timer RD is used (RAPI_TIMER_RD0 or RAPI_TIMERRD1 specified),  
specify a pointer to the variable that contains the interrupt priority level (07) to be  
set in the interrupt control register. When timer RD is not used, specify a pointer to  
the following array that contains the interrupt priority level  
[0]: Specify the timer C interrupt priority level (07).  
[1]: Specify the compare match 0 interrupt priority level (07).  
[2]: Specify the compare match 1 interrupt priority level (07).  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register. For  
the CPUs that do not have an interrupt control register, specify 0.  
[data3]  
(M16C)  
Specify a pointer to the array in which the set value for the time measurement  
control register is stored.  
[0]: Specify the set value for time measurement control register 0.  
[1]: Specify the set value for time measurement control register 1.  
Rev.1.01  
2007.02.16  
110  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[2]: Specify the set value for time measurement control register 2.  
[3]: Specify the set value for time measurement control register 3.  
[4]: Specify the set value for time measurement control register 4.  
[5]: Specify the set value for time measurement control register 5.  
[6]: Specify the set value for time measurement control register 6.  
[7]: Specify the set value for time measurement control register 7.  
For each element of the array, the following definition values can be set. To set  
multiple definition values at the same time, use the symbol “|” to separate each  
specified value.  
RAPI_IC_RISING  
RAPI_IC_FALLING  
RAPI_IC_BOTH  
Selects the rising edge of measurement pulse as active edge.  
Selects the falling edge of measurement pulse as active edge.  
Selects both rising and falling edges of measurement pulse as  
active edge.  
RAPI_FILTER_F1_F2  
RAPI_FILTER_FBT1  
RAPI_GATE  
Uses the digital filter facility that has a sampling frequency f1 or f2.  
Uses the digital filter facility that has a sampling frequency fBT1  
.
Uses a gate facility.  
RAPI_GATE_CLEAR  
Clears the gate facility upon a match of base timer and G1POk  
register.  
RAPI_PRESCALER  
Uses a prescaler facility.  
• Specifiable definition values for time measurement registers 07  
(Measurement Specify one from { RAPI_IC_RISING, RAPI_IC_FALLING,  
pulse)  
(Filter)  
RAPI_IC_BOTH }. If no measurement pulses are specified, the time  
measurement register is set to “No time measurement performed.”  
Specify one from { RAPI_FILTER_F1, RAPI_FILTER_FBT1 }. If no filters are  
specified, “No digital filter” is set.  
• Specifiable definition values for time measurement registers 67  
(Gate)  
To use the gate facility, specify RAPI_GATE. If RAPI_GATE is not specified,  
“No facility unused” is set. Make sure RAPI_GATE_CLEAR is specified at  
the same time RAPI_GATE is specified.  
(Prescaler)  
To use the prescaler facility, specify RAPI_PRESCALER. If  
RAPI_PRESCALER is not specified, “No prescaler facility” is set.  
(R8C)  
When using timer RD (RAPI_TIMER_RD0 to RAPI_TIMER_RD1 specified), set one of the  
following values. Otherwise, specify 0.  
Specify a pointer to the array in which each active edge setting is stored.  
[0]: Specify the active edge of TRDIOAi (i=0,1) pin.  
[1]: Specify the active edge of TRDIOBi (i=0,1) pin.  
[2]: Specify the active edge of TRDIOCi (i=0,1) pin.  
[3]: Specify the active edge of TRDIODi (i=0,1) pin.  
For each element of the array, one of [RAPI_TRD_RISING, RAPI_TRD_FALLING,  
RAPI_TRD_BOTH] can be set as the active edge of measured pulses.  
Furthermore, if the digital filter function is enabled, select RAPI_FILTER_ON.  
To set the f0C0128 signal for the TRDI0A0 pin on channel 0, specify RAPI_F0C0128. For the  
elements corresponding to unused channels, set 0.  
Rev.1.01  
2007.02.16  
111  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TRD_RISING  
Selects the rising edge of measurement pulse as active edge.  
RAPI_TRD_FALLING Selects the falling edge of measurement pulse as active edge.  
RAPI_TRD_BOTH  
RAPI_FILTER_ON  
RAPI_FOCO128  
Selects both rising and falling edges of measurement pulse as active  
edge.  
Selects digital filter on. If not select “RAPI_FILTER_ON”, “No digital  
filter” is set.  
Selects fOCO128 as TRDIOA0 pin input. Specifiable only active  
edge of channel0 TRDIOA0 pin.  
(H8/300H)  
Specify a pointer to the array in which each active edge setting is stored.  
[0]: Specify the active edge of TRDIOA pin.  
[1]: Specify the active edge of TRDIOB pin.  
[2]: Specify the active edge of TRDIOC pin.  
[3]: Specify the active edge of TRDIOD pin.  
For each element of the array, one of the following definition values  
{ RAPI_RISING, RAPI_FALLING, RAPI_BOTH } can be set.  
For the array elements corresponding to unused channels, set 0.  
RAPI_RISING  
RAPI_FALLING Selects the falling edge of measurement pulse as active edge.  
RAPI_BOTH Selects both rising and falling edges of measurement pulse as active edge.  
RAPI_FILTER_ Selects digital filter on. If not select “RAPI_FILTER_ON”, “No digital filter” is  
Selects the rising edge of measurement pulse as active edge.  
ON  
set.  
[data4]  
(M16C)  
Specify a pointer to the array in which the set value for each register or timer S is  
stored.  
[0]: Specify the set value for the facility select and facility enable registers.  
Specify the channel for which the time measurement facility is enabled.  
[1]: Specify the set value for interrupt enable register 0.  
Specify the channel for which IO/CO interrupt 0 request is enabled.  
[2]: Specify the set value for interrupt enable register 1.  
Specify the channel for which IO/CO interrupt 1 request is enabled.  
[3]: Specify the set value for the count source divide-by-N register.  
Specify the value of ‘n’ in the formula “count source divided by (n +1)” in 8 bits.  
[4]: Specify the set value for time measurement prescaler register 6.  
Specify the value of ‘n’ in the prescaler period “n + 1” in 8 bits.  
[5]: Specify the set value for time measurement prescaler register 7.  
Specify the value of ‘n’ in the prescaler period “n +1” in 8 bits.  
For the channels to be specified in each array element, use the following definition  
values. To specify multiple definition values at the same time, use the symbol “|” to  
separate each specified value. If 0 is specified, the value 0 is set in the  
corresponding register.  
RAPI_CHANNEL0  
Selects channel 0.  
Rev.1.01  
2007.02.16  
112  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_CHANNEL1  
RAPI_CHANNEL2  
RAPI_CHANNEL3  
RAPI_CHANNEL4  
RAPI_CHANNEL5  
RAPI_CHANNEL6  
RAPI_CHANNEL7  
(R8C) (H8/300H)  
Specify 0.  
Selects channel 1.  
Selects channel 2.  
Selects channel 3.  
Selects channel 4.  
Selects channel 5.  
Selects channel 6.  
Selects channel 7.  
[data5]  
(M16C)  
Specify a pointer to the array in which the callback function is stored.  
[0]: Specify a pointer to the callback function for IC/OC base timer interrupt. If this  
pointer is not specified, 0 is set.  
[1]: Specify a pointer to the callback function for IC/OC interrupt 0. If this pointer is  
not specified, 0 is set.  
[2]: Specify a pointer to the callback function for IC/OC interrupt 1. If this pointer is  
not specified, 0 is set.  
(R8C) (H8/300H)  
Specify a pointer to the array in which the callback function is stored. If this pointer  
is not specified, RAPI_NULL is set.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (input capture mode)  
__EnableInputCapture, __DestroyInputCapture, __GetInputCapture  
If an undefined value is specified in the first, third and fourth arguments, operation  
of the API cannot be guaranteed.  
The specifiable timers differ with each CPU used.  
When use CPU which has no digital filter function, cannot specify digital filter  
setting.  
When used for the H8/300H, this API specify when freeing it from module stanby  
state.  
Program example  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc( void ){}  
Rev.1.01  
2007.02.16  
113  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Set up timer C as imput capture mode */  
__CreateInputCapture(  
RAPI_TIMER_C|RAPI_TIMER_ON|RAPI_BOTH|RAPI_F32| RAPI_FRING128,  
5, TimerIntFunc);  
}
Rev.1.01  
2007.02.16  
114  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableInputCapture  
Synopsis  
<Control operation of input capture mode>  
Boolean __EnableInputCapture(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified input capture mode by starting or  
stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_S  
Selects timer S.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Sets the timer that is set to input capture mode to start operating.  
Sets the timer that is set to input capture mode to stop operating.  
(R8C)  
RAPI_TIMER_C  
Selects timer C.  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Selects timer RD0 channe 0.  
Selects timer RD0 channe 1.  
Sets the timer that is set to input capture mode to start operating.  
Sets the timer that is set to input capture mode to stop operating.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RD0.  
Selects timer RD0 channe 0.  
Selects timer RD0 channe 1.  
Selects timer RD0 channe 2.  
Selects timer RD0 channe 3.  
Sets the timer that is set to input capture mode to start operating.  
Sets the timer that is set to input capture mode to stop operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (input capture mode)  
CreateInputCapture, DestroyInputCapture, GetInputCapture  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
Rev.1.01  
2007.02.16  
115  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Enable timer C as input capture mode */  
__EnableInputCapture( RAPI_TIMER_C|RAPI_TIMER_ON );  
}
Rev.1.01  
2007.02.16  
116  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyInputCapture  
Synopsis  
<Discard settings of input capture mode>  
Boolean __DestroyInputCapture(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified input capture mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_S  
Selects timer S.  
(R8C)  
RAPI_TIMER_C  
Selects timer C.  
RAPI_TIMER_RD0 Selects timer RD0 channe 0.  
RAPI_TIMER_RD1 Selects timer RD0 channe 1.  
(H8/300H)  
RAPI_TIMER_W  
Selects timer W.  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RD0.  
RAPI_TIMER_RD0 Selects timer RD0 channe 0.  
RAPI_TIMER_RD1 Selects timer RD0 channe 1.  
RAPI_TIMER_RD2 Selects timer RD0 channe 2.  
RAPI_TIMER_RD3 Selects timer RD0 channe 3.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (input capture mode)  
__CreateInputCapture, __EnableInputCapture, __GetInputCapture  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_timer_r8c_13.h"  
Rev.1.01  
2007.02.16  
117  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Destroy the setting of timer C as input capture mode */  
__DestroyInputCapture( RAPI_TIMER_C );  
}
Rev.1.01  
2007.02.16  
118  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetInputCapture  
Synopsis  
<Get input capture mode counter value>  
Boolean __GetInputCapture(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Description  
Gets the counter value of the timer that is set to specified input capture mode.  
[data1]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_S  
Selects timer S.  
(R8C)  
RAPI_TIMER_C  
Selects timer C.  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
Selects timer RD0 channe 0.  
Selects timer RD0 channe 1.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RD0.  
Selects timer RD0 channe 0.  
Selects timer RD0 channe 1.  
Selects timer RD0 channe 2.  
Selects timer RD0 channe 3.  
[data2]  
(M16C)  
Specify a pointer to the array in which the acquired counter value is stored.  
[0]: Stores the value of base timer register 0.  
[1]: Stores the value of time measurement register 0.  
[2]: Stores the value of time measurement register 1.  
[3]: Stores the value of time measurement register 2.  
[4]: Stores the value of time measurement register 3.  
[5]: Stores the value of time measurement register 4.  
[6]: Stores the value of time measurement register 5.  
[7]: Stores the value of time measurement register 6.  
[8]: Stores the value of time measurement register 7.  
(R8C)  
Specify a pointer to the array in which the acquired counter value is stored.  
• When timer C is used (RAPI_TIMER_C specified)  
[0]: Stores the value of timer C counter.  
[1]: Stores the value of capture & compare 0 register.  
Rev.1.01  
2007.02.16  
119  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
• When timer RD is used (RAPI_TIMER_RD0- RAPI_TIMER_RD1 specified)  
[0]: Stores the value of timer counter.  
[1]: Stores the value of general register A.  
[2]: Stores the value of general register B.  
[3]: Stores the value of general register C.  
[4]: Stores the value of general register D.  
(H8/300H)  
[0]: Stores the value of the timer counter.  
[1]: Stores the value of general register A.  
[2]: Stores the value of general register B.  
[3]: Stores the value of general register C.  
[4]: Stores the value of general register D.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (input capture mode)  
__CreateInputCapture, __EnableInputCapture, __DestroyInputCapture  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
unsigned int data[2];  
/* Get the counter of timer C as input capture mode */  
__GetInputCapture( RAPI_TIMER_C, data );  
}
Rev.1.01  
2007.02.16  
120  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__CreateOutputCompare  
Synopsis  
<Set output compare mode>  
Boolean __CreateOutputCompare(unsigned long data1, unsigned int* data2,  
unsigned int* data3, unsigned int* data4, void** data5)  
data1  
data2  
data3  
data4  
data5  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
Setup data 5 (content differs with MCU type)  
Description  
Sets a specified timer to output compare mode.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_S  
RAPI_F1  
Uses timer S.  
Selects f1 for the count source.  
RAPI_F2  
Selects f2 for the count source.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Sets the timer to start operating in __CreateOutputCompare.  
Sets the timer to stop operating in __CreateOutputCompare.  
RAPI_OVERFLOW_BIT14 Selects overflow of bit 14 for the base timer interrupt.  
RAPI_OVERFLOW_BIT15 Selects overflow of bit 15 for the base timer interrupt.  
• Specifiable definition values when timer S is used (RAPI_TIMER_S specified)  
(Count source) Specify one from { RAPI_F1, RAPI_F2 }. The default value is RAPI_F2.  
(Operating  
states set)  
(Base timer)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
Specify one from { RAPI_OVERFLOW_BIT14, RAPI_OVERFLOW_BIT15 }.  
The default value is RAPI_OVERFLOW_BIT15.  
(R8C)  
RAPI_TIMER_C  
Uses timer C.  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RE  
RAPI_F1  
Uses timer RD0 channe 0.  
Uses timer RD0 channe 1.  
Uses timer C.  
Selects f1 for the count source.  
Selects f8 for the count source.  
Selects f32 for the count source.  
Selects fRING-fast for the count source.  
Selects f1 for the timer RD count source.  
Selects f2 for the timer RD count source.  
Selects f4 for the timer RD count source.  
Selects f8 for the timer RD count source.  
RAPI_F8  
RAPI_F32  
RAPI_FRING_FAST  
RAPI_TRD_F1  
RAPI_TRD_F2  
RAPI_TRD_F4  
RAPI_TRD_F8  
Rev.1.01  
2007.02.16  
121  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TRD_F32  
RAPI_TRD_F40M  
RAPI_TRE_F4  
RAPI_TRE_F8  
RAPI_TRE_F32  
RAPI_TRE_FC4  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_TIMER_OVERFLO  
W
Selects f32 for the timer RD count source.  
Selects fOCO40M for the timer RD count source.  
Selects f4 for the timer RE count source.  
Selects f8 for the timer RE count source.  
Selects f32 for the timer RE count source.  
Selects fC4 for the timer RE count source.  
Sets the timer to start operating in __CreateOutputCompare.  
Sets the timer to stop operating in __CreateOutputCompare.  
Enables the overflow interrupt.  
RAPI_COMPARE_MATCH Enables the comparematch interrupt.  
RAPI_COMPARE_MATCH Enables the GRA compare match interrupt.  
_A  
RAPI_COMPARE_MATCH Enables the GRB compare match interrupt.  
_B  
RAPI_COMPARE_MATCH Enables the GRC compare match interrupt.  
_C  
RAPI_COMPARE_MATCH Enables the GRD compare match interrupt.  
_D  
RAPI_COUNT_CLEAR_A  
RAPI_COUNT_CLEAR_B  
RAPI_COUNT_CLEAR_C  
RAPI_COUNT_CLEAR_D  
RAPI_COUNT_CLEAR_SYNC  
RAPI_TIMER_SYNC  
Specifies GRA compare match for the cause of counter clear.  
Specifies GRB compare match for the cause of counter clear.  
Specifies GRC compare match for the cause of counter clear.  
Specifies GRD compare match for the cause of counter clear.  
Clear counter in sync with the synchronized other timer counter  
Synchronize timer on channels 0 and 1.  
Disables CMP output from CMP00.  
RAPI_CMP00_DISABLE  
RAPI_CMP01_DISABLE  
RAPI_CMP02_DISABLE  
RAPI_CMP10_DISABLE  
RAPI_CMP11_DISABLE  
RAPI_CMP12_DISABLE  
RAPI_CMP00_ENABLE  
RAPI_CMP01_ENABLE  
RAPI_CMP02_ENABLE  
RAPI_CMP10_ENABLE  
RAPI_CMP11_ENABLE  
RAPI_CMP12_ENABLE  
RAPI_OUTPUT_  
Disables CMP output from CMP01.  
Disables CMP output from CMP02.  
Disables CMP output from CMP10.  
Disables CMP output from CMP11.  
Disables CMP output from CMP12.  
Enables CMP output from CMP00.  
Enables CMP output from CMP01.  
Enables CMP output from CMP02.  
Enables CMP output from CMP10.  
Enables CMP output from CMP11.  
Enables CMP output from CMP12.  
Inverts CMP output from CMP00 through CMP02.  
REVERSE_0  
RAPI_OUTPUT_  
Inverts CMP output from CMP10 through CMP12.  
REVERSE_1  
RAPI_RELOAD  
Sets TC register to “0x0000” when compare 1 matches.  
Rev.1.01  
2007.02.16  
122  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_UNCHANGE_0  
Leaves CMP0 output unchanged even when matched in  
compare 0.  
RAPI_REVERSE_0  
RAPI_L_0  
Inverts CMP0 output upon compare 0 match signal.  
Forces CMP0 output low upon compare 0 match signal.  
Forces CMP0 output high upon compare 0 match signal.  
Leaves CMP1 output unchanged even when matched in  
compare 1.  
RAPI_H_0  
RAPI_UNCHANGE_1  
RAPI_REVERSE_1  
RAPI_L_1  
Inverts CMP1 output upon compare 1 match signal.  
Forces CMP1 output low upon compare 1 match signal.  
Forces CMP1 output high upon compare 1 match signal.  
RAPI_H_1  
RAPI_OUTPUT_DISABLE Disable output.  
RAPI_OUTPUT_F2  
RAPI_OUTPUT_F4  
RAPI_OUTPUT_F8  
Specifies f2 output for output function.  
Specifies f4 output for output function.  
Specifies f8 output for output function.  
RAPI_OUTPUT_COMPAR Specifies compare output for output function.  
E
RAPI_4BIT_COUNTER  
Uses 4 bit counter.  
RAPI_COMPARE_MATCH Stop count when GRA compare match occur  
_A_STOP  
RAPI_STOP  
Stop count when clear TSTART bit.  
• Specifiable definition values when timer C is used (RAPI_TIMER_C specified)  
(Count source)  
Specify one from { RAPI_F1, RAPI_F8, RAPI_F32,  
RAPI_FRING_FAST }. The default value is RAPI_F1.  
(Operating states Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
set)  
value is RAPI_TIMER_OFF.  
(CMP00 output)  
Specify one from { RAPI_CMP00_DISABLE, RAPI_CMP00_ENABLE }.  
The default value is RAPI_CMP00_DISABLE.  
(CMP01 output)  
(CMP02 output)  
(CMP10 output)  
(CMP11 output)  
(CMP12 output)  
Specify one from { RAPI_CMP01_DISABLE, RAPI_CMP01_ENABLE }.  
The default value is RAPI_CMP01_DISABLE.  
Specify one from { RAPI_CMP02_DISABLE, RAPI_CMP02_ENABLE }.  
The default value is RAPI_CMP02_DISABLE.  
Specify one from { RAPI_CMP10_DISABLE, RAPI_CMP10_ENABLE }.  
The default value is RAPI_CMP10_DISABLE.  
Specify one from { RAPI_CMP11_DISABLE, RAPI_CMP11_ENABLE }.  
The default value is RAPI_CMP11_DISABLE.  
Specify one from { RAPI_CMP12_DISABLE, RAPI_CMP12_ENABLE }.  
The default value is RAPI_CMP12_DISABLE.  
(CMP0 output  
inversion)  
To invert CMP0 output, specify RAPI_OUTPUT_REVERSE_0. If  
RAPI_OUTPUT_REVERSE_0 is not specified, “CMP0 output not  
inverted” is set.  
(CMP1 output  
inversion)  
To invert CMP1 output, specify RAPI_OUTPUT_REVERSE_1. If  
RAPI_OUTPUT_REVERSE_1 is not specified, “CMP1 output not  
inverted” is set.  
Rev.1.01  
2007.02.16  
123  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(TC reload)  
To reload TC register, specify RAPID_RELOAD. If RAPID_RELOAD is  
not specified, “No reload” is set.  
(CMP0 output  
mode)  
Specify one from { RAPI_UNCHANGE_0, RAPI_REVERSE_0,  
RAPI_L_0, RAPI_H_0 }. The default value is RAPI_UNCHANGE_0.  
Specify one from { RAPI_UNCHANGE_1, RAPI_REVERSE_1,  
RAPI_L_1, RAPI_H_1 }. The default value is RAPI_UNCHANGE_1.  
(CMP1 output  
mode)  
• Specifiable definition values when timer RD is used (RAPI_TIMER_RD specified)  
(Count source)  
Specify one from [RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M]. The default is  
RAPI_TRD_F1.  
(Operating states Specify one from [RAPI_TIMER_ON, RAPI_TIMER_OFF]. The default  
set)  
is RAPI_TIMER_OFF  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW.  
If input capture A, input capture B, input capture C, or input capture D  
interrupt requests are enabled, specify RAPI_INPUT_CAPURE_A,  
RAPI_INPUT_CAPURE_B,  
RAPI_INPUT_CAPURE_C,  
or  
RAPI_INPUT_CAPURE_D, respectively. When not specifying  
interrupts, select “No interrupt requests.”  
(Counter clear)  
To specify GRA, GRB, GRC, or GRD input capture for the cause for  
which the counter is cleared, select RAPI_COUNT_CLEAR_A,  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively. If cleared at the same time a  
synchronously operating counter on another channel is cleared, select  
RAPI_COUNT_CLEAR_SYNC.  
(Synchronization)  
(count stop)  
If timers on channels 0 and 1 are to be synchronized, select  
RAPI_TIMER_SYNC. When not specifying synchronization, select  
“Channels 0 and 1 operate independently.”  
Specify one from [RAPI_COMPARE_MATCH_A_STOP, RAPI_STOP].  
The default is RAPI_STOP.  
• Specifiable definition values when timer RE is used (RAPI_TIMER_RE specified)  
(Count source)  
Specify one from [RAPI_TRE_F4, RAPI_TRE_F8, RAPI_TRE_F32,  
RAPI_TRD_FC4]. The default is RAPI_TRD_F1.  
(Operating states Specify one from [RAPI_TIMER_ON, RAPI_TIMER_OFF]. The default  
set)  
is RAPI_TIMER_OFF  
(Interrupt)  
If compare match interrupt requests are enabled, specify  
RAPI_COMPARE_MATCH. When not specifying interrupts, select “No  
interrupt requests.”  
(Output function)  
Specify one from [RAPI_OUTPUT_DISABLE, RAPI_OUTPUT_F2,  
RAPI_OUTPUT_F4, RAPI_OUTPUT_F8,  
RAPI_OUTPUT_COMPARE]. The default is  
RAPI_OUTPUT_COMPARE.  
(Counter)  
If use 4 bit counter, spcify RAPI_4BIT_COUNTER. The default is 8 bit  
counter .  
(H8/300H)  
Rev.1.01  
2007.02.16  
124  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
RAPI_TW_F1  
Uses timer W.  
Uses timer Z channel 0.  
Uses timer Z channel 1.  
Uses timer RC.  
Uses timer RD0 channel 0.  
Uses timer RD0 channel 1.  
Uses timer RD0 channel 2.  
Uses timer RD0 channel 3.  
Timer W counts with internal clock φ.  
Timer W counts with internal clock φ/2.  
Timer W counts with internal clock φ/4.  
Timer W counts with internal clock φ/8.  
Timer Z counts with internal clock φ.  
Timer Z counts with internal clock φ/2.  
Timer Z counts with internal clock φ/4.  
Timer Z counts with internal clock φ/8.  
Timer RC counts with internal clock φ.  
Timer RC counts with internal clock φ/2.  
Timer RC counts with internal clockφ/4.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ/8.  
Timer RC counts with internal clock φ40M.  
Timer RD counts with internal clock φ.  
Timer RD counts with internal clock φ/2.  
Timer RD counts with internal clockφ/4.  
Timer RD counts with internal clock φ/8.  
Timer RD counts with internal clock φ/32.  
Timer RD counts with internal clock φ40M.  
Sets the timer to start operating in __CreateOutputCompare.  
Sets the timer to stop operating in __CreateOutputCompare.  
Enables overflow interrupt.  
RAPI_TW_F2  
RAPI_TW_F4  
RAPI_TW_F8  
RAPI_TZ_F1  
RAPI_TZ_F2  
RAPI_TZ_F4  
RAPI_TZ_F8  
RAPI_TRC_F1  
RAPI_TRC_F2  
RAPI_TRC_F4  
RAPI_TRC_F8  
RAPI_TRC_F32  
RAPI_TRC_F40M  
RAPI_TRD_F1  
RAPI_TRD_F2  
RAPI_TRD_F4  
RAPI_TRD_F8  
RAPI_TRD_F32  
RAPI_TRD_F40M  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
RAPI_OVERFLOW  
RAPI_COMPARE_  
MATCH_A  
Enables GRA compare match interrupt.  
RAPI_COMPARE_  
MATCH_B  
Enables GRB compare match interrupt.  
Enables GRC compare match interrupt.  
Enables GRD compare match interrupt.  
RAPI_COMPARE_  
MATCH_C  
RAPI_COMPARE_  
MATCH_D  
RAPI_COUNT_CLEAR_A  
RAPI_COUNT_CLEAR_B  
RAPI_COUNT_CLEAR_C  
RAPI_COUNT_CLEAR_D  
Specifies GRA compare match for the cause of counter clear.  
Specifies GRB compare match for the cause of counter clear.  
Specifies GRC compare match for the cause of counter clear.  
Specifies GRD compare match for the cause of counter clear.  
Rev.1.01  
2007.02.16  
125  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_COUNT_CLEAR_S  
YNC  
Clear counter in sync with the synchronized other timer counter  
Synchronizes timer on channels 0 and 1.  
RAPI_TIMER_SYNC  
• Specifiable definition values when timer W is used (RAPI_TIMER_W specified)  
(Count source) Specify one from { RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4,  
RAPI_TW_F8 }. The default value is RAPI_TW_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW.  
Similarly, if compare match A, compare match B, compare match C, or  
compare match D interrupt requests are enabled, specify  
RAPI_COMPARE_ATCH_A, RAPI_COMPARE_ATCH_B,  
RAPI_COMPARE_ATCH_C, or RAPI_COMPARE_ATCH_D, respectively. If  
no interrupts are specified, “No interrupt request” is set.  
(Counter clear) To specify GRA compare match for the cause of counter clear, specify  
RAPI_COUNT_CLEAR_A.  
• Specifiable definition values when timer Z is used (RAPI_TIMER_Z0 to  
RAPI_TIMER_Z1 specified)  
(Count source)  
Specify one from { RAPI_TZ_F1, RAPI_TZ_F2, RAPI_TZ_F4,  
RAPI_TZ_F8 }. The default value is RAPI_TZ_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW.  
Similarly, if compare match A, compare match B, compare match C, or  
compare match D interrupt requests are enabled, specify  
RAPI_COMPARE_ATCH_A, RAPI_COMPARE_ATCH_B,  
RAPI_COMPARE_ATCH_C, or RAPI_COMPARE_ATCH_D,  
respectively. If no interrupts are specified, “No interrupt request” is set.  
To specify GRA, GRB, GRC, or GRD compare match for the cause of  
counter clear, specify RAPI_COUNT_CLEAR_A,  
(Counter clear)  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively.  
(Synchronization) If the timer is synchronized on channels 0 and 1, specify  
RAPI_TIMER_SYNC. If synchronization is not specified, “Channels 0 and  
1 operate independently” is set.  
• Specifiable definition values when timer RC is used (RAPI_TIMER_RC specified)  
(Count source)  
Specify one from [RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M]. The default is  
RAPI_TRD_F1.  
(Operating  
states set)  
Specify one from [RAPI_TIMER_ON, RAPI_TIMER_OFF]. The default is  
RAPI_TIMER_OFF.  
Rev.1.01  
2007.02.16  
126  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Interrupt)  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If  
compare match A, compare match B, compare match C, or compare  
match  
D
interrupt  
requests  
are  
enabled,  
specify  
RAPI_COMPARE_MATCH_A,  
RAPI_COMPARE_MATCH_C,  
RAPI_COMPARE_MATCH_B,  
RAPI_COMPARE_MATCH_D,  
or  
respectively. When not specifying interrupts, select “No interrupt  
requests.”  
(Counter clear)  
To specify GRA compare match for the cause of counter clear, specify  
RAPI_COUNT_CLEAR_A.  
• Specifiable definition values when timer RD is used (RAPI_TIMER_RD0 to  
RAPI_TIMER_RD4 specified)  
(Count source)  
Specify one from [RAPI_TRD_F1, RAPI_TRD_F2, RAPI_TRD_F4,  
RAPI_TRD_F8, RAPI_TRD_F32, RAPI_TRD_F40M]. The default is  
RAPI_TRD_F1.  
(Operating  
states set)  
(Interrupt)  
Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default  
value is RAPI_TIMER_OFF.  
If overflow interrupt requests are enabled, specify RAPI_OVERFLOW.  
Similarly, if compare match A, compare match B, compare match C, or  
compare match D interrupt requests are enabled, specify  
RAPI_COMPARE_MATCH_A, RAPI_COMPARE_MATCH_B,  
RAPI_COMPARE_MATCH_C, or RAPI_COMPARE_MATCH_D,  
respectively. If no interrupts are specified, “No interrupt request” is set.  
To specify GRA, GRB, GRC, or GRD compare match for the cause of  
counter clear, specify RAPI_COUNT_CLEAR_A,  
(Counter clear)  
RAPI_COUNT_CLEAR_B, RAPI_COUNT_CLEAR_C, or  
RAPI_COUNT_CLEAR_D, respectively.  
(Synchronization) If the timer is synchronized on channels 0 and 1, specify  
RAPI_TIMER_SYNC. If synchronization is not specified, “Channels 0 and  
1 operate independently” is set.  
[data2]  
(M16C)  
Specify a pointer to the array in which the interrupt priority level is stored.  
[0]: Specify the IC/OC base timer interrupt priority level (07).  
[1]: Specify the IC/OC interrupt 0 priority level (07).  
[2]: Specify the IC/OC interrupt 1 priority level (07).  
(R8C)  
Specify a pointer to the array in which the interrupt priority level is stored.  
[0]: Specify the timer C interrupt priority level (07).  
[1]: Specify the compare match 0 interrupt priority level (07).  
[2]: Specify the compare match 1 interrupt priority level (07).  
(H8/300H)  
Specify 0.  
[data3]  
Rev.1.01  
2007.02.16  
127  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(M16C)  
Specify a pointer to the array in which the set value for the waveform generation  
control register or waveform generation register is stored.  
[0]: Specify the set value for waveform generation control register 0.  
[1]: Specify the set value for waveform generation control register 1.  
[2]: Specify the set value for waveform generation control register 2.  
[3]: Specify the set value for waveform generation control register 3.  
[4]: Specify the set value for waveform generation control register 4.  
[5]: Specify the set value for waveform generation control register 5.  
[6]: Specify the set value for waveform generation control register 6.  
[7]: Specify the set value for waveform generation control register 7.  
[8]: Specify the set value for waveform generation register 0 in 16 bits.  
Specify the comparison value of channel 0 in 16 bits.  
[9]: Specify the set value for waveform generation register 1 in 16 bits.  
Specify the comparison value of channel 1 in 16 bits.  
[10]: Specify the set value for waveform generation register 2 in 16 bits.  
Specify the comparison value of channel 2 in 16 bits.  
[11]: Specify the set value for waveform generation register 3 in 16 bits.  
Specify the comparison value of channel 3 in 16 bits.  
[12]: Specify the set value for waveform generation register 4 in 16 bits.  
Specify the comparison value of channel 4 in 16 bits.  
[13]: Specify the set value for waveform generation register 5 in 16 bits.  
Specify the comparison value of channel 5 in 16 bits.  
[14]: Specify the set value for waveform generation register 6 in 16 bits.  
Specify the comparison value of channel 6 in 16 bits.  
[15]: Specify the set value for waveform generation register 7 in 16 bits.  
Specify the comparison value of channel 7 in 16 bits.  
To specify the set value for each waveform generation control register that is an  
array element, the following definition values can be set. To specify multiple  
definition values at the same time, use the symbol “|” to separate each specified  
value.  
RAPI_SINGLE  
Selects single-phase waveform output mode.  
Selects SR waveform output mode.  
Selects inverted waveform output mode.  
Outputs a 0 as the initial output value.  
Outputs a 1 as the initial output value.  
Uses an output inversion facility.  
RAPI_SR  
RAPI_PHASE_DELAYED  
RAPI_OUT_INIT_0  
RAPI_OUT_INIT_1  
RAPI_OUTPUT_  
REVERSED  
RAPI_RELOAD_WITH_  
RESET  
Selects a reset of the base timer as the timing with which the  
G1P0J register value is reloaded.  
RAPI_RELOAD_WITH_  
WRITE  
Selects a write to the base timer as the timing with which the  
G1P0J register value is reloaded.  
• Specifiable definition values for waveform generation control registers 07  
Rev.1.01  
2007.02.16  
128  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Output mode) Specify one from { RAPI_SINGLE, RAPI_SR, RAPI_PHASE_DELAYED }.  
The default value is RAPI_SINGLE.  
(Initial output  
value)  
Specify one from { RAPI_OUT_INIT_0, RAPI_OUT_INIT_1 }. The default  
value is RAPI_OUT_INIT_0.  
(Output  
To invert the output, specify RAPI_OUTPUT_REVERSED. If output  
inversion is not specified, “Output not inverted” is set.  
Specify one from { RAPI_RELOAD_WITH_RESET,  
RAPI_RELOAD_WITH_WRITE }.  
inversion)  
(Reload)  
The default value is RAPI_RELOAD_WITH_WRITE.  
(R8C)  
• When timer C is used (RAPI_TIMER_C specified)  
Specify a pointer to the array in which the comparison value is stored.  
[0]: Specify comparison value 0 in 16 bits.  
[1]: Specify comparison value 1 in 16 bits.  
• When timer RD is used (RAPI_TIMER_RD0 to RAPI_TIMER_RD4 specified)  
Specify a pointer to the array in which the comparison value is stored.  
[0]: Specify the output operation of TRDIOAi (i=0,1).  
[1]: Specify the output operation of TRDIOBi (i=0,1).  
[2]: Specify the output operation of TRDIOCi (i=0,1).  
[3]: Specify the output operation of TRDIODi (i=0,1).  
[4]: Specify the comparison value of general register A in 16 bits.  
[5]: Specify the comparison value of general register B in 16 bits.  
[6]: Specify the comparison value of general register C in 16 bits.  
[7]: Specify the comparison value of general register D in 16 bits.  
To specify output operation for each output compare of array elements, the following definition  
values can be used. To specify multiple definition values at the same time, use the symbol “|”  
to separate each specified value. For elements of output operation corresponding to unused  
channels, set 0.  
RAPI_OUT_0  
Selects 0 output for the output waveform.  
Selects 1 output for the output waveform.  
Selects toggle output for the output waveform.  
Selects 0 output for the initial output.  
RAPI_OUT_1  
RAPI_OUT_TOGGLE  
RAPI_OUT_INIT_0  
RAPI_OUT_INIT_1  
Selects 1 output for the initial output.  
• When timer RE is used (RAPI_TIMER_RE specified)  
Specify a pointer to the array in which the comparison value is stored.  
Specify comparison value of timer RE compare data register in 8 bits.  
(H8/300H)  
Specify a pointer to the array in which the comparison value is stored.  
[0]: Specify the output operation of FTIOA pin.  
[1]: Specify the output operation of FTIOB pin.  
[2]: Specify the output operation of FTIOC pin.  
[3]: Specify the output operation of FTIOD pin.  
[4]: Specify the comparison value of general register A in 16 bits.  
[5]: Specify the comparison value of general register B in 16 bits.  
Rev.1.01  
2007.02.16  
129  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[6]: Specify the comparison value of general register C in 16 bits.  
[7]: Specify the comparison value of general register D in 16 bits.  
To specify output operation for each output compare of array elements, the following definition  
values can be used. To specify multiple definition values at the same time, use the symbol “|”  
to separate each specified value. For elements of output operation corresponding to unused  
channels, set 0.  
RAPI_OUT_0  
Selects 0 output for the output waveform.  
Selects 1 output for the output waveform.  
Selects toggle output for the output waveform.  
Selects 0 output for the initial output.  
RAPI_OUT_1  
RAPI_OUT_TOGGLE  
RAPI_OUT_INIT_0  
RAPI_OUT_INIT_1  
Selects 1 output for the initial output.  
[data4]  
(M16C)  
Specify a pointer to the array in which the set value for each register of timer S is  
stored.  
[0]: Specify the set value for the facility select and facility enable register.  
Specify the channel for which the waveform generation facility is enabled.  
[1]: Specify the set value for interrupt enable register 0.  
Specify the channel for which IO/CO interrupt 0 request is enabled.  
[2]: Specify the set value for interrupt enable register 1.  
Specify the channel for which IO/CO interrupt 1 request is enabled.  
[3]: Specify the set value for the count source divide-by-n register. Specify the value  
of ‘n’ in the formula “count source divided by (n + 1)” in 8 bits.  
For the channels to be specified in each array element, use the following definition  
values. To specify multiple definition values at the same time, use the symbol “|” to  
separate each specified value. If 0 is specified, the value 0 is set in the  
corresponding register.  
RAPI_CHANNEL0  
RAPI_CHANNEL1  
RAPI_CHANNEL2  
RAPI_CHANNEL3  
RAPI_CHANNEL4  
RAPI_CHANNEL5  
RAPI_CHANNEL6  
RAPI_CHANNEL7  
(R8C) (H8/300H)  
Specify 0.  
Selects channel 0.  
Selects channel 1.  
Selects channel 2.  
Selects channel 3.  
Selects channel 4.  
Selects channel 5.  
Selects channel 6.  
Selects channel 7.  
[data5]  
(M16C)  
Specify a pointer to the array in which the callback function is stored.  
[0]: Specify a pointer to the callback function for IC/OC base timer interrupt.  
If this pointer is not specified, 0 is set.  
Rev.1.01  
2007.02.16  
130  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[1]: Specify a pointer to the callback function for IC/OC interrupt 0.  
If this pointer is not specified, 0 is set.  
[2]: Specify a pointer to the callback function for IC/OC interrupt 1.  
If this pointer is not specified, 0 is set.  
(R8C)  
• When timer C is used (RAPI_TIMER_C specified)  
Specify a pointer to the array in which the callback function is stored.  
[0]: Specify a pointer to the callback function for timer C interrupt.  
If this pointer is not specified, 0 is set.  
[1]: Specify a pointer to the callback function for compare match interrupt 0.  
If this pointer is not specified, 0 is set.  
[2]: Specify a pointer to the callback function for compare match interrupt 1.  
If this pointer is not specified, 0 is set.  
• When timer RD is used (RAPI_TIMER_RD0 to RAPI_TIMER_RD4 specified)  
Specify a pointer to the array in which the callback function is stored.  
If this pointer is not specified, RAPI_NULL is set.  
• When timer RE is used (RAPI_TIMER_RE specified)  
Specify a pointer to the array in which the callback function is stored.  
If this pointer is not specified, RAPI_NULL is set.  
(H8/300H)  
Specify a pointer to the variable in which the callback function is stored. If this  
pointer is not specified, RAPI_NULL is set.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (output compare mode)  
__EnableOutputCompare, __DestroyOutputCompare  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
If when using the H8/300H an undefined value is specified in the second argument,  
program operation cannot be guaranteed.  
If when using the M16C an undefined value is specified for any waveform  
generation control register in the third argument, operation of the API cannot be  
guaranteed.  
If when using the H8/300H an undefined value is specified for the output operation  
of any channel in the third argument, operation of the API cannot be guaranteed.  
If when using the M16C or the H8/300H an undefined value is specified in the  
fourth argument, operation of the API cannot be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
Rev.1.01  
2007.02.16  
131  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
#include "rapi_timer_r8c_13.h"  
void TimerIntFunc0( void ){}  
void TimerIntFunc1( void ){}  
void TimerIntFunc2( void ){}  
void func( void )  
{
unsignedint*p_func[]= {(void*)TimerIntFunc0,(void*)TimerIntFunc1,  
(void*) TimerIntFunc2};  
unsigned char p_ic[] = {1,2,3};  
unsigned int p_cmp[] = {0x1234, 0x9876};  
/* Set up timer C as output compare mode */  
__CreateOutputCompare(  
RAPI_TIMER_C|RAPI_TIMER_ON|RAPI_RELOAD|RAPI_L_1|RAPI_L_0|RAPI_F32|  
RAPI_CMP02_ENABLE|RAPI_CMP12_ENABLE, p_cmp, p_ic, p_func );  
}
Rev.1.01  
2007.02.16  
132  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableOutputCompare  
Synopsis  
<Control operation of output compare mode>  
Boolean __EnableOutputCompare(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of the timer that is set to specified output compare mode by starting  
or stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_S  
Selects timer S.  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Sets the timer that is set to output compare mode to start operating.  
Sets the timer that is set to output compare mode to stop operating.  
(R8C)  
RAPI_TIMER_C  
Selects timer C.  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RE  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RE.  
Sets the timer that is set to output compare mode to start operating.  
Sets the timer that is set to output compare mode to stop operating.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RD0.  
Selects timer RD0 channe 0.  
Selects timer RD0 channe 1.  
Selects timer RD0 channe 2.  
Selects timer RD0 channe 3.  
Sets the timer that is set to output compare mode to start operating.  
Sets the timer that is set to output compare mode to stop operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (output compare mode)  
__CreateOutputCompare, __DestroyOutputCompare  
If an undefined value is specified in the argument, operation of the API cannot be  
Rev.1.01  
2007.02.16  
133  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include "rapi_timer_r8c_13.h"  
void func( void )  
{
/* Enable timer C as output compare mode */  
__EnableOutputCompare( RAPI_TIMER_C|RAPI_TIMER_ON );  
}
Rev.1.01  
2007.02.16  
134  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyOutputCompare  
Synopsis  
<Discard settings of output compare mode>  
Boolean __DestroyOutputCompare(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Discards settings of the timer that is set to specified output compare mode.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_S  
Selects timer S.  
(R8C)  
RAPI_TIMER_C  
Selects timer C.  
RAPI_TIMER_RD0 Selects timer RD channel 0.  
RAPI_TIMER_RD1 Selects timer RD channel 1.  
RAPI_TIMER_RE  
Selects timer RE.  
(H8/300H)  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RD0.  
RAPI_TIMER_RD0 Selects timer RD0 channe 0.  
RAPI_TIMER_RD1 Selects timer RD0 channe 1.  
RAPI_TIMER_RD2 Selects timer RD0 channe 2.  
RAPI_TIMER_RD3 Selects timer RD0 channe 3.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (output compare mode)  
__CreateOutputCompare, __EnableOutputCompare  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_timer_r8c_13.h"  
Rev.1.01  
2007.02.16  
135  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Destroy the setting of timer C as output compare mode */  
__DestroyOutputCompare( RAPI_TIMER_C );  
}
Rev.1.01  
2007.02.16  
136  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__SetTimerRegister  
Synopsis  
<Set timer register>  
Boolean __SetTimerRegister(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the buffer in which register value is stored  
Description  
Sets the registers of a specified timer.  
[data1]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_S  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Selects timer S.  
(R8C)  
RAPI_TIMER_C  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RE  
Selects timer C.  
Selects timer X.  
Selects timer Y.  
Selects timer Z.  
Selects timer RA.  
Selects timer RB.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RE.  
(H8/300H)  
RAPI_TIMER_A  
RAPI_TIMER_B1  
RAPI_TIMER_V  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
Selects timer A.  
Selects timer B1.  
Selects timer V.  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
Rev.1.01  
2007.02.16  
137  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[data2]  
The content of a pointer to the buffer in which the register value is stored must be specified  
as described below. The value is set in each register in order of buffer pointer elements.  
(M16C)  
• When using timer A (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified)  
[0]: Specify the set value for the timer Ai mode register (i = 0–4).  
[1]: Specify the set value for the timer Ai register (i = 0–4).  
[2]: Specify the set value for the up/down flag register.  
[3]: Specify the set value for the one-shot start flag register.  
[4]: Specify the set value for the trigger select register.  
[5]: Specify the set value for the time-clock prescaler reset register.  
[6]: Specify the set value for the count start flag register.  
• When using timer B (RAPI_TIMER_B0 to RAPI_TIMER_B2)  
[0]: Specify the set value for the timer Bi mode register (i = 0–2).  
[1]: Specify the set value for the timer Bi register (i = 0–2).  
[3]: Specify the set value for the time-clock prescaler reset register.  
[4]: Specify the set value for the count start flag register.  
• When using timer S (RAPI_TIMER_S specified)  
[0]: Specify the set value for the base timer register.  
[1]: Specify the set value for the base timer reset register.  
[2]: Specify the set value for base timer control register 0.  
[3]: Specify the set value for base timer control register 1.  
[4]: Specify the set value for the count source divide-by-n register.  
[5]: Specify the set value for time measurement control register 0.  
[6]: Specify the set value for time measurement control register 1.  
[7]: Specify the set value for time measurement control register 2.  
[8]: Specify the set value for time measurement control register 3.  
[9]: Specify the set value for time measurement control register 4.  
[10]: Specify the set value for time measurement control register 5.  
[11]: Specify the set value for time measurement control register 6.  
[12]: Specify the set value for time measurement control register 7.  
[13]: Specify the set value for time measurement prescaler register 6.  
[14]: Specify the set value for time measurement prescaler register 7.  
[15]: Specify the set value for waveform generation control register 0.  
[16]: Specify the set value for waveform generation control register 1.  
[17]: Specify the set value for waveform generation control register 2.  
[18]: Specify the set value for waveform generation control register 3.  
[19]: Specify the set value for waveform generation control register 4.  
[20]: Specify the set value for waveform generation control register 5.  
[21]: Specify the set value for waveform generation control register 6.  
[22]: Specify the set value for waveform generation control register 7.  
[23]: Specify the set value for waveform generation register 0.  
[24]: Specify the set value for waveform generation register 1.  
[25]: Specify the set value for waveform generation register 2.  
[26]: Specify the set value for waveform generation register 3.  
Rev.1.01  
2007.02.16  
138  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[27]: Specify the set value for waveform generation register 4.  
[28]: Specify the set value for waveform generation register 5.  
[29]: Specify the set value for waveform generation register 6.  
[30]: Specify the set value for waveform generation register 7.  
[31]: Specify the set value for the facility select register.  
[32]: Specify the set value for the facility enable register.  
[33]: Specify the set value for the interrupt request register.  
[34]: Specify the set value for interrupt enable register 0.  
[35]: Specify the set value for interrupt enable register 1.  
(R8C)  
• When using timer C (RAPI_TIMER_C specified)  
[0]: Specify the set value for the timer C output control register.  
[1]: Specify the set value for timer C control register 0.  
[2]: Specify the set value for timer C control register 1.  
[3]: Specify the set value for the capture & compare 0 register.  
[4]: Specify the set value for the compare 1 register.  
• When using timer X (RAPI_TIMER_X specified)  
[0]: Specify the set value for the timer count source setup register.  
[1]: Specify the set value for the prescaler X register.  
[2]: Specify the set value for the timer X register.  
[3]: Specify the set value for the timer X mode register.  
• When using timer Y (RAPI_TIMER_Y specified)  
[0]: Specify the set value for the timer count source setup register.  
[1]: Specify the set value for the prescaler Y register.  
[2]: Specify the set value for the timer Y primary register.  
[3]: Specify the set value for the timer Y secondary register.  
[4]: Specify the set value for the timer Y & Z waveform output control register.  
[5]: Specify the set value for the timer Y & Z output control register.  
[6]: Specify the set value for the timer Y & Z mode register.  
• When using timer Z (RAPI_TIMER_Z specified)  
[0]: Specify the set value for the timer count source setup register.  
[1]: Specify the set value for the prescaler Z register.  
[2]: Specify the set value for the timer Z primary register.  
[3]: Specify the set value for the timer Z secondary register.  
[4]: Specify the set value for the timer Y & Z waveform output control register.  
[5]: Specify the set value for the timer Y & Z output control register.  
[6]: Specify the set value for the timer Y & Z mode register.  
• When using timer RA (RAPI_TIMER_RA specified)  
[0]: Specify the set value for the timer RA I/O control register.  
[1]: Specify the set value for the timer RA prescaler register.  
[2]: Specify the set value for the timer RA register.  
[3]: Specify the set value for the timer RA mode register.  
[4]: Specify the set value for the timer RA control register.  
• When using timer RB (RAPI_TIMER_RB specified)  
[0]: Specify the set value for the timer RB one shot control register.  
Rev.1.01  
2007.02.16  
139  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[1]: Specify the set value for the timer RB I/O control register.  
[2]: Specify the set value for the timer RB prescaler register.  
[3]: Specify the set value for the timer RB primary register.  
[4]: Specify the set value for the timer RB secondary register.  
[5]: Specify the set value for the timer RB mode register.  
[6]: Specify the set value for the timer RB control register.  
• When using timer RD (RAPI_TIMER_RD0 to RAPI_TIMER_RD1)  
[0]: Specify the set value for the timer RD mode register.  
[1]: Specify the set value for the timer RD PWM mode register.  
[2]: Specify the set value for the timer RD function control register.  
[3]: Specify the set value for the timer RD general register Ai (i=0,1).  
[4]: Specify the set value for the timer RD general register Bi (i=0,1).  
[5]: Specify the set value for the timer RD general register Ci (i=0,1).  
[6]: Specify the set value for the timer RD general register Di (i=0,1).  
[7]: Specify the set value for the timer RD digital filter function select register  
i(i=0,1).  
[8]: Specify the set value for the timer RD control register i(i=0,1).  
[9]: Specify the set value for the timer RD I/O control register Ai(i=0,1).  
[10]: Specify the set value for the timer RD I/O control register Ci(i=0,1).  
[11]: Specify the set value for the timer RD status register i(i=0,1).  
[12]: Specify the set value for the timer RD interrupt enable register i(i=0,1).  
[13]: Specify the set value for the timer RD counter i(i=0,1).  
[14]: Specify the set value for the timer RD start register.  
[15]: Specify the set value for the timer RD output master enable register 1.  
[16]: Specify the set value for the timer RD output master enable register 2.  
[17]: Specify the set value for the timer RD output control register.  
• When using timer RE (RAPI_TIMER_RE)  
[0]: Specify the set value for the timer RE second data register.  
[1]: Specify the set value for the timer RE minute data register.  
[2]: Specify the set value for the timer RE hour data register.  
[3]: Specify the set value for the timer RE day of week data register.  
[4]: Specify the set value for the timer RE control register 2.  
[5]: Specify the set value for the timer RE count source select register.  
[6]: Specify the set value for the timer RE control register 1.  
(H8/300H)  
• When using timer A (RAPI_TIMER_A specified)  
[0]: Specify the set value for timer mode register A.  
[1]: Specify the set value for timer counter A.  
• When using timer B1 (RAPI_TIMER_B1 specified)  
[0]: Specify the set value for timer mode register B1.  
[1]: Specify the set value for timer load register B1.  
• When using timer V (RAPI_TIMER_V specified)  
[0]: Specify the set value for timer counter V.  
[1]: Specify the set value for time constant register A.  
[2]: Specify the set value for time constant register B.  
Rev.1.01  
2007.02.16  
140  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[3]: Specify the set value for timer control register V0.  
[4]: Specify the set value for timer control register V1.  
[5]: Specify the set value for timer control/status register V.  
• When using timer W (RAPI_TIMER_W specified)  
[0]: Specify the set value for timer control register W.  
[1]: Specify the set value for timer interrupt enable register W.  
[2]: Specify the set value for timer status register W.  
[3]: Specify the set value for timer I/O control register 0.  
[4]: Specify the set value for timer I/O control register 1.  
[5]: Specify the set value for the timer counter.  
[6]: Specify the set value for general register A.  
[7]: Specify the set value for general register B.  
[8]: Specify the set value for general register C.  
[9]: Specify the set value for general register D.  
[10]: Specify the set value for the timer mode register W.  
• When using timer Z (RAPI_TIMER_Z0 to RAPI_TIMER_Z1 specified)  
[0]: Specify the set value for the timer mode register.  
[1]: Specify the set value for the timer PWM mode register.  
[2]: Specify the set value for the timer function control register.  
[3]: Specify the set value for the timer output master enable register.  
[4]: Specify the set value for the timer output control register.  
[5]: Specify the set value for the timer counter.  
[6]: Specify the set value for general register A i(i=0,1).  
[7]: Specify the set value for general register B i(i=0,1).  
[8]: Specify the set value for general register C i(i=0,1).  
[9]: Specify the set value for general register D i(i=0,1).  
[10]: Specify the set value for timer control register_i (i = 0, 1).  
[11]: Specify the set value for timer I/O control register A_i (i = 0, 1).  
[12]: Specify the set value for timer I/O control register C_i (i = 0, 1).  
[13]: Specify the set value for timer status register_i (i = 0, 1).  
[14]: Specify the set value for timer interrupt enable register_i (i = 0, 1).  
[15]: Specify the set value for PWM mode output level control register_i (i = 0, 1).  
[16]: Specify the set value for the timer start register.  
• When using timer RC (RAPI_TIMER_RC)  
[0]: Specify the set value for timer RC control register 1.  
[1]: Specify the set value for timer RC control register 2.  
[2]: Specify the set value for timer RC interrupt enable register.  
[3]: Specify the set value for timer RC status register.  
[4]: Specify the set value for timer RC I/O control register 0.  
[5]: Specify the set value for timer RC I/O control register 1.  
[6]: Specify the set value for timer RC output enable register.  
[7]: Specify the set value for timer RC digital filter function select register.  
[8]: Specify the set value for timer RC counter.  
[9]: Specify the set value for general register A.  
[10]: Specify the set value for general register B.  
Rev.1.01  
2007.02.16  
141  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[11]: Specify the set value for general register C.  
[12]: Specify the set value for general register D.  
[13]: Specify the set value for timer RC mode register.  
• When using timer RD (RAPI_TIMER_RD0 to RAPI_TIMER_RD3 specified)  
[0]: Specify the set value for the timer RD mode register.  
[1]: Specify the set value for the timer RD PWM mode register.  
[2]: Specify the set value for the timer RD function control register.  
[3]: Specify the set value for the timer RD output master enable register 1.  
[4]: Specify the set value for the timer RD output master enable register 2.  
[5]: Specify the set value for the timer RD output control register.  
[6]: Specify the set value for the timer RD counter i(i=0,1).  
[7]: Specify the set value for general register A_i(i=0,1).  
[8]: Specify the set value for general register B_i(i=0,1).  
[9]: Specify the set value for general register C_i(i=0,1).  
[10]: Specify the set value for general register D_i(i=0,1).  
[11]: Specify the set value for timer RD control register_i (i = 0, 1).  
[12]: Specify the set value for timer RD I/O control register A_i (i = 0, 1).  
[13]: Specify the set value for timer RD I/O control register C_i (i = 0, 1).  
[14]: Specify the set value for timer RD status register_i (i = 0, 1).  
[15]: Specify the set value for timer RD interrupt enable register_i (i = 0, 1).  
[16]: Specify the set value for PWM mode output level control register_i (i = 0, 1).  
[17]: Specify the set value for the timer RD digital filter function select register i(i = 0,  
1).  
[18]: Specify the set value for the timer RD start register.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (register manipulation)  
__EnableTimerRegister, __ClearTimerRegister, __GetTimerRegister  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include " rapi_timer_r8c_13.h"  
void func( void )  
{
unsigned char data[] = {0,0,0,0,0,0,0};  
/* Set up timer Z register */  
__SetTimerRegister( RAPI_TIMER_Z, data );  
}
Rev.1.01  
2007.02.16  
142  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableTimerRegister  
Synopsis  
<Control operation of timer register>  
Boolean __EnableTimerRegister(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Controls operation of a specified timer by starting or stopping it.  
[data]  
For data, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_S  
RAPI_TIMER_ON  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Selects timer S.  
Sets the selected timer to start operating.  
RAPI_TIMER_OFF Sets the selected timer to stop operating.  
(R8C)  
RAPI_TIMER_C  
Selects timer C.  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
Selects timer X.  
Selects timer Y.  
Selects timer Z.  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RE  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Selects timer RA.  
Selects timer RB.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RE.  
Sets the selected timer to start operating.  
Sets the selected timer to stop operating.  
(H8/300H)  
RAPI_TIMER_V  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
Selects timer V.  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Rev.1.01  
2007.02.16  
143  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
RAPI_TIMER_ON  
RAPI_TIMER_OFF  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
Sets the selected timer to start operating.  
Sets the selected timer to stop operating.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (register manipulation)  
__SetTimerRegister, __ClearTimerRegister, __GetTimerRegister  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
To specify commencement of timer operation when using timer V of the H8/300H, set the  
clock and count condition to be supplied to TCNTV that are specified in __SetTimerRegister  
immediately preceding this API.  
Program example  
#include " rapi_timer_r8c_13.h"  
void func( void )  
{
/* Activate timer C */  
__EnableTimerRegister( RAPI_TIMER_C|RAPI_TIMER_ON );  
}
Rev.1.01  
2007.02.16  
144  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__ClearTimerRegister  
Synopsis  
<Clear timer register>  
Boolean __ClearTimerRegister(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Sets the timer register of a specified timer to its initial value after reset.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_S  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Selects timer S.  
(R8C)  
RAPI_TIMER_C  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RE  
Selects timer C.  
Selects timer X.  
Selects timer Y.  
Selects timer Z.  
Selects timer RA.  
Selects timer RB.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RE.  
(H8/300H)  
RAPI_TIMER_A  
Selects timer A.  
RAPI_TIMER_B1  
RAPI_TIMER_V  
Selects timer B1.  
Selects timer V.  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
Rev.1.01  
2007.02.16  
145  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
Timer (register manipulation)  
__SetTimerRegister, __EnableTimerRegister, __GetTimerRegister  
If an undefined value is specified in the argument, operation of the API cannot be  
guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include " rapi_timer_r8c_13.h"  
void func( void )  
{
/* Clear the setting of timer C */  
__ClearTimerRegister( RAPI_TIMER_C );  
}
Rev.1.01  
2007.02.16  
146  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetTimerRegister  
Synopsis  
<Get timer register value>  
Boolean __GetTimerRegister(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data (content differs with MCU type)  
Pointer to the buffer in which register value is stored  
Description  
Gets the counter value of a specified timer.  
[data]  
For data, the following definition values can be set.  
(M16C)  
RAPI_TIMER_A0  
RAPI_TIMER_A1  
RAPI_TIMER_A2  
RAPI_TIMER_A3  
RAPI_TIMER_A4  
RAPI_TIMER_B0  
RAPI_TIMER_B1  
RAPI_TIMER_B2  
RAPI_TIMER_S  
Selects timer A channel 0.  
Selects timer A channel 1.  
Selects timer A channel 2.  
Selects timer A channel 3.  
Selects timer A channel 4.  
Selects timer B channel 0.  
Selects timer B channel 1.  
Selects timer B channel 2.  
Selects timer S.  
(R8C)  
RAPI_TIMER_C  
RAPI_TIMER_X  
RAPI_TIMER_Y  
RAPI_TIMER_Z  
RAPI_TIMER_RA  
RAPI_TIMER_RB  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RE  
Selects timer C.  
Selects timer X.  
Selects timer Y.  
Selects timer Z.  
Selects timer RA.  
Selects timer RB.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RE.  
(H8/300H)  
RAPI_TIMER_A  
Selects timer A.  
RAPI_TIMER_B1  
RAPI_TIMER_V  
Selects timer B1.  
Selects timer V.  
RAPI_TIMER_W  
RAPI_TIMER_Z0  
RAPI_TIMER_Z1  
RAPI_TIMER_RC  
RAPI_TIMER_RD0  
RAPI_TIMER_RD1  
RAPI_TIMER_RD2  
RAPI_TIMER_RD3  
Selects timer W.  
Selects timer Z channel 0.  
Selects timer Z channel 1.  
Selects timer RC.  
Selects timer RD channel 0.  
Selects timer RD channel 1.  
Selects timer RD channel 2.  
Selects timer RD channel 3.  
Rev.1.01  
2007.02.16  
147  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[data2]  
Specify a pointer to the array in which the acquired register value is stored.  
The content of the array is described below.  
(M16C)  
When using timer A (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified)  
[0]: Store the value of timer Ai mode register (i = 0–4).  
[1]: Store the value of timer Ai register (i = 0–4).  
[2]: Store the value of the up/down flag register.  
[3]: Store the value of the one-shot start flag register.  
[4]: Store the value of the trigger select register.  
[5]: Store the value of the time-clock prescaler reset flag register.  
[6]: Store the value of the count start flag register.  
When using timer B (RAPI_TIMER_B0 to RAPI_TIMER_B2 specified)  
[0]: Store the value of timer Bi mode register (i = 0–2).  
[1]: Store the value of timer Bi register (i = 0–2).  
[2]: Store the value of the time-clock prescaler reset flag register.  
[3]: Store the value of the count start flag register.  
When using timer S (RAPI_TIMER_S specified)  
[0]: Store the value of the base timer register.  
[1]: Store the value of the base timer reset register.  
[2]: Store the value of base timer control register 0.  
[3]: Store the value of base timer control register 1.  
[4]: Store the value of the count source divide-by-n register.  
[5]: Store the value of time measurement control register 0.  
[6]: Store the value of time measurement control register 1.  
[7]: Store the value of time measurement control register 2.  
[8]: Store the value of time measurement control register 3.  
[9]: Store the value of time measurement control register 4.  
[10]: Store the value of time measurement control register 5.  
[11]: Store the value of time measurement control register 6.  
[12]: Store the value of time measurement control register 7.  
[13]: Store the value of time measurement prescaler register 6.  
[14]: Store the value of time measurement prescaler register 7.  
[15]: Store the value of waveform generation control register 0.  
[16]: Store the value of waveform generation control register 1.  
[17]: Store the value of waveform generation control register 2.  
[18]: Store the value of waveform generation control register 3.  
[19]: Store the value of waveform generation control register 4.  
[20]: Store the value of waveform generation control register 5.  
[21]: Store the value of waveform generation control register 6.  
[22]: Store the value of waveform generation control register 7.  
[23]: Store the value of time measurement register 0.  
[24]: Store the value of time measurement register 1/waveform generation register 1.  
[25]: Store the value of time measurement register 2/waveform generation register 2.  
Rev.1.01  
2007.02.16  
148  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[26]: Store the value of time measurement register 3/waveform generation register 3.  
[27]: Store the value of time measurement register 4/waveform generation register 4.  
[28]: Store the value of time measurement register 5/waveform generation register 5.  
[29]: Store the value of time measurement register 6/waveform generation register 6.  
[30]: Store the value of time measurement register 7/waveform generation register 7.  
[31]: Store the value of the facility select register.  
[32]: Store the value of the facility enable register.  
[33]: Store the value of the interrupt request register.  
[34]: Store the value of interrupt enable register 0.  
[35]: Store the value of interrupt enable register 1.  
(R8C)  
When using timer C (RAPI_TIMER_C specified)  
[0]: Store the value of the timer C register.  
[1]: Store the value of the capture & compare 0 register.  
[2]: Store the value of the compare 1 register.  
[3]: Store the value of the timer C output control register.  
[4]: Store the value of timer C control register 1.  
[5]: Store the value of timer C control register 0.  
When using timer X (RAPI_TIMER_X specified)  
[0]: Store the value of the timer count source setup register.  
[1]: Store the value of the prescaler X register.  
[2]: Store the value of the timer X register.  
[3]: Store the value of the timer X mode register.  
When using timer Y (RAPI_TIMER_Y specified)  
[0]: Store the value of the timer count source setup register.  
[1]: Store the value of the prescaler Y register.  
[2]: Store the value of the timer Y primary register.  
[3]: Store the value of the timer Y secondary register.  
[4]: Store the value of the timer Y & Z waveform output control register.  
[5]: Store the value of the timer Y & Z output control register.  
[6]: Store the value of the timer Y & Z mode register.  
When using timer Z (RAPI_TIMER_Z specified)  
[0]: Store the value of the timer count source setup register.  
[1]: Store the value of the prescaler Z register.  
[2]: Store the value of the timer Z primary register.  
[3]: Store the value of the timer Z secondary register.  
[4]: Store the value of the timer Y & Z waveform output control register.  
[5]: Store the value of the timer Y & Z output control register.  
[6]: Store the value of the timer Y & Z mode register.  
• When using timer RA (RAPI_TIMER_RA specified)  
[0]: Specify the set value for the timer RA I/O control register.  
[1]: Specify the set value for the timer RA prescaler register.  
[2]: Specify the set value for the timer RA register.  
[3]: Specify the set value for the timer RA mode register.  
[4]: Specify the set value for the timer RA control register.  
Rev.1.01  
2007.02.16  
149  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
• When using timer RB (RAPI_TIMER_RB specified)  
[0]: Specify the set value for the timer RB one shot control register.  
[1]: Specify the set value for the timer RB I/O control register.  
[2]: Specify the set value for the timer RB prescaler register.  
[3]: Specify the set value for the timer RB primary register.  
[4]: Specify the set value for the timer RB secondary register.  
[5]: Specify the set value for the timer RB mode register.  
[6]: Specify the set value for the timer RB control register.  
• When using timer RD (RAPI_TIMER_RD0 to RAPI_TIMER_RD1)  
[0]: Specify the set value for the timer RD mode register.  
[1]: Specify the set value for the timer RD PWM mode register.  
[2]: Specify the set value for the timer RD function control register.  
[3]: Specify the set value for the timer RD general register Ai (i=0,1).  
[4]: Specify the set value for the timer RD general register Bi (i=0,1).  
[5]: Specify the set value for the timer RD general register Ci (i=0,1).  
[6]: Specify the set value for the timer RD general register Di (i=0,1).  
[7]: Specify the set value for the timer RD digital filter function select register  
i(i=0,1).  
[8]: Specify the set value for the timer RD control register i(i=0,1).  
[9]: Specify the set value for the timer RD I/O control register Ai(i=0,1).  
[10]: Specify the set value for the timer RD I/O control register Ci(i=0,1).  
[11]: Specify the set value for the timer RD status register i(i=0,1).  
[12]: Specify the set value for the timer RD interrupt enable register i(i=0,1).  
[13]: Specify the set value for the timer RD counter i(i=0,1).  
[14]: Specify the set value for the timer RD start register.  
[15]: Specify the set value for the timer RD output master enable register 1.  
[16]: Specify the set value for the timer RD output master enable register 2.  
[17]: Specify the set value for the timer RD output control register.  
• When using timer RE (RAPI_TIMER_RE)  
[0]: Specify the set value for the timer RE second data register.  
[1]: Specify the set value for the timer RE minute data register.  
[2]: Specify the set value for the timer RE hour data register.  
[3]: Specify the set value for the timer RE day of week data register.  
[4]: Specify the set value for the timer RE control register 2.  
[5]: Specify the set value for the timer RE count source select register.  
[6]: Specify the set value for the timer RE control register 1.  
(H8/300H)  
When using timer A (RAPI_TIMER_A specified)  
[0]: Store the value of timer mode register A.  
[1]: Store the value of timer counter A.  
When using timer B1 (RAPI_TIMER_B1 specified)  
[0]: Store the value of timer mode register B1.  
[1]: Store the value of timer counter B1.  
When using timer V (RAPI_TIMER_V specified)  
[0]: Store the value of timer counter V.  
Rev.1.01  
2007.02.16  
150  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[1]: Store the value of time constant register A.  
[2]: Store the value of time constant register B.  
[3]: Store the value of timer control register V0.  
[4]: Store the value of timer control register V1.  
[5]: Store the value of timer control/status register V.  
When using timer W (RAPI_TIMER_W specified)  
[0]: Store the value of timer mode register W.  
[1]: Store the value of timer control register W.  
[2]: Store the value of timer interrupt master enable register W.  
[3]: Store the value of timer status register W.  
[4]: Store the value of timer I/O control register 0.  
[5]: Store the value of timer I/O control register 1.  
[6]: Store the value of the timer counter.  
[7]: Store the value of general register A.  
[8]: Store the value of general register B.  
[9]: Store the value of general register C.  
[10]: Store the value of general register D.  
When using timer Z (RAPI_TIMER_Z specified)  
[0]: Store the value of the timer start register.  
[1]: Store the value of the timer mode register.  
[2]: Store the value of the timer PWM mode register.  
[3]: Store the value of the timer function control register.  
[4]: Store the value of the timer output master enable register.  
[5]: Store the value of the timer output control register.  
[6]: Store the value of timer counter_i (i = 0, 1).  
[7]: Store the value of general register A_i (i = 0, 1).  
[8]: Store the value of general register B_i (i=0, 1).  
[9]: Store the value of general register C_i (i=0, 1).  
[10]: Store the value of general register D_i (i=0, 1).  
[11]: Store the value of timer control register_i (i = 0, 1).  
[12]: Store the value of timer I/O control register A_i (i = 0, 1).  
[13]: Store the value of timer I/O control register B_i (i = 0, 1).  
[14]: Store the value of timer status register_i (i = 0, 1).  
[15]: Store the value of timer interrupt enable register_i (i = 0, 1).  
[16]: Store the value of PWM mode output level control register_i (i = 0, 1).  
• When using timer RC (RAPI_TIMER_RC)  
[0]: Specify the set value for timer RC control register 1.  
[1]: Specify the set value for timer RC control register 2.  
[2]: Specify the set value for timer RC interrupt enable register.  
[3]: Specify the set value for timer RC status register.  
[4]: Specify the set value for timer RC I/O control register 0.  
[5]: Specify the set value for timer RC I/O control register 1.  
[6]: Specify the set value for timer RC output enable register.  
[7]: Specify the set value for timer RC digital filter function select register.  
[8]: Specify the set value for timer RC counter.  
Rev.1.01  
2007.02.16  
151  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
[9]: Specify the set value for general register A.  
[10]: Specify the set value for general register B.  
[11]: Specify the set value for general register C.  
[12]: Specify the set value for general register D.  
[13]: Specify the set value for timer RC mode register.  
• When using timer RD (RAPI_TIMER_RD0 to RAPI_TIMER_RD3 specified)  
[0]: Specify the set value for the timer RD mode register.  
[1]: Specify the set value for the timer RD PWM mode register.  
[2]: Specify the set value for the timer RD function control register.  
[3]: Specify the set value for the timer RD output master enable register 1.  
[4]: Specify the set value for the timer RD output master enable register 2.  
[5]: Specify the set value for the timer RD output control register.  
[6]: Specify the set value for the timer RD counter i(i=0,1).  
[7]: Specify the set value for general register A_i(i=0,1).  
[8]: Specify the set value for general register B_i(i=0,1).  
[9]: Specify the set value for general register C_i(i=0,1).  
[10]: Specify the set value for general register D_i(i=0,1).  
[11]: Specify the set value for timer RD control register_i (i = 0, 1).  
[12]: Specify the set value for timer RD I/O control register A_i (i = 0, 1).  
[13]: Specify the set value for timer RD I/O control register C_i (i = 0, 1).  
[14]: Specify the set value for timer RD status register_i (i = 0, 1).  
[15]: Specify the set value for timer RD interrupt enable register_i (i = 0, 1).  
[16]: Specify the set value for PWM mode output level control register_i (i = 0, 1).  
[17]: Specify the set value for the timer RD digital filter function select register i(i = 0,  
1).  
[18]: Specify the set value for the timer RD start register.  
Return value  
If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE  
is returned.  
Functionality  
Reference  
Remark  
Timer (register manipulation)  
__SetTimerRegister, __EnableTimerRegister, __ClearTimerRegister  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable timers differ with each CPU used.  
Program example  
#include " rapi_timer_r8c_13.h"  
void func( void )  
{
unsigned int data[7];  
/* Get the value of timer Z registers */  
__GetTimerRegister( RAPI_TIMER_Z, data );  
}
Rev.1.01  
2007.02.16  
152  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4.2.3 I/O Port  
__SetIOPort  
Synopsis  
<Set I/O port>  
Boolean __SetIOPort(unsigned long data1, unsigned int data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Description  
Sets the operating conditions of a specified I/O port.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value. Note, however, that  
multiple ports cannot be specified at the same time.  
(M16C)  
The definition values corresponding to each I/O port are listed below.  
RAPI_PORT_0_0  
RAPI_PORT_0_2  
RAPI_PORT_0_4  
RAPI_PORT_0_6  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
RAPI_PORT_7_0  
RAPI_PORT_7_2  
RAPI_PORT_7_4  
RAPI_PORT_7_6  
RAPI_PORT_8_0  
RAPI_PORT_8_2  
RAPI_PORT_8_4  
RAPI_PORT_8_6  
Port P00  
Port P02  
Port P04  
Port P06  
Port P10  
Port P12  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P36  
Port P60  
Port P62  
Port P64  
Port P66  
Port P70  
Port P72  
Port P74  
Port P76  
Port P80  
Port P82  
Port P84  
Port P86  
RAPI_PORT_0_1  
RAPI_PORT_0_3  
RAPI_PORT_0_5  
RAPI_PORT_0_7  
RAPI_PORT_1_1  
RAPI_PORT_1_3  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_3_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
RAPI_PORT_7_1  
RAPI_PORT_7_3  
RAPI_PORT_7_5  
RAPI_PORT_7_7  
RAPI_PORT_8_1  
RAPI_PORT_8_3  
RAPI_PORT_8_5  
RAPI_PORT_8_7  
Port P01  
Port P03  
Port P05  
Port P07  
Port P11  
Port P13  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P37  
Port P61  
Port P63  
Port P65  
Port P67  
Port P71  
Port P73  
Port P75  
Port P77  
Port P81  
Port P83  
Port P85  
Port P87  
Rev.1.01  
2007.02.16  
153  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_9_0  
RAPI_PORT_9_2  
RAPI_PORT_9_5  
RAPI_PORT_9_7  
RAPI_PORT_10_1  
RAPI_PORT_10_3  
RAPI_PORT_10_5  
RAPI_PORT_10_7  
Port P90  
Port P92  
Port P95  
Port P97  
Port P101  
Port P103  
Port P105  
Port P107  
RAPI_PORT_9_1  
RAPI_PORT_9_3  
RAPI_PORT_9_6  
RAPI_PORT_10_0  
RAPI_PORT_10_2  
RAPI_PORT_10_4  
RAPI_PORT_10_6  
Port P91  
Port P93  
Port P96  
Port P100  
Port P102  
Port P104  
Port P106  
The definition values related to port settings are described below.  
RAPI_PORT_INPUT  
RAPI_PORT_OUTPUT  
RAPI_PULLED_HIGH  
RAPI_NOT_PULLED  
_HIGH  
Sets a selected port for input.  
Sets a selected port for output.  
Sets a selected port to be pulled high.  
Sets a selected port not to be pulled high.  
RAPI_LATCH  
Sets a selected port to read the port latch regardless of whether it  
is set for input or output. Specifiable only when port P1 is used.  
(R8C)  
The definition values corresponding to each I/O port are listed below.  
RAPI_PORT_0_0  
RAPI_PORT_0_2  
RAPI_PORT_0_4  
RAPI_PORT_0_6  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_7  
RAPI_PORT_4_4  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
Port P00  
Port P02  
Port P04  
Port P06  
Port P10  
Port P12  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P37  
Port P44  
Port P60  
Port P62  
Port P64  
Port P66  
RAPI_PORT_0_1  
RAPI_PORT_0_3  
RAPI_PORT_0_5  
RAPI_PORT_0_7  
RAPI_PORT_1_1  
RAPI_PORT_1_3  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_4_3  
RAPI_PORT_4_5  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
Port P01  
Port P03  
Port P05  
Port P07  
Port P11  
Port P13  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P43  
Port P45  
Port P61  
Port P63  
Port P65  
Port P67  
The definition values corresponding to each I/O port are listed below.  
RAPI_PORT_INPUT  
RAPI_PORT_OUTPUT  
RAPI_PULLED_HIGH  
Sets a selected port for input.  
Sets a selected port for output.  
Sets a selected port to be pulled high.  
Rev.1.01  
2007.02.16  
154  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_NOT_PULLED_HIGH  
Sets a selected port not to be pulled high.  
RAPI_DRIVE_CAPACITY_H Sets the N-channel output transistor drive capacity of a  
selected port to High. Specifiable only when port P1 is used.  
RAPI_DRIVE_CAPACITY_L  
Sets the N-channel output transistor drive capacity of a  
selected port to Low. Specifiable only when port P1 is used.  
(H8/300H)  
The definition values corresponding to each I/O port are listed below.  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_3_7  
RAPI_PORT_5_1  
RAPI_PORT_5_3  
RAPI_PORT_5_5  
RAPI_PORT_5_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
RAPI_PORT_7_1  
RAPI_PORT_7_4  
RAPI_PORT_7_6  
RAPI_PORT_8_0  
RAPI_PORT_8_2  
RAPI_PORT_8_4  
RAPI_PORT_8_6  
RAPI_PORT_9_0  
RAPI_PORT_9_2  
RAPI_PORT_9_4  
RAPI_PORT_9_6  
RAPI_PORT_C_0  
RAPI_PORT_C_2  
RAPI_PORT_D_0  
RAPI_PORT_D_2  
RAPI_PORT_D_4  
Port P10  
Port P12  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P37  
Port P51  
Port P53  
Port P55  
Port P57  
Port P61  
Port P63  
Port P65  
Port P67  
Port P71  
Port P74  
Port P76  
Port P80  
Port P82  
Port P84  
Port P86  
Port P90  
Port P92  
Port P94  
Port P96  
Port PC0  
PortPC2  
PortPD0  
PortPD2  
PortPD4  
RAPI_PORT_1_1  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_6  
RAPI_PORT_5_0  
RAPI_PORT_5_2  
RAPI_PORT_5_4  
RAPI_PORT_5_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
RAPI_PORT_7_0  
RAPI_PORT_7_2  
RAPI_PORT_7_5  
RAPI_PORT_7_7  
RAPI_PORT_8_1  
RAPI_PORT_8_3  
RAPI_PORT_8_5  
RAPI_PORT_8_7  
RAPI_PORT_9_1  
RAPI_PORT_9_3  
RAPI_PORT_9_5  
RAPI_PORT_9_7  
RAPI_PORT_C_1  
RAPI_PORT_C_3  
RAPI_PORT_D_1  
RAPI_PORT_D_3  
RAPI_PORT_D_5  
Port P11  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P36  
Port P50  
Port P52  
Port P54  
Port P56  
Port P60  
Port P62  
Port P64  
Port P66  
Port P70  
Port P72  
Port P75  
Port P77  
Port P81  
Port P83  
Port P85  
Port P87  
Port P91  
Port P93  
Port P95  
Port P97  
Port PC1  
PortPC3  
PortPD1  
PortPD3  
PortPD5  
Rev.1.01  
2007.02.16  
155  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_D_6  
RAPI_PORT_E_0  
RAPI_PORT_E_2  
RAPI_PORT_E_4  
RAPI_PORT_E_6  
RAPI_PORT_F_0  
RAPI_PORT_G_1  
RAPI_PORT_G_3  
RAPI_PORT_G_5  
RAPI_PORT_G_7  
RAPI_PORT_H_1  
RAPI_PORT_H_3  
RAPI_PORT_H_5  
RAPI_PORT_H_7  
RAPI_PORT_J_1  
PortPD6  
PortPE0  
PortPE2  
PortPE4  
PortPE6  
PortPF0  
PortPG1  
PortPG3  
PortPG5  
PortPG7  
PortPH1  
PortPH3  
PortPH5  
PortPH7  
PortPJ1  
RAPI_PORT_D_7  
RAPI_PORT_E_1  
RAPI_PORT_E_3  
RAPI_PORT_E_5  
RAPI_PORT_E_7  
RAPI_PORT_G_0  
RAPI_PORT_G_2  
RAPI_PORT_G_4  
RAPI_PORT_G_6  
RAPI_PORT_H_0  
RAPI_PORT_H_2  
RAPI_PORT_H_4  
RAPI_PORT_H_6  
RAPI_PORT_J_0  
PortPD7  
PortPE1  
PortPE3  
PortPE5  
PortPE7  
PortPG0  
PortPG2  
PortPG4  
PortPG6  
PortPH0  
PortPH2  
PortPH4  
PortPH6  
PortPJ0  
The definition values related to port settings are described below.  
RAPI_PORT_INPUT  
Sets a selected port for input.  
RAPI_PORT_OUTPUT  
RAPI_PULLED_HIGH  
RAPI_NOT_PULLED_HIGH  
Sets a selected port for output.  
Sets a selected port to be pulled high.  
Sets a selected port not to be pulled high.  
[data2]  
(M16C)  
Specify the digital filter width of the digital debounce facility assigned to _NMI/_SD.  
Specifiable only when port P85 is used.  
Specify the digital filter width of the digital debounce facility assigned to  
INPC17/_INT5. Specifiable only when port P17 is used.  
When using any other port, set 0 for this data.  
(R8C) (H8/300H)  
Specify 0.  
Return value  
If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
I/O port  
__ReadIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister,  
__WriteIOPortRegister  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable I/O ports differ with each CPU used.  
The API cannot set function that the specified I/O port dont have.  
Rev.1.01  
2007.02.16  
156  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Program example  
#include " rapi_io_port_r8c_13.h  
void func( void )  
{
/* Set up port P03 as input port */  
__SetIOPort(RAPI_PORT_0_3| RAPI_PORT_INPUT| RAPI_PULLED_HIGH, 0, 0 );  
}
Rev.1.01  
2007.02.16  
157  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__ReadIOPort  
Synopsis  
<Read from I/O port>  
Boolean __ReadIOPort(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the variable in which the value read from I/O port is stored.  
Description  
Gets the value of a specified I/O port.  
[data1]  
Specify an I/O port from which data is read. The definition values corresponding to  
each I/O port are listed below.  
(M16C)  
RAPI_PORT_0_0  
RAPI_PORT_0_2  
RAPI_PORT_0_4  
RAPI_PORT_0_6  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
RAPI_PORT_7_0  
RAPI_PORT_7_2  
RAPI_PORT_7_4  
RAPI_PORT_7_6  
RAPI_PORT_8_0  
RAPI_PORT_8_2  
RAPI_PORT_8_4  
RAPI_PORT_8_6  
RAPI_PORT_9_0  
RAPI_PORT_9_2  
Port P00  
Port P02  
Port P04  
Port P06  
Port P10  
Port P12  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P36  
Port P60  
Port P62  
Port P64  
Port P66  
Port P70  
Port P72  
Port P74  
Port P76  
Port P80  
Port P82  
Port P84  
Port P86  
Port P90  
Port P92  
RAPI_PORT_0_1  
RAPI_PORT_0_3  
RAPI_PORT_0_5  
RAPI_PORT_0_7  
RAPI_PORT_1_1  
RAPI_PORT_1_3  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_3_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
RAPI_PORT_7_1  
RAPI_PORT_7_3  
RAPI_PORT_7_5  
RAPI_PORT_7_7  
RAPI_PORT_8_1  
RAPI_PORT_8_3  
RAPI_PORT_8_5  
RAPI_PORT_8_7  
RAPI_PORT_9_1  
RAPI_PORT_9_3  
Port P01  
Port P03  
Port P05  
Port P07  
Port P11  
Port P13  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P37  
Port P61  
Port P63  
Port P65  
Port P67  
Port P71  
Port P73  
Port P75  
Port P77  
Port P81  
Port P83  
Port P85  
Port P87  
Port P91  
Port P93  
Rev.1.01  
2007.02.16  
158  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_9_5  
RAPI_PORT_9_7  
RAPI_PORT_10_1  
RAPI_PORT_10_3  
RAPI_PORT_10_5  
RAPI_PORT_10_7  
Port P95  
RAPI_PORT_9_6  
RAPI_PORT_10_0  
RAPI_PORT_10_2  
RAPI_PORT_10_4  
RAPI_PORT_10_6  
Port P96  
Port P97  
Port P100  
Port P102  
Port P104  
Port P106  
Port P101  
Port P103  
Port P105  
Port P107  
(R8C)  
RAPI_PORT_0_0  
RAPI_PORT_0_2  
RAPI_PORT_0_4  
RAPI_PORT_0_6  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_7  
RAPI_PORT_4_3  
RAPI_PORT_4_5  
RAPI_PORT_4_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
Port P00  
Port P02  
Port P04  
Port P06  
Port P10  
Port P12  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P37  
Port P43  
Port P45  
Port P47  
Port P61  
Port P63  
Port P65  
Port P67  
RAPI_PORT_0_1  
RAPI_PORT_0_3  
RAPI_PORT_0_5  
RAPI_PORT_0_7  
RAPI_PORT_1_1  
RAPI_PORT_1_3  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_4_2  
RAPI_PORT_4_4  
RAPI_PORT_4_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
Port P01  
Port P03  
Port P05  
Port P07  
Port P11  
Port P13  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P42  
Port P44  
Port P46  
Port P60  
Port P62  
Port P64  
Port P66  
(H8/300H)  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_3_7  
Port P10  
Port P12  
Port P15  
Port P17  
Port P21  
Port P23  
PortP25  
PortP27  
PortP31  
PortP33  
PortP35  
PortP37  
RAPI_PORT_1_1  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_6  
RAPI_PORT_5_0  
Port P11  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
PortP26  
PortP30  
PortP32  
PortP34  
PortP36  
PortP50  
Rev.1.01  
2007.02.16  
159  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_5_1  
RAPI_PORT_5_3  
RAPI_PORT_5_5  
RAPI_PORT_5_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
RAPI_PORT_7_1  
RAPI_PORT_7_4  
RAPI_PORT_7_6  
RAPI_PORT_8_0  
RAPI_PORT_8_2  
RAPI_PORT_8_4  
RAPI_PORT_8_6  
RAPI_PORT_9_0  
RAPI_PORT_9_2  
RAPI_PORT_9_4  
RAPI_PORT_9_6  
RAPI_PORT_B_0  
RAPI_PORT_B_2  
RAPI_PORT_B_4  
RAPI_PORT_B_6  
RAPI_PORT_C_0  
RAPI_PORT_C_2  
RAPI_PORT_D_0  
RAPI_PORT_D_2  
RAPI_PORT_D_4  
RAPI_PORT_D_6  
RAPI_PORT_E_0  
RAPI_PORT_E_2  
RAPI_PORT_E_4  
RAPI_PORT_E_6  
RAPI_PORT_F_0  
RAPI_PORT_F_2  
RAPI_PORT_F_4  
RAPI_PORT_F_6  
RAPI_PORT_G_0  
RAPI_PORT_G_2  
RAPI_PORT_G_4  
RAPI_PORT_G_6  
RAPI_PORT_H_0  
RAPI_PORT_H_2  
PortP51  
PortP53  
PortP55  
PortP57  
PortP61  
PortP63  
PortP65  
PortP67  
PortP71  
PortP74  
PortP76  
PortP80  
PortP82  
PortP84  
PortP86  
PortP90  
PortP92  
PortP94  
PortP96  
PortPB0  
PortPB2  
PortPB4  
PortPB6  
PortPC0  
PortPC2  
PortPD0  
PortPD2  
PortPD4  
PortPD6  
PortPE0  
PortPE2  
PortPE4  
PortPE6  
PortPF0  
PortPF2  
PortPF4  
PortPF6  
PortPG0  
PortPG2  
PortPG4  
PortPG6  
PortPH0  
PortPH2  
RAPI_PORT_5_2  
RAPI_PORT_5_4  
RAPI_PORT_5_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
RAPI_PORT_7_0  
RAPI_PORT_7_2  
RAPI_PORT_7_5  
RAPI_PORT_7_7  
RAPI_PORT_8_1  
RAPI_PORT_8_3  
RAPI_PORT_8_5  
RAPI_PORT_8_7  
RAPI_PORT_9_1  
RAPI_PORT_9_3  
RAPI_PORT_9_5  
RAPI_PORT_9_7  
RAPI_PORT_B_1  
RAPI_PORT_B_3  
RAPI_PORT_B_5  
RAPI_PORT_B_7  
RAPI_PORT_C_1  
RAPI_PORT_C_3  
RAPI_PORT_D_1  
RAPI_PORT_D_3  
RAPI_PORT_D_5  
RAPI_PORT_D_7  
RAPI_PORT_E_1  
RAPI_PORT_E_3  
RAPI_PORT_E_5  
RAPI_PORT_E_7  
RAPI_PORT_F_1  
RAPI_PORT_F_3  
RAPI_PORT_F_5  
RAPI_PORT_F_7  
RAPI_PORT_G_1  
RAPI_PORT_G_3  
RAPI_PORT_G_5  
RAPI_PORT_G_7  
RAPI_PORT_H_1  
RAPI_PORT_H_3  
PortP52  
PortP54  
PortP56  
PortP60  
PortP62  
PortP64  
PortP66  
PortP70  
PortP72  
PortP75  
PortP77  
PortP81  
PortP83  
PortP85  
PortP87  
PortP91  
PortP93  
PortP95  
PortP97  
PortPB1  
PortPB3  
PortPB5  
PortPB7  
PortPC1  
PortPC3  
PortPD1  
PortPD3  
PortPD5  
PortPD7  
PortPE1  
PortPE3  
PortPE5  
PortPE7  
PortPF1  
PortPF3  
PortPF5  
PortPF7  
PortPG1  
PortPG3  
PortPG5  
PortPG7  
PortPH1  
PortPH3  
Rev.1.01  
2007.02.16  
160  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_H_4  
RAPI_PORT_H_6  
RAPI_PORT_J_0  
PortPH4  
PortPH6  
PortPJ0  
RAPI_PORT_H_5  
RAPI_PORT_H_7  
RAPI_PORT_J_1  
PortPH5  
PortPH7  
PortPJ1  
Return value  
If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
I/O port  
__SetIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister,  
__WriteIOPortRegister  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable I/O ports differ with each CPU used.  
Ports in port B of the H8/300H that are used as analog input pins cannot be used as input  
ports.  
Program example  
#include " rapi_io_port_r8c_13.h"  
void func( void )  
{
/* Get the value of port P12 */  
__ReadIOPort(RAPI_PORT_1_2, &data );  
}
Rev.1.01  
2007.02.16  
161  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__WriteIOPort  
Synopsis  
<Write to I/O port>  
Boolean __WriteIOPort(unsigned long data1, unsigned int data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Data to be written to I/O port  
Description  
Writes data to a specified I/O port.  
[data1]  
Specify an I/O port to which data is written. The definition values corresponding to each  
I/O port are listed below.  
(M16C)  
RAPI_PORT_0_0  
RAPI_PORT_0_2  
RAPI_PORT_0_4  
RAPI_PORT_0_6  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
RAPI_PORT_7_0  
RAPI_PORT_7_2  
RAPI_PORT_7_4  
RAPI_PORT_7_6  
RAPI_PORT_8_0  
RAPI_PORT_8_2  
RAPI_PORT_8_4  
RAPI_PORT_8_6  
RAPI_PORT_9_0  
RAPI_PORT_9_2  
Port P00  
Port P02  
Port P04  
Port P06  
Port P10  
Port P12  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P36  
Port P60  
Port P62  
Port P64  
Port P66  
Port P70  
Port P72  
Port P74  
Port P76  
Port P80  
Port P82  
Port P84  
Port P86  
Port P90  
Port P92  
RAPI_PORT_0_1  
RAPI_PORT_0_3  
RAPI_PORT_0_5  
RAPI_PORT_0_7  
RAPI_PORT_1_1  
RAPI_PORT_1_3  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_3_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
RAPI_PORT_7_1  
RAPI_PORT_7_3  
RAPI_PORT_7_5  
RAPI_PORT_7_7  
RAPI_PORT_8_1  
RAPI_PORT_8_3  
RAPI_PORT_8_5  
RAPI_PORT_8_7  
RAPI_PORT_9_1  
RAPI_PORT_9_3  
Port P01  
Port P03  
Port P05  
Port P07  
Port P11  
Port P13  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P37  
Port P61  
Port P63  
Port P65  
Port P67  
Port P71  
Port P73  
Port P75  
Port P77  
Port P81  
Port P83  
Port P85  
Port P87  
Port P91  
Port P93  
Rev.1.01  
2007.02.16  
162  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_9_5  
RAPI_PORT_9_7  
RAPI_PORT_10_1  
RAPI_PORT_10_3  
RAPI_PORT_10_5  
RAPI_PORT_10_7  
Port P95  
RAPI_PORT_9_6  
RAPI_PORT_10_0  
RAPI_PORT_10_2  
RAPI_PORT_10_4  
RAPI_PORT_10_6  
Port P96  
Port P97  
Port P100  
Port P102  
Port P104  
Port P106  
Port P101  
Port P103  
Port P105  
Port P107  
(R8C)  
RAPI_PORT_0_0  
RAPI_PORT_0_2  
RAPI_PORT_0_4  
RAPI_PORT_0_6  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_7  
RAPI_PORT_4_4  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
Port P00  
Port P02  
Port P04  
Port P06  
Port P10  
Port P12  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
Port P26  
Port P30  
Port P32  
Port P34  
Port P37  
Port P44  
Port P60  
Port P62  
Port P64  
Port P66  
RAPI_PORT_0_1  
RAPI_PORT_0_3  
RAPI_PORT_0_5  
RAPI_PORT_0_7  
RAPI_PORT_1_1  
RAPI_PORT_1_3  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_4_3  
RAPI_PORT_4_5  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
Port P01  
Port P03  
Port P05  
Port P07  
Port P11  
Port P13  
Port P15  
Port P17  
Port P21  
Port P23  
Port P25  
Port P27  
Port P31  
Port P33  
Port P35  
Port P43  
Port P45  
Port P61  
Port P63  
Port P65  
Port P67  
(H8/300H)  
RAPI_PORT_1_0  
RAPI_PORT_1_2  
RAPI_PORT_1_5  
RAPI_PORT_1_7  
RAPI_PORT_2_1  
RAPI_PORT_2_3  
RAPI_PORT_2_5  
RAPI_PORT_2_7  
RAPI_PORT_3_1  
RAPI_PORT_3_3  
RAPI_PORT_3_5  
RAPI_PORT_3_7  
RAPI_PORT_5_1  
RAPI_PORT_5_3  
Port P10  
Port P12  
Port P15  
Port P17  
Port P21  
Port P23  
PortP25  
PortP27  
PortP31  
PortP33  
PortP35  
PortP37  
PortP51  
PortP53  
RAPI_PORT_1_1  
RAPI_PORT_1_4  
RAPI_PORT_1_6  
RAPI_PORT_2_0  
RAPI_PORT_2_2  
RAPI_PORT_2_4  
RAPI_PORT_2_6  
RAPI_PORT_3_0  
RAPI_PORT_3_2  
RAPI_PORT_3_4  
RAPI_PORT_3_6  
RAPI_PORT_5_0  
RAPI_PORT_5_2  
RAPI_PORT_5_4  
Port P11  
Port P14  
Port P16  
Port P20  
Port P22  
Port P24  
PortP26  
PortP30  
PortP32  
PortP34  
PortP36  
PortP50  
PortP52  
PortP54  
Rev.1.01  
2007.02.16  
163  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_PORT_5_5  
RAPI_PORT_5_7  
RAPI_PORT_6_1  
RAPI_PORT_6_3  
RAPI_PORT_6_5  
RAPI_PORT_6_7  
RAPI_PORT_7_1  
RAPI_PORT_7_4  
RAPI_PORT_7_6  
RAPI_PORT_8_0  
RAPI_PORT_8_2  
RAPI_PORT_8_4  
RAPI_PORT_8_6  
RAPI_PORT_9_0  
RAPI_PORT_9_2  
RAPI_PORT_9_4  
RAPI_PORT_9_6  
RAPI_PORT_C_0  
RAPI_PORT_C_2  
RAPI_PORT_D_0  
RAPI_PORT_D_2  
RAPI_PORT_D_4  
RAPI_PORT_D_6  
RAPI_PORT_E_0  
RAPI_PORT_E_2  
RAPI_PORT_E_4  
RAPI_PORT_E_6  
RAPI_PORT_G_0  
RAPI_PORT_G_2  
RAPI_PORT_G_4  
RAPI_PORT_G_6  
RAPI_PORT_H_0  
RAPI_PORT_H_2  
RAPI_PORT_H_4  
RAPI_PORT_H_6  
RAPI_PORT_J_0  
PortP55  
PortP57  
PortP61  
PortP63  
PortP65  
PortP67  
PortP71  
PortP74  
PortP76  
PortP80  
PortP82  
PortP84  
PortP86  
PortP90  
PortP92  
PortP94  
PortP96  
PortPC0  
PortPC2  
PortPD0  
PortPD2  
PortPD4  
PortPD6  
PortPE0  
PortPE2  
PortPE4  
PortPE6  
PortPG0  
PortPG2  
PortPG4  
PortPG6  
PortPH0  
PortPH2  
PortPH4  
PortPH6  
PortPJ0  
RAPI_PORT_5_6  
RAPI_PORT_6_0  
RAPI_PORT_6_2  
RAPI_PORT_6_4  
RAPI_PORT_6_6  
RAPI_PORT_7_0  
RAPI_PORT_7_2  
RAPI_PORT_7_5  
RAPI_PORT_7_7  
RAPI_PORT_8_1  
RAPI_PORT_8_3  
RAPI_PORT_8_5  
RAPI_PORT_8_7  
RAPI_PORT_9_1  
RAPI_PORT_9_3  
RAPI_PORT_9_5  
RAPI_PORT_9_7  
RAPI_PORT_C_1  
RAPI_PORT_C_3  
RAPI_PORT_D_1  
RAPI_PORT_D_3  
RAPI_PORT_D_5  
RAPI_PORT_D_7  
RAPI_PORT_E_1  
RAPI_PORT_E_3  
RAPI_PORT_E_5  
RAPI_PORT_E_7  
RAPI_PORT_G_1  
RAPI_PORT_G_3  
RAPI_PORT_G_5  
RAPI_PORT_G_7  
RAPI_PORT_H_1  
RAPI_PORT_H_3  
RAPI_PORT_H_5  
RAPI_PORT_H_7  
RAPI_PORT_J_1  
PortP56  
PortP60  
PortP62  
PortP64  
PortP66  
PortP70  
PortP72  
PortP75  
PortP77  
PortP81  
PortP83  
PortP85  
PortP87  
PortP91  
PortP93  
PortP95  
PortP97  
PortPC1  
PortPC3  
PortPD1  
PortPD3  
PortPD5  
PortPD7  
PortPE1  
PortPE3  
PortPE5  
PortPE7  
PortPG1  
PortPG3  
PortPG5  
PortPG7  
PortPH1  
PortPH3  
PortPH5  
PortPH7  
PortPJ1  
Return value  
If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
I/O port  
__SetIOPort, __ReadIOPort, __SetIOPortRegister, __ReadIOPortRegister,  
Rev.1.01  
2007.02.16  
164  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__WriteIOPortRegister  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Remark  
The specifiable I/O ports differ with each CPU used.  
Program example  
#include " rapi_io_port_r8c_13.h"  
void func( void )  
{
unsigned int data;  
/* Set the data to port P05 */  
__WriteIOPort( RAPI_PORT_0_5, 0 );  
}
Rev.1.01  
2007.02.16  
165  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__SetIOPortRegister  
<Set I/O port register>  
Synopsis  
Boolean __SetIOPortRegister(unsigned long data1, unsigned int data2, unsigned  
int data3, unsigned int data4)  
data1  
data2  
data3  
data4  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Setup data 4 (content differs with MCU type)  
[data1]  
Description  
Set the operating condition of a specified I/O port in each relevant register.  
(M16C)  
The definition values corresponding to each I/O port register are listed below.  
RAPI_PORT_0  
RAPI_PORT_2  
RAPI_PORT_6  
RAPI_PORT_8  
RAPI_PORT_10  
Port P0 register  
Port P2 register  
Port P6 register  
Port P8 register  
Port P10 register  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_7  
RAPI_PORT_9  
Port P1 register  
Port P3 register  
Port P7 register  
Port P9 register  
The definition values related to port settings are described below.  
RAPI_LATCH  
Set to read the port latch regardless of whether the port is set for input or  
output. Specifiable only when port P1 is used.  
(R8C)  
The definition values corresponding to each I/O port register are listed below.  
RAPI_PORT_0  
RAPI_PORT_2  
RAPI_PORT_4  
Port P0 register  
Port P2 register  
Port P4 register  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_6  
Port P1 register  
Port P3 register  
Port P6 register  
(H8/300H)  
The definition values corresponding to each I/O port register are listed below.  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_6  
RAPI_PORT_8  
RAPI_PORT_C  
RAPI_PORT_E  
RAPI_PORT_G  
RAPI_PORT_J  
Port P1 register  
Port P3 register  
Port P6 register  
Port P8 register  
Port PC register  
Port PE register  
Port PG register  
Port PJ register  
RAPI_PORT_2  
RAPI_PORT_5  
RAPI_PORT_7  
RAPI_PORT_9  
RAPI_PORT_D  
RAPI_PORT_F  
RAPI_PORT_H  
Port P2 register  
Port P5 register  
Port P7 register  
Port P9 register  
Port PD register  
Port PF register  
Port PH register  
[data2]  
(M16C) (R8C)  
Specify the set value for the port direction register corresponding to a selected port.  
(H8/300H)  
Rev.1.01  
2007.02.16  
166  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Specify the set value for the port control register corresponding to a selected port.  
[data3]  
(M16C) (R8C)  
Specify the set value for the pullup control register corresponding to a selected port.  
(H8/300H)  
Specify the set value for the pullup control register corresponding to a selected port.  
[data4]  
(M16C)  
Specify the digital filter width of the digital debounce facility assigned to _NMI/_SD.  
Specifiable only when port P8 is used.  
Specify the digital filter width of the digital debounce facility assigned to  
INPC17/_INT5. Specifiable only when port P1 is used.  
When using any other port, set 0 for this data.  
(R8C)  
Specify the set value for the port P1 drive capacity register. Specifiable only when  
port P1 is used.  
When using any other port, set 0 for this data.  
(H8/300H)  
Specify 0.  
Return value  
If the I/O port register specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
I/O port  
__SetIOPort, __ReadIOPort, __WriteIOPort, __ReadIOPortRegister,  
__WriteIOPortRegister  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable I/O port registers differ with each CPU used.  
Program example  
#include " rapi_io_port_r8c_13.h"  
void func( void )  
{
/* Set inputs/outputs of port P1 register */  
__SetIOPortRegister(RAPI_PORT_1, 0xAA, 0, 0 );  
}
Rev.1.01  
2007.02.16  
167  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__ReadIOPortRegister  
Synopsis  
<Read from I/O port register>  
Boolean __ReadIOPortRegister(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the variable in which the value read from I/O port register is stored.  
Description  
Gets the value of a specified I/O port from each relevant register.  
[data1]  
Specify an I/O port register from which data is read. The definition values  
corresponding to each I/O port register are listed below.  
(M16C)  
RAPI_PORT_0  
RAPI_PORT_2  
RAPI_PORT_6  
RAPI_PORT_8  
RAPI_PORT_10  
Port P0 register  
Port P2 register  
Port P6 register  
Port P8 register  
Port P10 register  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_7  
RAPI_PORT_9  
Port P1 register  
Port P3 register  
Port P7 register  
Port P9 register  
(R8C)  
RAPI_PORT_0  
RAPI_PORT_2  
RAPI_PORT_4  
Port P0 register  
Port P2 register  
Port P4 register  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_6  
Port P1 register  
Port P3 register  
Port P6 register  
(H8/300H)  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_6  
RAPI_PORT_8  
RAPI_PORT_B  
RAPI_PORT_D  
RAPI_PORT_F  
RAPI_PORT_H  
Port P1 register  
Port P3 register  
Port P6 register  
Port P8 register  
Port PB register  
Port PD register  
Port PF register  
Port PH register  
RAPI_PORT_2  
RAPI_PORT_5  
RAPI_PORT_7  
RAPI_PORT_9  
RAPI_PORT_C  
RAPI_PORT_E  
RAPI_PORT_G  
RAPI_PORT_J  
Port P2 register  
Port P5 register  
Port P7 register  
Port P9 register  
Port PC register  
Port PE register  
Port PG register  
Port PJ register  
Return value  
If the I/O port register specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
I/O port  
__SetIOPort, __ReadIOPort, __WriteIOPort, __SetIOPortRegister,  
__WriteIOPortRegister  
Remark  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable I/O port registers differ with each CPU used.  
Rev.1.01  
2007.02.16  
168  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Ports in port B of the H8/300H that are used as analog input pins cannot be used as input  
ports.  
Program example  
#include " rapi_io_port_r8c_13.h"  
void func( void )  
{
unsigned int data;  
/* Get the value of port P1 register */  
__ReadIOPortRegister( RAPI_PORT_1, &data );  
}
Rev.1.01  
2007.02.16  
169  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__WriteIOPortRegister  
Synopsis  
<Write to I/O port register>  
Boolean __WriteIOPortRegister(unsigned long data1, unsigned int data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Data to be written to I/O port register  
Description  
Writes the value for a specified I/O port to each relevant register.  
[data1]  
Specify an I/O port register to which data is written. The definition values  
corresponding to each I/O port register are listed below.  
(M16C)  
RAPI_PORT_0  
RAPI_PORT_2  
RAPI_PORT_6  
RAPI_PORT_8  
RAPI_PORT_10  
Port P0 register  
Port P2 register  
Port P6 register  
Port P8 register  
Port P10 register  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_7  
RAPI_PORT_9  
Port P1 register  
Port P3 register  
Port P7 register  
Port P9 register  
(R8C)  
RAPI_PORT_0  
RAPI_PORT_2  
RAPI_PORT_4  
Port P0 register  
Port P2 register  
Port P4 register  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_6  
Port P1 register  
Port P3 register  
Port P6 register  
(H8/300H)  
RAPI_PORT_1  
RAPI_PORT_3  
RAPI_PORT_6  
RAPI_PORT_8  
RAPI_PORT_B  
RAPI_PORT_D  
RAPI_PORT_F  
RAPI_PORT_H  
Port P1 register  
Port P3 register  
Port P6 register  
Port P8 register  
Port PB register  
Port PD register  
Port PF register  
Port PH register  
RAPI_PORT_2  
RAPI_PORT_5  
RAPI_PORT_7  
RAPI_PORT_9  
RAPI_PORT_C  
RAPI_PORT_E  
RAPI_PORT_G  
RAPI_PORT_J  
Port P2 register  
Port P5 register  
Port P7 register  
Port P9 register  
Port PC register  
Port PE register  
Port PG register  
Port PJ register  
Return value  
If the I/O port register specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
I/O port  
__SetIOPort, __ReadIOPort, __WriteIOPort, __SetIOPortRegister,  
__ReadIOPortRegister  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Remark  
The specifiable I/O port registers differ with each CPU used.  
Rev.1.01  
2007.02.16  
170  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Program example  
#include " rapi_io_port_r8c_13.h"  
void func( void )  
{
/* Set the data to port P1 register */  
__WriteIOPortRegister( RAPI_PORT_1, 0xFF );  
}
Rev.1.01  
2007.02.16  
171  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4.2.4 External interrupt  
__SetInterrupt  
Synopsis  
<Set external interrupt>  
Boolean __SetInterrupt(unsigned long data1, unsigned int data2, void* func)  
data1  
data2  
func  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets a specified external interrupt.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value. Note, however, that  
multiple external interrupts cannot be specified at the same time.  
(M16C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_INT4  
RAPI_INT5  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses _INT4 interrupt.  
Uses _INT5 interrupt.  
Uses key input interrupt.  
Specifies a rising edge for the active edge of a selected external  
interrupt.  
RAPI_INT_RISING  
RAPI_INT_FALLING Specifies a falling edge for the active edge of a selected external  
interrupt.  
RAPI_INT_BOTH  
Specifies both edges for the active edge of a selected external  
interrupt.  
RAPI_KI0_ENABLE  
RAPI_KI1_ENABLE  
RAPI_KI2_ENABLE  
RAPI_KI3_ENABLE  
Uses _KI0 pin input.  
Uses _KI1 pin input.  
Uses _KI2 pin input.  
Uses _KI3 pin input.  
• Specifiable definition values when _INT05 interrupts are used (RAPI_INT0 to  
RAPI_INT5 specified)  
(Polarity)  
Specify one from { RAPI_INT_RISING, RAPI_INT_FALLING,  
RAPI_INT_BOTH }. The default value is RAPI_INT_FALLING.  
• Specifiable definition values when key input interrupt is used (RAPI_KEY specified)  
(Input pin)  
To use _KI0, _KI1, _KI2, or _KI3 pin input, specify RAPI_KI0_ENABLE,  
RAPI_KI1_ENABLE, RAPI_KI2_ENABLE, or RAPI_KI3_ENABLE,  
respectively. The default value is RAPI_INT_FALLING.  
(R8C)  
RAPI_INT0  
RAPI_INT1  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Rev.1.01  
2007.02.16  
172  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_INT2  
Uses _INT2 interrupt.  
RAPI_INT3  
Uses _INT3 interrupt.  
RAPI_KEY  
Uses key input interrupt.  
RAPI_INT_RISING  
Specifies a rising edge for the active edge of a selected external  
interrupt.  
RAPI_INT_FALLING Specifies a falling edge for the active edge of a selected external  
interrupt.  
RAPI_INT_BOTH  
Specifies both edges for the active edge of a selected external  
interrupt.  
RAPI_FILTER_F1  
RAPI_FILTER_F8  
RAPI_FILTER_F32  
RAPI_KI0_FALLING  
RAPI_KI0_RISING  
RAPI_KI1_FALLING  
RAPI_KI1_RISING  
RAPI_KI2_FALLING  
RAPI_KI2_RISING  
RAPI_KI3_FALLING  
RAPI_KI3_RISING  
Uses the digital filter facility that has a sampling frequency f1.  
Uses the digital filter facility that has a sampling frequency f8.  
Uses the digital filter facility that has a sampling frequency f32.  
Enables _KI0 pin input whose falling edge is the active edge.  
Enables _KI0 pin input whose rising edge is the active edge.  
Enables _KI1 pin input whose falling edge is the active edge.  
Enables _KI1 pin input whose rising edge is the active edge.  
Enables _KI2 pin input whose falling edge is the active edge.  
Enables _KI2 pin input whose rising edge is the active edge.  
Enables _KI3 pin input whose falling edge is the active edge.  
Enables _KI3 pin input whose rising edge is the active edge.  
• Specifiable definition values when _INT0 to _INT3 interrupt is used (RAPI_INT0 to  
RAPI_INT3 specified)  
(Polarity)  
Specify one from { RAPI_INT_RISING, RAPI_INT_FALLING,  
RAPI_INT_BOTH }. The default value is RAPI_INT_FALLING.  
Specify one from { RAPI_FILTER_F1, RAPI_FILTER_F8,  
RAPI_FILTER_F32 }. If no filters are specified, “No filter” is set.  
(Filter)  
• Specifiable definition values when key input interrupt is used (RAPI_KEY specified)  
(_KI0 pin input) Specify one from { RAPI_KI0_FALLING, RAPI_KI0_RISING }. If _KI0 pin  
input is not specified, “_KI0 pin input disabled” is set.  
(_KI1 pin input) Specify one from { RAPI_KI1_FALLING, RAPI_KI1_RISING }. If _KI1 pin  
input is not specified, “_KI1 pin input disabled” is set.  
(_KI2 pin input) Specify one from { RAPI_KI2_FALLING, RAPI_KI2_RISING }. If _KI2 pin  
input is not specified, “_KI2 pin input disabled” is set.  
(_KI3 pin input) Specify one from { RAPI_KI3_FALLING, RAPI_KI3_RISING }. If _KI3 pin  
input is not specified, “_KI3 pin input disabled” is set.  
(H8/300H)  
RAPI_IRQ0  
Uses IRQ0 interrupt.  
RAPI_IRQ1  
Uses IRQ1 interrupt.  
RAPI_IRQ2  
Uses IRQ2 interrupt.  
RAPI_IRQ3  
Uses IRQ3 interrupt.  
RAPI_WKP  
Uses WKP interrupt.  
RAPI_NOT_INT_  
REQUEST  
Does not request assertion of interrupt for a selected external  
interrupt.  
RAPI_INT_REQUEST  
Requests assertion of interrupt for a selected external interrupt.  
Rev.1.01  
2007.02.16  
173  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_INT_RISING  
RAPI_INT_FALLING  
Specifies a rising edge for the active edge of a selected external  
interrupt.  
Specifies a falling edge for the active edge of a selected external  
interrupt.  
RAPI_WKP0_FALLING Enables _WKP0 pin input whose falling edge is the active edge.  
RAPI_WKP0_RISING Enables _WKP0 pin input whose rising edge is the active edge.  
RAPI_WKP1_FALLING Enables _WKP1 pin input whose falling edge is the active edge.  
RAPI_WKP1_RISING Enables _WKP1 pin input whose rising edge is the active edge.  
RAPI_WKP2_FALLING Enables _WKP2 pin input whose falling edge is the active edge.  
RAPI_WKP2_RISING Enables _WKP2 pin input whose rising edge is the active edge.  
RAPI_WKP3_FALLING Enables _WKP3 pin input whose falling edge is the active edge.  
RAPI_WKP3_RISING Enables _WKP3 pin input whose rising edge is the active edge.  
RAPI_WKP4_FALLING Enables _WKP4 pin input whose falling edge is the active edge.  
RAPI_WKP4_RISING Enables _WKP4 pin input whose rising edge is the active edge.  
RAPI_WKP5_FALLING Enables _WKP5 pin input whose falling edge is the active edge.  
RAPI_WKP5_RISING Enables _WKP5 pin input whose rising edge is the active edge.  
• Specifiable definition values when _IRQ0–3 interrupts are used (RAPI_IRQ0 to  
RAPI_IRQ3 specified)  
(Polarity)  
Specify one from { RAPI_INT_RISING, RAPI_INT_FALLING }. The  
default value is RAPI_INT_FALLING.  
(Interrupt  
request)  
Specify one from { RAPI_NOT_INT_REQUEST, RAPI_INT_REQUEST }.  
The default value is RAPI_NOT_INT_REQUEST.  
• Specifiable definition values when WKP interrupt is used (RAPI_WKP specified)  
(_WKP0 pin input) Specify one from { RAPI_WKP0_FALLING, RAPI_WKP0_RISING }. If  
_WKP0 pin input is not specified, “_WKP0 pin input disabled” is set.  
(_WKP1 pin input) Specify one from { RAPI_WKP1_FALLING, RAPI_WKP1_RISING }. If  
_WKP1 pin input is not specified, “_WKP1 pin input disabled” is set.  
(_WKP pin input) Specify one from { RAPI_WKP2_FALLING, RAPI_WKP2_RISING }. If  
_WKP2 pin input is not specified, “_WKP2 pin input disabled” is set.  
(_WKP3 pin input) Specify one from { RAPI_WKP3_FALLING, RAPI_WKP3_RISING }. If  
_WKP3 pin input is not specified, “_WKP3 pin input disabled” is set.  
(_WKP4 pin input) Specify one from { RAPI_WKP4_FALLING, RAPI_WKP4_RISING }. If  
_WKP4 pin input is not specified, “_WKP4 pin input disabled” is set.  
(_WKP5 pin input) Specify one from { RAPI_WKP5_FALLING, RAPI_WKP5_RISING }. If  
_WKP5 pin input is not specified, “_WKP5 pin input disabled” is set.  
[data2]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register. For  
the CPUs that do not have an interrupt control register, specify 0.  
Return value  
If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise,  
Rev.1.01  
2007.02.16  
174  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
External interrupt  
__EnableInterrupt, __GetInterruptFlag, __ClearInterruptFlag  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable external interrupts differ with each CPU used.  
For the R8C, if its CPU type is the one that does not accept specification of “both edges” for  
interrupts to INT2 and INT3, RAPI_INT_BOTH cannot be specified for INT2 and INT3.  
Program example  
#include " rapi_interrupt_r8c_13.h"  
void IntFunc( void ){}  
void func( void )  
{
/* Set up _INT0 interrupt */  
__SetInterrupt( RAPI_INT0|RAPI_INT_FALLING, 0, IntFunc );  
}
Rev.1.01  
2007.02.16  
175  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableInterrupt  
Synopsis  
<Control external interrupt>  
Boolean __EnableInterrupt(unsigned long data1, unsigned int data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Setup data 2 (content differs with MCU type)  
Description  
Changes the operating condition of a specified external interrupt.  
[data1]  
The following definition values can be set for data1. To specify multiple definition values at the  
same time, use the symbol “|” to separate each specified value. Note, however, that multiple  
external interrupts cannot be specified at the same time.  
(M16C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_INT4  
RAPI_INT5  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses _INT4 interrupt.  
Uses _INT5 interrupt.  
Uses key input interrupt.  
(R8C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses key input interrupt.  
(H8/300H)  
RAPI_IRQ0  
Uses IRQ0 interrupt.  
RAPI_IRQ1  
Uses IRQ1 interrupt.  
RAPI_IRQ2  
Uses IRQ2 interrupt.  
RAPI_IRQ3  
Uses IRQ3 interrupt.  
RAPI_WKP  
Uses WKP interrupt.  
RAPI_NOT_INT_  
REQUEST  
Does not request assertion of interrupt for a selected external  
interrupt. (Default)  
RAPI_INT_REQUEST  
Requests assertion of interrupt for a selected external interrupt.  
[data2]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register. For  
the CPUs that do not have an interrupt control register, specify 0.  
Rev.1.01  
2007.02.16  
176  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Return value  
If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
External interrupt  
__SetInterrupt, __GetInterruptFlag, __ClearInterruptFlag  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable external interrupts differ with each CPU used.  
Program example  
#include " rapi_interrupt_r8c_13.h"  
void func( void )  
{
/* Activate _INT1 interrupt ( interrupt priority level 5 ) */  
__EnableInterrupt(RAPI_INT1, 5 );  
}
Rev.1.01  
2007.02.16  
177  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetInterruptFlag  
Synopsis  
<Get the status of external interrupt flag>  
Boolean __GetInterruptFlag(unsigned long data1, unsigned int *data2))  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the buffer in which the acquired flag data is stored  
Description  
Gets the value of interrupt request flag of a specified external interrupt.  
[data1]  
(M16C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_INT4  
RAPI_INT5  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses _INT4 interrupt.  
Uses _INT5 interrupt.  
Uses key input interrupt.  
(R8C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses key input interrupt.  
(H8/300H)  
RAPI_IRQ0  
RAPI_IRQ1  
RAPI_IRQ2  
RAPI_IRQ3  
RAPI_WKP0  
RAPI_WKP1  
RAPI_WKP2  
RAPI_WKP3  
RAPI_WKP4  
RAPI_WKP5  
Uses IRQ0 interrupt.  
Uses IRQ1 interrupt.  
Uses IRQ2 interrupt.  
Uses IRQ3 interrupt.  
Uses WKP0 interrupt.  
Uses WKP1 interrupt.  
Uses WKP2 interrupt.  
Uses WKP3 interrupt.  
Uses WKP4 interrupt.  
Uses WKP5 interrupt.  
[data2]  
0 0 0 0 0 0 0  
Value of interrupt request flag (0: Interrupt not requested; 1: Interrupt requested)  
Return value  
If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Rev.1.01  
2007.02.16  
178  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Functionality  
Reference  
Remark  
External interrupt  
__SetInterrupt, __EnableInterrupt, __ClearInterruptFlag  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable external interrupts differ with each CPU used.  
Program example  
#include " rapi_interrupt_r8c_13.h"  
void func( void )  
{
unsigned char data;  
/* Get flag of _INT2 interrupt */  
__GetInterruptFlag( IS_INT2, &data );  
}
Rev.1.01  
2007.02.16  
179  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__ClearInterruptFlag  
Synopsis  
<Clear external interrupt flag>  
Boolean __ClearInterruptFlag(unsigned long data)  
data  
Setup data (content differs with MCU type)  
Description  
Clears the interrupt request flag of a specified external interrupt.  
[data]  
(M16C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_INT4  
RAPI_INT5  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses _INT4 interrupt.  
Uses _INT5 interrupt.  
Uses key input interrupt.  
(R8C)  
RAPI_INT0  
RAPI_INT1  
RAPI_INT2  
RAPI_INT3  
RAPI_KEY  
Uses _INT0 interrupt.  
Uses _INT1 interrupt.  
Uses _INT2 interrupt.  
Uses _INT3 interrupt.  
Uses key input interrupt.  
(H8/300H)  
RAPI_IRQ0  
RAPI_IRQ1  
RAPI_IRQ2  
RAPI_IRQ3  
RAPI_WKP0  
RAPI_WKP1  
RAPI_WKP2  
RAPI_WKP3  
RAPI_WKP4  
RAPI_WKP5  
Uses IRQ0 interrupt.  
Uses IRQ1 interrupt.  
Uses IRQ2 interrupt.  
Uses IRQ3 interrupt.  
Uses WKP0 interrupt.  
Uses WKP1 interrupt.  
Uses WKP2 interrupt.  
Uses WKP3 interrupt.  
Uses WKP4 interrupt.  
Uses WKP5 interrupt.  
Return value  
If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise,  
RAPI_TRUE is returned.  
Functionality  
Reference  
Remark  
External interrupt  
__SetInterrupt, __EnableInterrupt, __GetInterruptFlag  
If an undefined value is specified in the first argument, operation of the API cannot  
Rev.1.01  
2007.02.16  
180  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
be guaranteed.  
The specifiable external interrupts differ with each CPU used.  
Program example  
#include " rapi_interrupt_r8c_13.h"  
void func( void )  
{
/* Clear status of _INT0 interrupt */  
__ClearInterruptFlag( RAPI_INT0 );  
}
Rev.1.01  
2007.02.16  
181  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
4.2.5 A/D converter  
__CreateADC  
Synopsis  
<Set A/D converter>  
Boolean __CreateADC(unsigned long data1, unsigned int data2, unsigned int  
data3, void* func)  
data1  
data2  
data3  
func  
Setup data 1 (content differs with MCU type)  
Number of analog input pins used by A/D converter (differs with MCU type)  
Setup data 3 (content differs with MCU type)  
Callback function pointer  
(Specify 0 if no callback functions are set.)  
Description  
Sets the A/D converter to specified mode and operating condition.  
[data1]  
For data1, the following definition values can be set. To set multiple definition values at  
the same time, use the symbol “|” to separate each specified value. Note, however,  
that multiple analog input pin symbols cannot be specified at the same time.  
(M16C)  
RAPI_ONE_SHOT  
RAPI_REPEAT  
RAPI_SINGLE_SWEEP  
RAPI_REPEAT_SWEEP0  
RAPI_REPEAT_SWEEP1  
RAPI_SIMULTANEOUS_  
SAMPLE_SWEEP  
RAPI_DELAYED_TRIGGER0  
RAPI_DELAYED_TRIGGER1  
RAPI_AN0  
Selects one-shot mode.  
Selects repeat mode.  
Selects single sweep mode.  
Selects repeat sweep mode 0.  
Selects repeat sweep mode 1.  
Selects simultaneous sampling sweep mode.  
Selects delayed trigger mode 0.  
Selects delayed trigger mode 1.  
Uses AN0 pin for the analog input pin.  
Uses AN1 pin for the analog input pin.  
Uses AN2 pin for the analog input pin.  
Uses AN3 pin for the analog input pin.  
Uses AN4 pin for the analog input pin.  
Uses AN5 pin for the analog input pin.  
Uses AN6 pin for the analog input pin.  
Uses AN7 pin for the analog input pin.  
Uses AN00 pin for the analog input pin.  
Uses AN01 pin for the analog input pin.  
Uses AN02 pin for the analog input pin.  
Uses AN03 pin for the analog input pin.  
Uses AN04 pin for the analog input pin.  
Uses AN05 pin for the analog input pin.  
Uses AN06 pin for the analog input pin.  
Uses AN07 pin for the analog input pin.  
Uses AN20 pin for the analog input pin.  
Uses AN21 pin for the analog input pin.  
RAPI_AN1  
RAPI_AN2  
RAPI_AN3  
RAPI_AN4  
RAPI_AN5  
RAPI_AN6  
RAPI_AN7  
RAPI_AN00  
RAPI_AN01  
RAPI_AN02  
RAPI_AN03  
RAPI_AN04  
RAPI_AN05  
RAPI_AN06  
RAPI_AN07  
RAPI_AN20  
RAPI_AN21  
Rev.1.01  
2007.02.16  
182  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_AN22  
Uses AN22 pin for the analog input pin.  
Uses AN23 pin for the analog input pin.  
Uses AN24 pin for the analog input pin.  
Uses AN25 pin for the analog input pin.  
Uses AN26 pin for the analog input pin.  
Uses AN27 pin for the analog input pin.  
Uses AN30 pin for the analog input pin.  
Uses AN31 pin for the analog input pin.  
Uses AN32 pin for the analog input pin.  
Uses port P0 group for the analog input pin.  
Uses port P10 group for the analog input pin.  
Uses port P1/P9 group for the analog input pin.  
Uses port P9 group for the analog input pin.  
Sets the AD converter’s operating frequency to fAD  
RAPI_AN23  
RAPI_AN24  
RAPI_AN25  
RAPI_AN26  
RAPI_AN27  
RAPI_AN30  
RAPI_AN31  
RAPI_AN32  
RAPI_P0_GROUP  
RAPI_P10_GROUP  
RAPI_P1P9_GROUP  
RAPI_P9_GROUP  
RAPI_FAD  
.
Sets the AD converter’s operating frequency to fAD divided by 2.  
Sets the AD converter’s operating frequency to fAD divided by 3.  
Sets the AD converter’s operating frequency to fAD divided by 4.  
Sets the AD converter’s operating frequency to fAD divided by 6.  
Sets the AD converter’s operating frequency to fAD divided by 12.  
Sets the AD converter’s resolution to 10 bits.  
RAPI_FAD2  
RAPI_FAD3  
RAPI_FAD4  
RAPI_FAD6  
RAPI_FAD12  
RAPI_10BIT  
RAPI_8BIT  
Sets the AD converter’s resolution to 8 bits.  
RAPI_AD_ON  
Sets the AD converter to start operating.  
RAPI_AD_OFF  
RAPI_WITH_SAMPLE_HOLD  
RAPI_WITHOUT_SAMPLE_  
HOLD  
Sets the AD converter to stop operating.  
Specifies that sample-and-hold action is applied.  
Specifies that sample-and-hold action is not applied.  
RAPI_SOFTWARE_TRIGGER  
RAPI_EXTERNAL_TRIGGER  
RAPI_TIMER_B0_TRIGGER  
RAPI_TIMER_B2_TRIGGER  
RAPI_ICTB2_TRIGGER  
Selects software trigger.  
Selects external trigger.  
Selects underflow of timer B0 as trigger.  
Selects underflow of timer B2 as trigger.  
Selects underflow of timer B2 interrupt generation  
frequency set counter as trigger.  
• Specifiable definition values when one-shot mode is used (RAPI_ONE_SHOT specified)  
Specify one from { RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3, RAPI_AN4,  
RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN00, RAPI_AN01, RAPI_AN02,  
RAPI_AN03, RAPI_AN04, RAPI_AN05, RAPI_AN06, RAPI_AN07, RAPI_AN20,  
RAPI_AN21, RAPI_AN22, RAPI_AN23, RAPI_AN24, RAPI_AN25, RAPI_AN26,  
RAPI_AN27, RAPI_AN30, RAPI_AN31, RAPI_AN32 }. The default is RAPI_AN0.  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
(Input pin)  
(Operating  
frequency)  
(Resolution)  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Rev.1.01  
2007.02.16  
183  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }. The default value is  
RAPI_WITHOUT_SAMPLE_HOLD.  
(Conversion  
method)  
(Trigger)  
Specify one from { RAPI_SOFTWARE_TRIGGER,  
RAPI_EXTERNAL_TRIGGER }.  
The default value is RAPI_SOFTWARE_TRIGGER.  
• Specifiable definition values when repeat mode is used (RAPI_REPEAT specified)  
Specify one from { RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3, RAPI_AN4,  
RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN00, RAPI_AN01, RAPI_AN02,  
RAPI_AN03, RAPI_AN04, RAPI_AN05, RAPI_AN06, RAPI_AN07, RAPI_AN20,  
RAPI_AN21, RAPI_AN22, RAPI_AN23, RAPI_AN24, RAPI_AN25, RAPI_AN26,  
RAPI_AN27, RAPI_AN30, RAPI_AN31, RAPI_AN32 }. The default is RAPI_AN0.  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
(Input pin)  
(Operating  
frequency)  
(Resolution)  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Conversion  
method)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }.  
The default value is RAPI_WITHOUT_SAMPLE_HOLD.  
Specify one from { RAPI_SOFTWARE_TRIGGER,  
RAPI_EXTERNAL_TRIGGER }.  
(Trigger)  
The default value is RAPI_SOFTWARE_TRIGGER.  
• Specifiable definition values when single sweep mode is used  
(RAPI_SINGLE_SWEEP specified)  
(Input pin)  
Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP,  
RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is  
RAPI_P10_GROUP.  
(Operating  
frequency)  
(Resolution)  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Conversion  
method)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }.  
The default value is RAPI_WITHOUT_SAMPLE_HOLD.  
Specify one from { RAPI_SOFTWARE_TRIGGER,  
RAPI_EXTERNAL_TRIGGER }.  
(Trigger)  
The default value is RAPI_SOFTWARE_TRIGGER.  
• Specifiable definition values when repeat sweep mode 0 is used  
(RAPI_REPEAT_SWEEP0 specified)  
(Input pin)  
Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP,  
RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is  
RAPI_P10_GROUP.  
(Operating  
frequency)  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Rev.1.01  
2007.02.16  
184  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Resolution)  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Conversion  
method)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }. The default value is  
RAPI_WITHOUT_SAMPLE_HOLD.  
Specify one from { RAPI_SOFTWARE_TRIGGER,  
RAPI_EXTERNAL_TRIGGER }. The default value is  
RAPI_SOFTWARE_TRIGGER.  
(Trigger)  
• Specifiable definition values when repeat sweep mode 1 is used  
(RAPI_REPEAT_SWEEP1 specified)  
(Input pin)  
Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP,  
RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is  
RAPI_P10_GROUP.  
(Operating  
frequency)  
(Resolution)  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Conversion  
method)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }.  
The default value is RAPI_WITHOUT_SAMPLE_HOLD.  
Specify one from { RAPI_SOFTWARE_TRIGGER,  
RAPI_EXTERNAL_TRIGGER }.  
(Trigger)  
The default value is RAPI_SOFTWARE_TRIGGER.  
• Specifiable definition values when simultaneous sampling sweep mode is used  
(RAPI_SIMULTANEOUS_SAMPLE_SWEEP specified)  
(Input pin)  
Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP,  
RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is  
RAPI_P10_GROUP.  
(Operating  
frequency)  
(Resolution)  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Trigger)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_SOFTWARE_TRIGGER, RAPI_EXTERNAL_TRIGGER,  
RAPI_TIMER_B0_TRIGGER, RAPI_TIMER_B2_TRIGGER,  
RAPI_ICTB2_TRIGGER }. The default value is RAPI_SOFTWARE_TRIGGER.  
• Specifiable definition values when delayed trigger mode 0 is used  
(RAPI_DELAYED_TRIGGER0 specified)  
(Input pin)  
Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP,  
RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is  
RAPI_P10_GROUP.  
(Operating  
frequency)  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Rev.1.01  
2007.02.16  
185  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Resolution)  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
Specify RAPI_WITH_SAMPLE_HOLD.  
(Conversion  
method)  
• Specifiable definition values when delayed trigger mode 1 is used  
(RAPI_DELAYED_TRIGGER1 specified)  
(Input pin)  
Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP,  
RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is  
RAPI_P10_GROUP.  
(Operating  
frequency)  
(Resolution)  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4,  
RAPI_FAD6, RAPI_FAD12 }. The default value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
Specify RAPI_WITH_SAMPLE_HOLD.  
(Conversion  
method)  
(R8C)  
RAPI_ONE_SHOT  
RAPI_REPEAT  
RAPI_AN0  
Selects one-shot mode.  
Selects repeat mode.  
Uses AN0 pin for the analog input pin.  
Uses AN1 pin for the analog input pin.  
Uses AN2 pin for the analog input pin.  
Uses AN3 pin for the analog input pin.  
Uses AN4 pin for the analog input pin.  
Uses AN5 pin for the analog input pin.  
Uses AN6 pin for the analog input pin.  
Uses AN7 pin for the analog input pin.  
Uses AN8 pin for the analog input pin.  
Uses AN9 pin for the analog input pin.  
Uses AN10 pin for the analog input pin.  
Uses AN11 pin for the analog input pin.  
Sets the AD converter’s operating frequency to fAD  
RAPI_AN1  
RAPI_AN2  
RAPI_AN3  
RAPI_AN4  
RAPI_AN5  
RAPI_AN6  
RAPI_AN7  
RAPI_AN8  
RAPI_AN9  
RAPI_AN10  
RAPI_AN11  
RAPI_FAD  
.
RAPI_FAD2  
RAPI_FAD4  
RAPI_FOCOF  
RAPI_10BIT  
RAPI_8BIT  
Sets the AD converter’s operating frequency to fAD divided by 2.  
Sets the AD converter’s operating frequency to fAD divided by 4.  
Sets the AD converter’s operating frequency to fOCO-F.  
Sets the AD converter’s resolution to 10 bits.  
Sets the AD converter’s resolution to 8 bits.  
RAPI_AD_ON  
RAPI_AD_OFF  
RAPI_WITH_SAMPLE_  
HOLD  
Sets the AD converter to start operating in __CreateAD.  
Sets the AD converter to stop operating in __CreateAD  
Specifies that sample-and-hold action is applied.  
RAPI_WITHOUT_  
SAMPLE_HOLD  
Specifies that sample-and-hold action is not applied.  
Rev.1.01  
2007.02.16  
186  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_SOFTWARE_TRI  
GGER  
Selects software trigger.  
RAPI_TIMER_RD_TRIG Selects timer RD as trigger.  
GER  
• Specifiable definition values when one-shot mode is used (RAPI_ONE_SHOT specified)  
(Input pin)  
Specify one from  
{
RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3,  
RAPI_AN4, RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN8, RAPI_AN9,  
RAPI_AN10, RAPI_AN11 }. Always be sure to specify an input pin.  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD4, RAPI_FOCOF }.  
The default value is RAPI_FAD4.  
(Operating  
frequency)  
(Resolution)  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Conversion  
method)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }.  
The default value is RAPI_WITHOUT_SAMPLE_HOLD.  
(Trigger)  
Specify  
one  
from  
{
RAPI_SOFTWARE_TRIGGER,  
The default value is  
RAPI_TIMER_RD_TRIGGER  
RAPI_SOFTWARE_TRIGGER.  
}.  
• Specifiable definition values when repeat mode is used (RAPI_REPEAT specified)  
Specify one from  
{
RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3,  
(Input pin)  
RAPI_AN4, RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN8, RAPI_AN9,  
RAPI_AN10, RAPI_AN11}. Always be sure to specify an input pin.  
Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD4 }. The default  
(Operating  
frequency)  
(Resolution)  
value is RAPI_FAD4.  
Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is  
RAPI_8BIT.  
(Operating  
states set)  
(Conversion  
method)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_WITH_SAMPLE_HOLD,  
RAPI_WITHOUT_SAMPLE_HOLD }.  
The default value is RAPI_WITHOUT_SAMPLE_HOLD.  
(Trigger)  
Specify  
one  
from  
{
RAPI_SOFTWARE_TRIGGER,  
The default value is  
RAPI_TIMER_RD_TRIGGER  
RAPI_SOFTWARE_TRIGGER.  
}.  
(H8/300H)  
RAPI_ONE_SHOT  
RAPI_REPEAT  
RAPI_SINGLE_SWEEP  
RAPI_REPEAT_SWEEP0  
RAPI_AN0  
Selects one-shot mode.  
Selects repeat mode.  
Selects single sweep mode.  
Selects repeat sweep mode 0.  
Uses AN0 pin for the analog input pin.  
Uses AN1 pin for the analog input pin.  
Uses AN2 pin for the analog input pin.  
Uses AN3 pin for the analog input pin.  
RAPI_AN1  
RAPI_AN2  
RAPI_AN3  
Rev.1.01  
2007.02.16  
187  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_AN4  
Uses AN4 pin for the analog input pin.  
Uses AN5 pin for the analog input pin.  
Uses AN6 pin for the analog input pin.  
Uses AN7 pin for the analog input pin.  
Uses AN8 pin for the analog input pin.  
Uses AN9 pin for the analog input pin.  
Uses AN10 pin for the analog input pin.  
Uses AN11 pin for the analog input pin.  
Uses AN12 pin for the analog input pin.  
Uses AN13 pin for the analog input pin.  
Uses AN14 pin for the analog input pin.  
Uses AN15 pin for the analog input pin.  
Uses AN0AN3 group for the analog input pin.  
Uses AN4AN7 group for the analog input pin.  
Uses AN8AN11 group for the analog input pin.  
Uses AN12AN15 group for the analog input pin.  
Conversion time = 134 states  
RAPI_AN5  
RAPI_AN6  
RAPI_AN7  
RAPI_AN8  
RAPI_AN9  
RAPI_AN10  
RAPI_AN11  
RAPI_AN12  
RAPI_AN13  
RAPI_AN14  
RAPI_AN15  
RAPI_AN0_GROUP  
RAPI_AN4_GROUP  
RAPI_AN8_GROUP  
RAPI_AN12_GROUP  
RAPI_134_STATES  
RAPI_70_STATES  
RAPI_AD_ON  
RAPI_AD_OFF  
RAPI_RISING_TRIGGER  
Conversion time = 70 states  
Sets the AD converter to start operating in __CreateAD.  
Sets the AD converter to stop operating in __CreateAD.  
Includes a rising-edge external trigger in the A/D conversion  
start condition.  
RAPI_FALLING_TRIGGER Includes a falling-edge external trigger in the A/D conversion  
start condition.  
RAPI_AD_INT_REQUEST Requests assertion of interrupt for A/D conversion interrupt.  
RAPI_NOT_AD_INT_  
REQUEST  
Does not request assertion of interrupt for A/D conversion  
interrupt.  
• Specifiable definition values when one-shot mode is used (RAPI_ONE_SHOT specified)  
(Input pin)  
Specify one from { RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3, RAPI_AN4,  
RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN8, RAPI_AN9, RAPI_AN10,  
RAPI_AN11, RAPI_AN12, RAPI_AN13, RAPI_AN14, RAPI_AN15 }. The default  
value is RAPI_AN0.  
(Conversion  
time)  
Specify one from { RAPI_134_STATES, RAPI_70_STATES }. The default  
value is RAPI_134_STATES.  
(Operating  
states set)  
(Trigger)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_RISING_TRIGGER, RAPI_FALLING_TRIGGER }.  
If no triggers are specified, “Trigger input disabled” is set.  
Specify one from { RAPI_AD_INT_REQUEST,  
RAPI_NOT_AD_INT_REQUEST }.  
(Interrupt  
request)  
The default value is RAPI_NOT_AD_INT_REQUEST.  
• Specifiable definition values when repeat mode is used (RAPI_REPEAT specified)  
Rev.1.01  
2007.02.16  
188  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
(Input pin)  
Specify one from { RAPI_AN0, RAPI_AN1, RAPI_AN2, RAPI_AN3, RAPI_AN4,  
RAPI_AN5, RAPI_AN6, RAPI_AN7, RAPI_AN8, RAPI_AN9, RAPI_AN10,  
RAPI_AN11, RAPI_AN12, RAPI_AN13, RAPI_AN14, RAPI_AN15 } The default  
value is RAPI_AN0.  
(Conversion  
time)  
Specify one from { RAPI_134_STATES, RAPI_70_STATES }. The default  
value is RAPI_134_STATES.  
(Operating  
states set)  
(Trigger)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_RISING_TRIGGER, RAPI_FALLING_TRIGGER }.  
If no triggers are specified, “Trigger input disabled” is set.  
• Specifiable definition values when single sweep mode is used  
(RAPI_SINGLE_SWEEP specified)  
(Input pin)  
Specify  
one  
from  
{
RAPI_AN0_GROUP,  
RAPI_AN4_GROUP,  
RAPI_AN8_GROUP, RAPI_AN12_GROUP }.  
The default value is RAPI_AN0_GROUP.  
(Conversion  
time)  
Specify one from { RAPI_134_STATES, RAPI_70_STATES }. The default  
value is RAPI_134_STATES.  
(Operating  
states set)  
(Trigger)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_RISING_TRIGGER, RAPI_FALLING_TRIGGER }.  
If no triggers are specified, “Trigger input disabled” is set.  
Specify one from { RAPI_AD_INT_REQUEST,  
(Interrupt  
request)  
RAPI_NOT_AD_INT_REQUEST }.  
The default value is RAPI_NOT_AD_INT_REQUEST.  
• Specifiable definition values when repeat sweep mode 0 is used  
(RAPI_REPEAT_SWEEP0 specified)  
(Input pin)  
Specify  
one  
from  
{
RAPI_AN0_GROUP,  
RAPI_AN4_GROUP,  
RAPI_AN8_GROUP, RAPI_AN12_GROUP }. The default value is  
RAPI_AN0_GROUP.  
(Conversion  
time)  
Specify one from { RAPI_134_STATES, RAPI_70_STATES }. The default  
value is RAPI_134_STATES.  
(Operating  
states set)  
(Trigger)  
Specify one from { RAPI_AD_ON, RAPI_AD_OFF }. The default value is  
RAPI_AD_OFF.  
Specify one from { RAPI_RISING_TRIGGER, RAPI_FALLING_TRIGGER }.  
If no triggers are specified, “Trigger input disabled” is set.  
[data2]  
(M16C)  
The set value differs with the A/D conversion mode used.  
One-shot mode  
Specify 1.  
Repeat mode  
Single sweep mode  
Repeat sweep mode 0  
Simultaneous sampling mode  
Delayed trigger mode 0  
Specify 2, 4, 6, or 8.  
Rev.1.01  
2007.02.16  
189  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Delayed trigger mode 1  
Repeat sweep mode  
Specify 1, 2, 3, or 4.  
(R8C)  
Specify 1.  
(H8/300H)  
One-shot mode  
Specify 1.  
Repeat mode  
Single sweep mode  
Repeat sweep mode 0  
Specify 1, 2, 3, or 4.  
[data3]  
(M16C) (R8C)  
Specify the interrupt priority level (07) to be set in the interrupt control register.  
(H8/300H)  
Specify the interrupt priority level (0–1) to be set in the interrupt control register.  
For the CPUs that do not have an interrupt control register, specify 0.  
Return value  
If A/D converter was successfully set, RAPI_TRUE is returned; if failed, RAPI_FALSE  
is returned.  
Functionality  
Reference  
Remark  
A/D converter  
__EnableADC, __DestroyADC, __GetADC, __GetADCAll  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable analog input pins differ with each CPU used.  
If you use an R8C MCU which does not support fOCO-F for its operating frequency, you  
cannot specify RAPI_FOCOF.  
If you use an R8C MCU which does not support timer RD as a trigger, you cannot specify  
RAPI_TIMER_RD_TRIGGER as a trigger.  
When used for the H8/300H, this API specify when freeing it from module stanby.  
Program example  
#include " rapi_ad_r8c_13.h"  
void AdIntFunc( void ){}  
void func( void )  
{
/* Set up A/D converter as one short mode */  
__CreateADC( RAPI_ONE_SHOT|RAPI_AN2|RAPI_FAD2| RAPI_WITH_SAMPLE_HOLD  
|
RAPI_EXTERNAL_TRIGGER  
|RAPI_AD_ON|RAPI_10BIT,  
1,  
5,  
AdIntFunc );  
}
Rev.1.01  
2007.02.16  
190  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__EnableADC  
Synopsis  
<Control operation of A/D converter>  
Boolean __EnableADC (unsigned long data1, unsigned int data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Number of analog input pins used by A/D converter (differs with MCU type)  
Description  
Controls operation of the A/D converter by starting or stopping it.  
[data1]  
(M16C)  
RAPI_AN0  
RAPI_AN1  
RAPI_AN2  
RAPI_AN3  
RAPI_AN4  
RAPI_AN5  
RAPI_AN6  
RAPI_AN7  
RAPI_AN00  
RAPI_AN01  
RAPI_AN02  
RAPI_AN03  
RAPI_AN04  
RAPI_AN05  
RAPI_AN06  
RAPI_AN07  
RAPI_AN20  
Uses AN0 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN1 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN2 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN3 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN4pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN5pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN6 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN7 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN00 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN01 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN02 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN03 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN04 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN05pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN06 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN07 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN20 pin for the analog input pin.  
Rev.1.01  
2007.02.16  
191  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN21 pin for the analog input pin.  
RAPI_AN21  
RAPI_AN22  
RAPI_AN23  
RAPI_AN24  
RAPI_AN25  
RAPI_AN26  
RAPI_AN27  
RAPI_AN30  
RAPI_AN31  
RAPI_AN32  
RAPI_P0_GROUP  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN22 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN23 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN24 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN25 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN26 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN27 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN30 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN31 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN32 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses port P0 group for the analog input pin. Selectable only when  
sweep mode, repeat sweep mode 0, simultaneous sampling sweep  
mode, delayed trigger mode 0, delayed trigger mode 1, or repeat sweep  
mode 1 is used.  
RAPI_P10_GROUP Uses port P10 group for the analog input pin. Selectable only when  
sweep mode, repeat sweep mode 0, simultaneous sampling sweep  
mode, delayed trigger mode 0, delayed trigger mode 1, or repeat sweep  
mode 1 is used.  
RAPI_P1P9_GROUP Uses port P1 /P9 group for the analog input pin. Selectable only when  
sweep mode, repeat sweep mode 0, simultaneous sampling sweep  
mode, delayed trigger mode 0, delayed trigger mode 1, or repeat sweep  
mode 1 is used.  
RAPI_P9_GROUP  
Uses port P9 group for the analog input pin. Selectable only when  
sweep mode, repeat sweep mode 0, simultaneous sampling sweep  
mode, delayed trigger mode 0, delayed trigger mode 1, or repeat sweep  
mode 1 is used.  
RAPI_AD_ON  
RAPI_AD_OFF  
Sets the A/D converter to start operating.  
Sets the A/D converter to stop operating.  
(R8C)  
RAPI_AN0  
RAPI_AN1  
RAPI_AN2  
RAPI_AN3  
Uses AN0 pin for the analog input pin.  
Uses AN1 pin for the analog input pin.  
Uses AN2 pin for the analog input pin.  
Uses AN3 pin for the analog input pin.  
Rev.1.01  
2007.02.16  
192  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
RAPI_AN4  
RAPI_AN5  
RAPI_AN6  
RAPI_AN7  
RAPI_AN8  
RAPI_AN9  
RAPI_AN10  
RAPI_AN11  
RAPI_AD_ON  
RAPI_AD_OFF  
Uses AN4 pin for the analog input pin.  
Uses AN5 pin for the analog input pin.  
Uses AN6 pin for the analog input pin.  
Uses AN7 pin for the analog input pin.  
Uses AN8 pin for the analog input pin.  
Uses AN9 pin for the analog input pin.  
Uses AN10 pin for the analog input pin.  
Uses AN11 pin for the analog input pin.  
Sets the A/D converter to start operating.  
Sets the A/D converter to stop operating.  
(H8/300H)  
RAPI_AN0  
RAPI_AN1  
RAPI_AN2  
RAPI_AN3  
RAPI_AN4  
RAPI_AN5  
RAPI_AN6  
RAPI_AN7  
RAPI_AN8  
RAPI_AN9  
RAPI_AN10  
RAPI_AN11  
RAPI_AN12  
RAPI_AN13  
RAPI_AN14  
RAPI_AN15  
RAPI_AN0_GROUP  
Uses AN0 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN1 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN2 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN3 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN4 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN5 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN6 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN7 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN8 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN9 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN10 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN11 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN12 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN13 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN14 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN15 pin for the analog input pin.  
Selectable only when one-shot mode or repeat mode is used.  
Uses AN0-AN3 pins group for the analog input pin.  
Rev.1.01  
2007.02.16  
193  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Selectable only when sweep mode or repeat sweep mode 0 is used.  
Uses AN4-AN7 pins group for the analog input pin.  
RAPI_AN4_GROUP  
RAPI_AN8_GROUP  
Selectable only when sweep mode or repeat sweep mode 0 is used.  
Uses AN8-AN11 pins group for the analog input pin.  
Selectable only when sweep mode or repeat sweep mode 0 is used.  
RAPI_AN12_GROUP Uses AN12-AN15 pins group for the analog input pin.  
Selectable only when sweep mode or repeat sweep mode 0 is used.  
RAPI_AD_ON  
RAPI_AD_OFF  
Sets the A/D converter to start operating.  
Sets the A/D converter to stop operating.  
[data2]  
(M16C)  
The set value differs with the A/D conversion mode used.  
One-shot mode  
Specify 1.  
Repeat mode  
Single sweep mode  
Repeat sweep mode 0  
Simultaneous sampling mode  
Delayed trigger mode 0  
Delayed trigger mode 1  
Repeat sweep mode 1  
Specify 2, 4, 6, or 8.  
Specify 1, 2, 3, or 4.  
(R8C)  
Specify 1.  
(H8/300H)  
One-shot mode  
Specify 1.  
Repeat mode  
Single sweep mode  
Repeat sweep mode 0  
Specify 1, 2, 3, or 4.  
Return value  
Functionality  
If A/D converter was successfully controlled, RAPI_TRUE is returned; if failed,  
RAPI_FALSE is returned.  
A/D converter  
Reference  
Remark  
__CreateADC, __DestroyADC, __GetADC, __GetADCAll  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
The specifiable analog input pins differ with each CPU used.  
Program example  
#include "rapi_ad_r8c_13.h"  
Rev.1.01  
2007.02.16  
194  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
void func( void )  
{
/* Disable A/D converter */  
__EnableADC( RAPI_AN0|RAPI_AD_OFF, 1 );  
}
Rev.1.01  
2007.02.16  
195  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__DestroyADC  
Synopsis  
<Discard settings of A/D converter>  
Boolean __DestroyADC(void)  
Description  
Discards settings of a specified A/D converter.  
Return value  
If converter setting was successfully discarded, RAPI_TRUE is returned; if failed,  
RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
A/D converter  
__CreateADC, __EnableADC, __GetADC, __GetADCAll  
When used for the H8/300H, this API places a specified timer into module stanby  
state after discarding it.  
Program example  
#include "rapi_ad_r8c_13.h"  
void func( void )  
{
/* Destroy A/D converter */  
__DestroyADC();  
}
Rev.1.01  
2007.02.16  
196  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetADC  
Synopsis  
<Get A/D converted value (register specified)>  
Boolean __GetADC(unsigned long data1, unsigned int *data2)  
data1  
data2  
Setup data 1 (content differs with MCU type)  
Pointer to the buffer in which A/D converted value is stored.  
Description  
Gets the A/D converted value from a specified A/D register.  
For data1, the following values can be set.  
(M16C)  
RAPI_AD0  
RAPI_AD1  
RAPI_AD2  
RAPI_AD3  
RAPI_AD4  
RAPI_AD5  
RAPI_AD6  
RAPI_AD7  
Selects A/D register 0.  
Selects A/D register 1.  
Selects A/D register 2.  
Selects A/D register 3.  
Selects A/D register 4.  
Selects A/D register 5.  
Selects A/D register 6.  
Selects A/D register 7.  
(R8C)  
Specify 0.  
(H8/300H)  
RAPI_ADDRA  
RAPI_ADDRB  
RAPI_ADDRC  
RAPI_ADDRD  
Selects A/D data register A.  
Selects A/D data register B.  
Selects A/D data register C.  
Selects A/D data register D.  
Return value  
If A/D converted value was successfully acquired, RAPI_TRUE is returned; if failed,  
RAPI_FALSE is returned.  
Functionality  
Reference  
Remark  
A/D converter  
__CreateADC, __EnableADC, __DestroyADC, __GetADCAll  
If an undefined value is specified in the first argument, operation of the API cannot  
be guaranteed.  
Program example  
#include "rapi_ad_r8c_13.h"  
void func( void )  
{
unsigned int data;  
/* Get an A/D convertered data of A/D register 0 */  
__GetADC( RAPI_AD0, &data );  
}
Rev.1.01  
2007.02.16  
197  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetADCAll  
Synopsis  
<Get A/D converted value (all registers)>  
Boolean __GetADCAll(unsigned int *data)  
data  
Pointer to the buffer in which A/D converted value is stored.  
Description  
Gets the A/D converted value from all A/D registers.  
The A/D registers from which A/D converted values are acquired are listed below.  
[M16C]  
:
[0] A/D register 0  
[1] A/D register 1  
[2] A/D register 2  
[3] A/D register 3  
[4] A/D register 4  
[5] A/D register 5  
[6] A/D register 6  
[7] A/D register 7  
(16 bytes)  
[R8C]  
:
:
A/D register  
(2 bytes)  
[H8/300H]  
[0] A/D register A  
[1] A/D register B  
[2] A/D register C  
[3] A/D register D  
(8 bytes)  
Return value  
If A/D converted values were successfully acquired, RAPI_TRUE is returned; if failed,  
RAPI_FALSE is returned.  
Functionality  
Reference  
A/D converter  
__CreateADC, __EnableADC, __DestroyADC, __GetADC  
Program example  
#include "rapi_ad_r8c_13.h"  
void func( void )  
{
unsigned int data[8];  
/* Get A/D convertered datas of A/D register */  
__GetADCAll( data );  
}
Rev.1.01  
2007.02.16  
198  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__GetADCStatus  
Synopsis  
<Get the status of A/D converter>  
Boolean __GetADCStatus(unsigned int *status)  
status  
Pointer to the buffer in which the register content indicating A/D converter  
status is stored.  
Description  
Gets the status of a specified A/D converter.  
The status of interrupt bit (when using the M16C or R8C) or the value of A/D end flag  
(when using the H8/300H) is stored in the first low-order bit of *status. Furthermore,  
the status of A/D conversion start flag is stored in the second low-order bit of *status.  
When used in the M16C, the value of A/D conversion status register 0 is stored in the 8  
high-order bits of *status.  
[Configuration of *status]  
0 0 0 0 0 0  
Value of interrupt  
bit or A/D end flag  
Value of A/D conversion status Value of A/D conversion start flag (for only  
register 0 (for only the M16C; 0 for the R8C; 0 for the M16C and H8/300H)  
the R8C and H8/300H)  
Return value  
If A/D converter status was successfully acquired, RAPI_TRUE is returned; if failed,  
RAPI_FALSE is returned.  
Functionality  
Reference  
A/D converter  
__ClearADCStatus  
Program example  
#include " rapi_ad_r8c_13.h"  
void func( void )  
{
unsigned int status;  
/* Get status of A/D convertered */  
__GetADCStatus( &status );  
}
Rev.1.01  
2007.02.16  
199  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
__ClearADCStatus  
Synopsis  
<Clear the status of A/D converter>  
Boolean __ClearADCStatus(unsigned int status)  
status  
Status of A/D converter  
Description  
Clears the status flag of a specified A/D converter.  
Specify the status of interrupt bit (when using the M16C or R8C) or the value of A/D  
end flag (when using the H8/300H) in the first low-order bit of status.  
When used in the M16C, specify the value of A/D conversion status register 0 in the 8  
high-order bits of status. Write 0 to the bits to be cleared and 1 to the bits that do not  
need to be cleared.  
[Configuration of status]  
0 0 0 0 0 0 0  
Value of A/D conversion status register 0 (for Value of interrupt bit or  
only the M16C; 0 for the R8C and H8/300H)  
A/D end flag  
Return value  
If A/D converter status flag was successfully cleared, RAPI_TRUE is returned; if failed,  
RAPI_FALSE is returned.  
Functionality  
Reference  
A/D converter  
__GetADCStatus  
Program example  
#include "rapi_ad_r8c_13.h"  
void func( void )  
{
/* Clear status of A/D convertered */  
__ClearADCStatus( 0 );  
}
Rev.1.01  
2007.02.16  
200  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Renesas Embedded  
Application Programming Interface  
Reference Manual  
Rev. 1.01  
Issued: April 2007  
Rev.1.01  
2007.02.16  
201  
RJJ10J1643-0101  
Download from Www.Somanuals.com. All Manuals Search And Download.  
Renesas Embedded  
Application Programming Interface  
Reference manual  
2-6-2, Ote-machi, Chiyoda-ku, Tokyo,100-0004, Japan  
Download from Www.Somanuals.com. All Manuals Search And Download.  

PYLE Audio Speaker PSPVC4 User Guide
Rangemaster Oven Single Built in Oven User Guide
RCA Telephone 25825 User Guide
RIDGID Drill R82015 User Guide
Rose electronic Switch Vista Mini User Guide
Samsung Blu ray Player BD J5900 User Guide
Samsung Security Camera SCC C6407 User Guide
SATO Printer MI 6308 User Guide
Schwinn Home Gym 112212 User Guide
Seagate Computer Drive ST98823A User Guide