Renesas RJJ10J1643-0101 User manual

To our customers,
Old Company Name in Catalogs and Other Documents
On April 1st, 2010, NEC Electronics Corporation merged with Renesas Technology
Corporation, and Renesas Electronics Corporation took over all the business of both
companies. Therefore, although the old company name remains in this document, it is a valid
Renesas Electronics document. We appreciate your understanding.
Renesas Electronics website: http://www.renesas.com
April 1st, 2010
Renesas Electronics Corporation
Issued by: Renesas Electronics Corporation (http://www.renesas.com)
Send any inquiries to http://www.renesas.com/inquiry.

Notice
1. All information included in this document is current as of the date this document is issued. Such information, however, is
subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please
confirm the latest product information with a Renesas Electronics sales office. Also, please pay regular and careful attention to
additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website.
2. Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights
of third parties by or arising from the use of Renesas Electronics products or technical information described in this document.
No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights
of Renesas Electronics or others.
3. You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part.
4. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of
semiconductor products and application examples. You are fully responsible for the incorporation of these circuits, software,
and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by
you or third parties arising from the use of these circuits, software, or information.
5. When exporting the products or technology described in this document, you should comply with the applicable export control
laws and regulations and follow the procedures required by such laws and regulations. You should not use Renesas
Electronics products or the technology described in this document for any purpose relating to military applications or use by
the military, including but not limited to the development of weapons of mass destruction. Renesas Electronics products and
technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited
under any applicable domestic or foreign laws or regulations.
6. Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas Electronics
does not warrant that such information is error free. Renesas Electronics assumes no liability whatsoever for any damages
incurred by you resulting from errors in or omissions from the information included herein.
7. Renesas Electronics products are classified according to the following three quality grades: “Standard”, “High Quality”, and
“Specific”. The recommended applications for each Renesas Electronics product depends on the product’s quality grade, as
indicated below. You must check the quality grade of each Renesas Electronics product before using it in a particular
application. You may not use any Renesas Electronics product for any application categorized as “Specific” without the prior
written consent of Renesas Electronics. Further, you may not use any Renesas Electronics product for any application for
which it is not intended without the prior written consent of Renesas Electronics. Renesas Electronics shall not be in any way
liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an
application categorized as “Specific” or for which the product is not intended where you have failed to obtain the prior written
consent of Renesas Electronics. The quality grade of each Renesas Electronics product is “Standard” unless otherwise
expressly specified in a Renesas Electronics data sheets or data books, etc.
“Standard”: Computers; office equipment; communications equipment; test and measurement equipment; audio and visual
equipment; home electronic appliances; machine tools; personal electronic equipment; and industrial robots.
“High Quality”: Transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster systems; anti-
crime systems; safety equipment; and medical equipment not specifically designed for life support.
“Specific”: Aircraft; aerospace equipment; submersible repeaters; nuclear reactor control systems; medical equipment or
systems for life support (e.g. artificial life support devices or systems), surgical implantations, or healthcare
intervention (e.g. excision, etc.), and any other applications or purposes that pose a direct threat to human life.
8. You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics,
especially with respect to the maximum rating, operating supply voltage range, movement power voltage range, heat radiation
characteristics, installation and other product characteristics. Renesas Electronics shall have no liability for malfunctions or
damages arising out of the use of Renesas Electronics products beyond such specified ranges.
9. Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products have
specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. Further,
Renesas Electronics products are not subject to radiation resistance design. Please be sure to implement safety measures to
guard them against the possibility of physical injury, and injury or damage caused by fire in the event of the failure of a
Renesas Electronics product, such as safety design for hardware and software including but not limited to redundancy, fire
control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because
the evaluation of microcomputer software alone is very difficult, please evaluate the safety of the final products or system
manufactured by you.
10. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental
compatibility of each Renesas Electronics product. Please use Renesas Electronics products in compliance with all applicable
laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS
Directive. Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with
applicable laws and regulations.
11. This document may not be reproduced or duplicated, in any form, in whole or in part, without prior written consent of Renesas
Electronics.
12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this
document or Renesas Electronics products, or if you have any other inquiries.
(Note 1) “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its majority-
owned subsidiaries.
(Note 2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics.

Renesas Embedded
Application Programming Interface
Reference manual
User’s Manual
Rev.1.01 2007.02

Rev.1.01 2007.02.16
RJJ10J1643-0101
2
REVISION HISTORY
Rev. Summary Date
1.00 06.04.07
1.01 ・ Additions and corrections made for support of libraries for the H8/36094, H8/36077,
H8/36109, and R8C/24 and 25
・ Unnecessary periods in Chapter 1, “Instruction,” deleted
・ Port P73 of H8 deleted
・ Channels A–D written in CreateInputCapture corrected to input captures A–D
・ Error in writing “seroal” corrected to “serial”
・ Erroneous description of RAPI_70_STATES corrected
・ Error in writing of timer channel names corrected
・ Error in writing of input capture mode corrected
・ Error in writing of output compare mode corrected
・ Erroneous description of RAPI_OVERFLOW_BIT15 corrected
・ Support for R8C UART1 clock synchronous mode
・ RAPI_COUNT_CLEAR added to first arguments for the R8C and H8/300H in
__CreateInputCapture and __CreateOutputCompare
・ “External signal” deleted from the timer RD count source for the R8C in
__CreateInputCapture and __CreateOutputCompare
・ Following statements added to the item for timer RD in __SetTimerRegister and
__GetTimerRegister
・ [15]: Timer RD output master enable register 1
・ [16]: Timer RD output master enable register 2
・ [17]: Timer RD output control register
・ Explanation for clearing H8/300H module added to the description of __Create...,
__Open..., and __BasicOpen...
・ Explanation for setting H8/300H module for standby added to the description of
__Destroy..., __Close..., and BasicClose...
・ Return value in __PollingSerialReceiving changed from Boolean to unsigned int, and
explanation of return value and example program changed
・ Return value in __PollingSerialSending changed from Boolean to unsigned int, and
explanation of return value and example program changed
・ Remarks regarding use of port B on H8/300H added to __ReadIOPort and
__ReadIOPortRegister
07.02.16

Rev.1.01 2007.02.16
RJJ10J1643-0101
3
・ 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
RJJ10J1643-0101
4
・ 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
RJJ10J1643-0101
5
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
RJJ10J1643-0101
6
__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
RJJ10J1643-0101
7
__GetADC ............................................................. 197
__GetADCAll........................................................... 198
__GetADCStatus......................................................... 199
__ClearADCStatus ....................................................... 200

Rev.1.01 2007.02.16
RJJ10J1643-0101
8
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
RJJ10J1643-0101
9
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 Description
rapi_
xxx
_
yyy
.lib
(
xxx
= family name,
yyy
= series name)
This is the Renesas API library file. To use
Renesas APIs, specify this file as input file
for the linker.
rapi_ad_
xxx
_
yyy
.h
(
xxx
= family name,
yyy
= series name)
This is the header file for A/D converter
driver APIs. To use A/D converter driver
APIs, be sure to include this file.
rapi_io_port_
xxx
_
yyy
.h
(
xxx
= family name,
yyy
= series name)
This is the header file for I/O port driver
APIs. To use I/O port driver APIs, be sure
to include this file.
rapi_sif_
xxx
_
yyy
.h
(
xxx
= family name,
yyy
= series name)
This is the header file for serial I/F driver
APIs. To use serial I/F driver APIs, be sure
to include this file.
rapi_timer_
xxx
_
yyy
.h
(
xxx
= family name,
yyy
= series name)
This is the header file for timer driver
APIs. To use timer driver APIs, be sure to
include this file.
Interrupt_
xxx
_
yyy
.h
(
xxx
= family name,
yyy
= series name)
This is the interrupt function source file for
Renesas APIs. To use Renesas APIs that
use interrupts, add this file to the user
program.
rapi_io_
xxx
_
yyy
.h
(
xxx
= family name,
yyy
= series name)
This is the CPU control register definition
header file for Renesas APIs.

Rev.1.01 2007.02.16
RJJ10J1643-0101
10
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
RJJ10J1643-0101
11
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
RJJ10J1643-0101
12
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
RJJ10J1643-0101
13
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
RJJ10J1643-0101
14
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
RJJ10J1643-0101
15
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
RJJ10J1643-0101
16
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 : fAD divided by 2
Resolution : 10 bits
Analog input pin : AN0 pin
A/D conversion start condition : Software trigger
Sample-and-hold : Enabled
A program flow and a program example are shown below.
(Program flow)
_
_CreateADC()
_
_EnableADC()
_
_GetADCStatus()
_
_GetADC()
_
_ClearADCStatus()
main()
Set the A/D converter in
single-shot mode
Start A/D conversion
A/D interrupt?
Clear the A/D interrupt flag
No
Yes
Read out the A/D conversion value

Rev.1.01 2007.02.16
RJJ10J1643-0101
17
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
RJJ10J1643-0101
18
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.
This manual suits for next models
1
Table of contents
Other Renesas Software manuals
Popular Software manuals by other brands

Aruba Networks
Aruba Networks PowerConnect W Clearpass 100 Software manual

Novell
Novell LINUX ENTERPRISE DESKTOP 10 SP1 - KDE... manual

McAfee
McAfee TSA00M005PAA - Total Protection Service installation guide

Canon
Canon CanoScan FB 630U user guide

Barco
Barco DC Toolset user guide

MACROMEDIA
MACROMEDIA FLASH 8-FLASH Reference