Renesas RJJ10J1643-0101 Reference Manual
Renesas RJJ10J1643-0101 Reference Manual

Renesas RJJ10J1643-0101 Reference Manual

Renesas application programming interface reference manual
Table of Contents

Advertisement

Quick Links

To our customers,
st
On April 1
, 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.
Issued by: Renesas Electronics Corporation (http://www.renesas.com)
Send any inquiries to http://www.renesas.com/inquiry.
Old Company Name in Catalogs and Other Documents
Renesas Electronics website:
http://www.renesas.com
st
April 1
, 2010
Renesas Electronics Corporation

Advertisement

Table of Contents
loading

Summary of Contents for Renesas RJJ10J1643-0101

  • Page 1 On April 1 , 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.
  • Page 2 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”...
  • Page 3 Renesas Embedded Application Programming Interface Reference manual Rev.1.01 2007.02...
  • Page 4: Revision History

    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 Rev.1.01 2007.02.16 RJJ10J1643-0101 Summary Date 06.04.07 07.02.16...
  • Page 5 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 added “Reference” __SetSerialFormat output function added item...
  • Page 6 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 ・ __CreatePulsePeriodMeasurementMode and __CreatePulseWidthMeasurementMode deleted Rev.1.01 2007.02.16 RJJ10J1643-0101 timer input pins H8/300H...
  • Page 7: Table Of Contents

    __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 Table of Contents...
  • Page 8 __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...
  • Page 9 __GetADC ... 197 __GetADCAll ... 198 __GetADCStatus... 199 __ClearADCStatus ... 200 Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 10: Introduction

    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...
  • Page 11: Driver

    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.
  • Page 12: Driver Features

    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...
  • Page 13: Serial Interface Driver

    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...
  • Page 14: Timer Driver

    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...
  • Page 15: 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...
  • Page 16: I/O Port Driver

    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...
  • Page 17: External Interrupt Driver

    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...
  • Page 18: A/D Converter Driver

    Set the A/D converter in single-shot mode Start A/D conversion A/D interrupt? Read out the A/D conversion value Clear the A/D interrupt flag Rev.1.01 2007.02.16 RJJ10J1643-0101 fAD divided by 2 10 bits AN0 pin Software trigger Enabled __CreateADC() __EnableADC() __GetADCStatus()
  • Page 19: Program Example

    __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 RAPI_ONE_SHOT|RAPI_AN0|RAPI_FAD2| RAPI_AD_OFF|RAPI_10BIT, 1, 0, 0 );...
  • Page 20: Standard Types

    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 RJJ10J1643-0101...
  • Page 21: Library Reference

    4. Library Reference 4.1 API List by Peripheral Facility The table below lists the Renesas Embedded APIs classified by peripheral facility. Facility classification Single-data __BasicOpenSerialDriver serial I/O __BasicCloseSerialDriver __BasicSetSerialFormat __BasicStartSerialReceiving __BasicStartSerialSending __BasicReceivingStatusRead __BasicSendingStatusRead __BasicStopSerialReceiving __BasicStopSerialSending Multi-data __OpenSerialDriver serial I/O __CloseSerialDriver...
  • Page 22 __CreateADC __EnableADC __DestroyADC __GetADC __GetADCAll __GetADCStatus __ClearADCStatus Rev.1.01 2007.02.16 RJJ10J1643-0101 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...
  • Page 23: Description Of Each Api

    Indicates the functional classification of the function. • Functionality Indicates the related functions. • Reference Describes the precautions to be taken when using the API. • Remark • Program example : Presents a program showing how to use the function. Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 24: Serial I/O

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2...
  • Page 25: Basiccloseserialdriver

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2...
  • Page 26: Basicsetserialformat

    If the API is used in clock synchronous serial communication mode, do not set these values. (M16C) (UART0, UART1, UART2) RAPI_STPB_1 For the parity bit of clock asynchronous serial communication, the following values can be set. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 Setup data 2 UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4...
  • Page 27 For serial data logic switchover, the following values can be set. (M16C) (UART2) RAPI_LOGIC_NO_REV RAPI_LOGIC_REV (R8C) RAPI_COM1 For serial communication mode, the following values can be set. Rev.1.01 2007.02.16 RJJ10J1643-0101 No parity bit RAPI_PARITY_EVEN Odd parity bit Polarity not inverted RAPI_DPOL_INV Polarity not inverted RAPI_SIO_DPOL_INV f1SIO...
  • Page 28 (R8C) (UART0, UART1) RAPI_LSB_SEL (H8/300H) RAPI_COM1 Rev.1.01 2007.02.16 RJJ10J1643-0101 Clock synchronous serial communication mode Clock asynchronous serial communication mode Transfer data length 7 bits RAPI_BIT_8 Transfer data length 9 bits Internal clock is used as the clock source of serial communication.
  • Page 29 Sets the divide-by-N value of a communication speed. If serial communication was successfully set, RAPI_TRUE is returned; if settings failed, Return value RAPI_FALSE is returned. Rev.1.01 2007.02.16 RJJ10J1643-0101 SCI3 channel 3 Clock synchronous serial communication mode Clock asynchronous serial communication mode Transfer data length 7 bits RAPI_BIT_8 Internal clock is used as the clock source of serial communication.
  • Page 30 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 20); Rev.1.01 2007.02.16 RJJ10J1643-0101 RAPI_BCSS_F1 | RAPI_DPOL_NON | RAPI_LSB_SEL,...
  • Page 31: Basicstartserialreceiving

    • 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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2...
  • Page 32: Basicstartserialsending

    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 RJJ10J1643-0101 Setup data Transmit data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4...
  • Page 33: Basicreceivingstatusread

    Other than above (R8C) RAPI_RX_INCOMPLETE Other than above (H8/300H) RAPI_RX_INCOMPLETE Other than above Serial I/O Functionality __BasicStartSerialReceiving, Reference Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2 SCI3 channel 1 RAPI_COM2 SCI3 channel 3 Reception not complete yet.
  • Page 34 The specifiable serial ports differ with each CPU used. Remark • 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 ) unsigned int rcv_data; rcv_data = __BasicReceivingStatusRead( RAPI_COM1 ); Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 35: Basicsendingstatusread

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2...
  • Page 36: Basicstopserialreceiving

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 UART0 RAPI_COM2 SCI3 channel 1 RAPI_COM2 SCI3 channel 3...
  • Page 37: Basicstopserialsending

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 UART0 RAPI_COM2 SCI3 channel 1 RAPI_COM2 SIO3 channel 3...
  • Page 38: Openserialdriver

    Program example #include ”rapi_sif_r8c_13.h” void func( void ) ……………… /* Open serial driver */ return __OpenSerialDriver( RAPI_COM1 ); ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2 SCI3 channel 1...
  • Page 39: Closeserialdriver

    Program example #include ”rapi_sif_r8c_13.h” void func( void ) ……………… /* Close serial driver */ return __CloseSerialDriver( RAPI_COM1 ); ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2 SCI3 channel 1 RAPI_COM2...
  • Page 40: Configserialdrivernotify

    “any function name” (unsigned char notify); The argument is detailed below. (M16C) (UART0, UART1, UART2) b7 b6 b5 b4 b3 b2 b1 b0 (M16C) (SI/O3,SI/O4) Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data Function pointer to be registered UART0 RAPI_COM2 UART2 RAPI_COM4...
  • Page 41 The specifiable serial ports differ with each CPU used. Remark • If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Rev.1.01 2007.02.16 RJJ10J1643-0101 Transmission completed Reception completed Overrun error Framing error Parity error Transmission completed...
  • Page 42 ((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 RJJ10J1643-0101...
  • Page 43: Setserialformat

    #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 | ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 Setup data 2 RAPI_BCSS_F1 | RAPI_DPOL_NON | RAPI_LSB_SEL, 20);...
  • Page 44: Setserialinterrupt

    RAPI_INT_SIO_DIS RAPI_INT_SIO_LV_1 RAPI_INT_SIO_LV_2 RAPI_INT_SIO_LV_3 RAPI_INT_SIO_LV_4 RAPI_INT_SIO_LV_5 RAPI_INT_SIO_LV_6 RAPI_INT_SIO_LV_7 (R8C) Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 Transmit interrupt disabled Transmit interrupt priority level 1 Transmit interrupt priority level 2 Transmit interrupt priority level 3 Transmit interrupt priority level 4...
  • Page 45 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 RJJ10J1643-0101 UART0 RAPI_COM2 Transmit interrupt disabled Transmit interrupt priority level 1 Transmit interrupt priority level 2 Transmit interrupt priority level 3...
  • Page 46 Boolean func( void ) ……………… /* Set interrupt of RAPI_COM1 to serial driver */ return __SetSerialInterrupt( RAPI_INT_RX_LV_2 ); ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101 RAPI_COM1 RAPI_INT_TX_LV_1...
  • Page 47: Startserialreceiving

    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 RJJ10J1643-0101 Setup data Number of words received Pointer to the buffer in which received data is stored UART0 RAPI_COM2...
  • Page 48 ) ……………… /* Get 5 word data received in serial communication */ __StartSerialReceiving( RAPI_COM1, 5, buffer ); ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 49: Startserialsending

    • 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 RJJ10J1643-0101 Setup data Number of words transmitted Pointer to the transmit data UART0 RAPI_COM2 UART2 RAPI_COM4...
  • Page 50 ) ……………… /* Set 5 word data to transmit buffer of serial communication */ __StartSerialSending( RAPI_COM1, 5, buffer ); ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 51: Stopserialreceiving

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 UART0 RAPI_COM2 SCI3 channel 1 RAPI_COM2 SCI3 channel 3...
  • Page 52: Stopserialsending

    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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 UART0 RAPI_COM2 SCI3 channel 1 RAPI_COM2 SCI3 channel 3...
  • Page 53: Pollingserialreceiving

    /* Reception interrupt disable */ __SetSerialInterrupt( RAPI_COM1 | RAPI_INT_TX_DIS | RAPI_INT_RX_DIS ); /* Start reception */ __StartSerialReceiving( RAPI_COM1, 5, buffer ); count = __PollingSerialReceiving( RAPI_COM1 ); }while(count) ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2...
  • Page 54: Pollingserialsending

    The specifiable serial ports differ with each CPU used. Remark • 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 RJJ10J1643-0101 Setup data UART0 RAPI_COM2 UART2 RAPI_COM4 SI/O4 UART0 RAPI_COM2...
  • Page 55 ) ……………… /* Transmission interrupt disable */ __SetSerialInterrupt( RAPI_COM1 | RAPI_INT_TX_DIS | RAPI_INT_RX_DIS ); /* Start transmission */ __StartSerialSending( RAPI_COM1, 5, buffer ); count = __PollingSerialSending( RAPI_COM1 ); }while(count) ……………… Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 56: Timer

    • Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.)
  • Page 57 (Operating states set) • Specifiable definition values when timer Y is used (RAPI_TIMER_Y specified) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 58 RAPI_TA_F8192 RAPI_TB1_F4 RAPI_TB1_F16 RAPI_TB1_F64 Rev.1.01 2007.02.16 RJJ10J1643-0101 Specify one from { RAPI_F1, RAPI_F8, RAPI_FRING }. The default value is RAPI_F1. 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.
  • Page 59 • Specifiable definition values when timer V is used (RAPI_TIMER_V specified) (Clock) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 60 Program example #include "rapi_timer_r8c_13.h" void TimerIntFunc( void ){} Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 61 ) /* 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 RJJ10J1643-0101...
  • Page 62: Enabletimer

    Timer (timer mode) Functionality __CreateTimer, Reference Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) 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.
  • Page 63 If an undefined value is specified in the argument, operation of the API cannot be Remark 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 RJJ10J1643-0101...
  • Page 64: Destroytimer

    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 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2 Selects timer A channel 3.
  • Page 65 ) /* Destroy the setting of timer Z as timer mode */ __DestroyTimer( RAPI_TIMER_Z ); Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 66: Createeventcounter

    RAPI_FREE_RUN RAPI_UP_COUNT RAPI_DOWN_COUNT Rev.1.01 2007.02.16 RJJ10J1643-0101 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.)
  • Page 67 RAPI_TIMER_OFF RAPI_WRITE_ RELOAD_ ONLY Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects the UDF register for the cause of up/down switching. Selects the input signal at TA switching. Selects the rising edge of count source as active edge. Selects the falling edge of count source as active edge.
  • Page 68 RAPI_OVERFLOW RAPI_AUTO_RELOAD Rev.1.01 2007.02.16 RJJ10J1643-0101 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. Selects the rising edge of count source as active edge.
  • Page 69 B1 is used. If any timer other than B1 is used, specify 0. Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 70 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, Rev.1.01 2007.02.16 RJJ10J1643-0101 __GetEventCounter 0x80, 0x80, TimerIntFunc );...
  • Page 71: Enableeventcounter

    If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE Return value is returned. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2.
  • Page 72 If an undefined value is specified in the argument, operation of the API cannot be Remark 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 RJJ10J1643-0101 __GetEventCounter...
  • Page 73: Destroyeventcounter

    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 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2. Selects timer A channel 3.
  • Page 74 ) /* Destroy the setting of timer Y as event counter mode */ __DestroyEventCounter( RAPI_TIMER_Y ); Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 75: Geteventcounter

    • When using timer RA (RAPI_TIMER_RA specified) [0]: The value of timer RA prescaler register is stored. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the buffer in which counter value is stored Selects timer A channel 0.
  • Page 76 • 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 RJJ10J1643-0101 __DestroyEventCounter...
  • Page 77: Createpulsewidthmodulationmode

    RAPI_PULSE_OFF Selects that no pulses are output from TA RAPI_PWM_16 RAPI_PWM_8 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.)
  • Page 78 (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The (Output) • Specifiable definition values when timer Z is used (RAPI_TIMER_Z specified) Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects the rising edge of TA pin input signal as active edge. Selects the falling edge of TA pin input signal as active edge.
  • Page 79 RAPI_ TRGV_BOTH RAPI_TRGV_ PROHIBITED Rev.1.01 2007.02.16 RJJ10J1643-0101 Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_TIMER_Y_UNDERFLOW}. The default value is RAPI_F1. default value is RAPI_TIMER_OFF. Specify one from { RAPI_H_L_L, RAPI_L_H_H }. The default value is RAPI_H_L_L. Specify one from { RAPI_F1, RAPI_F2, RAPI_F8, RAPI_TIMER_RA_UNDERFLOW}.
  • Page 80 Timer (pulse width modulation mode (PWM mode)) Functionality Rev.1.01 2007.02.16 RJJ10J1643-0101 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.” If compare match A interrupt requests are enabled, specify RAPI_COMPARE_MATCH_A.
  • Page 81 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, Rev.1.01 2007.02.16 RJJ10J1643-0101 __DestroyPulseWidthModulationMode 5, p_tim, TimerIntFunc);...
  • Page 82: Enablepulsewidthmodulationmode

    Timer (pulse width modulation mode (PWM mode)) Functionality __CreatePulseWidthModulationMode, Reference Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2. Selects timer A channel 3.
  • Page 83 If an undefined value is specified in the argument, operation of the API cannot be Remark 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 RJJ10J1643-0101...
  • Page 84: Destroypulsewidthmodulationmode

    /* Destroy the setting of timer Z as pulse width modulation mode */ __DestroyPulseWidthModulationMode( RAPI_TIMER_Z ); Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2.
  • Page 85: Createpulseperiodmeasurementmode

    (R8C) RAPI_TIMER_X Rev.1.01 2007.02.16 RJJ10J1643-0101 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.)
  • Page 86 (H8/300H) RAPI_TIMER_W RAPI_TIMER_Z0 RAPI_TIMER_Z1 RAPI_TIMER_RC RAPI_TIMER_RD0 RAPI_TIMER_RD1 RAPI_TIMER_RD2 Rev.1.01 2007.02.16 RJJ10J1643-0101 Uses timer RA. Selects f for the count source. Selects f for the count source. Selects f for the count source. Selects f for the count source. Selects f for the count source.
  • Page 87 RAPI_TRD_FILTER_F RAPI_TRD_FILTER_F RAPI_TRD_FILTER_F RAPI_FTIOA Rev.1.01 2007.02.16 RJJ10J1643-0101 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 φ.
  • Page 88 (Operating set) (Measurement pulse) Rev.1.01 2007.02.16 RJJ10J1643-0101 Use FTIOB pin as input pin. 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.
  • Page 89 __CreatePulsePeriodMeasurementMode( RAPI_TIMER_X|RAPI_TIMER_ON|RAPI_FALLING_FALLING|RAPI_F8, 5, 0x80, 0x80, TimerIntFunc); Rev.1.01 2007.02.16 RJJ10J1643-0101 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. digital Specify one from { RAPI_TRC_FILTER_F1, RAPI_TRC_FILTER_F8, RAPI_TRC_FILTER_F32, RAPI_TRC_FILTER_F }.
  • Page 90: Enablepulseperiodmeasurementmode

    RAPI_TIMER_RD RAPI_TIMER_RD RAPI_TIMER_ON Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) 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.
  • Page 91 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 RJJ10J1643-0101 Sets the timer that is set to pulse period measurement mode to stop operating.
  • Page 92: Destroypulseperiodmeasurementmode

    Remark guaranteed. • The specifiable timers differ with each CPU used. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer B channel 0. Selects timer B channel 1. Selects timer B channel 2. Selects timer X. Selects timer RA.
  • Page 93 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 RJJ10J1643-0101...
  • Page 94: Getpulseperiodmeasurementmode

    [1]: The value of timer X register is stored. • When using timer RA (RAPI_TIMER_RA specified) Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the buffer in which counter value is stored Selects timer B channel 0.
  • Page 95 • 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 RJJ10J1643-0101...
  • Page 96: Createpulsewidthmeasurementmode

    RAPI_F8 RAPI_F32 RAPI_FC32 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.)
  • Page 97 RAPI_TW_F2 RAPI_TW_F4 Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects fOCO 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.
  • Page 98 RAPI_FTIOB • Specifiable definition values when timer W is used (RAPI_TIMER_W specified) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 99 [data2] (M16C) (R8C) Rev.1.01 2007.02.16 RJJ10J1643-0101 RAPI_TW_F8 }. The default value is RAPI_TW_F1. 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.
  • Page 100 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 RJJ10J1643-0101...
  • Page 101: Enablepulsewidthmeasurementmode

    RAPI_TIMER_RD RAPI_TIMER_ON RAPI_TIMER_OFF Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) 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.
  • Page 102 If an undefined value is specified in the argument, operation of the API cannot be Remark 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 RJJ10J1643-0101...
  • Page 103: Rjj10J1643

    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 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer B channel 0. Selects timer B channel 1. Selects timer B channel 2.
  • Page 104 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 RJJ10J1643-0101...
  • Page 105: Getpulsewidthmeasurementmode

    [1]: The value of timer X register is stored. • When using timer RA (RAPI_TIMER_RA specified) Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the buffer in which counter value is stored Selects timer B channel 0.
  • Page 106 • 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 RJJ10J1643-0101...
  • Page 107: Createinputcapture

    RAPI_TIMER_ON RAPI_TIMER_OFF RAPI_RISING Rev.1.01 2007.02.16 RJJ10J1643-0101 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) Uses timer S.
  • Page 108 (Count source) Specify (Operating states set) Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects the falling edge of measurement pulse as active edge. Selects both rising and falling edges of measurement pulse as active edge. Uses the digital filter facility that has a sampling frequency f...
  • Page 109 RAPI_TRC_F8 RAPI_TRC_F32 RAPI_TRC_F40M RAPI_TRD_F1 RAPI_TRD_F2 Rev.1.01 2007.02.16 RJJ10J1643-0101 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 enabled, RAPI_INPUT_CAPURE_B, RAPI_INPUT_CAPURE_D, respectively. When not specifying interrupts, select “No interrupt requests.”...
  • Page 110 (Operating states set) (Interrupt) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 111 • Specifiable definition values when timer RD is used (RAPI_TIMER_RD specified) (Count source) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 112 [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 RJJ10J1643-0101 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...
  • Page 113 0. Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 114 If 0 is specified, the value 0 is set in the corresponding register. RAPI_CHANNEL0 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 115 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 RJJ10J1643-0101 Selects channel 1. Selects channel 2. Selects channel 3. Selects channel 4. Selects channel 5. Selects channel 6.
  • Page 116 ) /* 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 RJJ10J1643-0101...
  • Page 117: Enableinputcapture

    Remark guaranteed. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer S. 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.
  • Page 118 • 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 RJJ10J1643-0101...
  • Page 119: Destroyinputcapture

    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 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer S. Selects timer C. Selects timer RD0 channe 0. Selects timer RD0 channe 1.
  • Page 120 ) /* Destroy the setting of timer C as input capture mode */ __DestroyInputCapture( RAPI_TIMER_C ); Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 121: Getinputcapture

    [0]: Stores the value of timer C counter. [1]: Stores the value of capture & compare 0 register. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Setup data 2 (content differs with MCU type) Selects timer S.
  • Page 122 • 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 RJJ10J1643-0101 __DestroyInputCapture...
  • Page 123: Createoutputcompare

    RAPI_TRD_F2 RAPI_TRD_F4 RAPI_TRD_F8 Rev.1.01 2007.02.16 RJJ10J1643-0101 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) Uses timer S.
  • Page 124 RAPI_OUTPUT_ REVERSE_0 RAPI_OUTPUT_ REVERSE_1 RAPI_RELOAD Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects f for the timer RD count source. Selects fOCO40M for the timer RD count source. Selects f for the timer RE count source. Selects f for the timer RE count source.
  • Page 125 (CMP1 output inversion) Rev.1.01 2007.02.16 RJJ10J1643-0101 Leaves CMP0 output unchanged even when matched in compare 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.
  • Page 126 (Output function) (Counter) (H8/300H) Rev.1.01 2007.02.16 RJJ10J1643-0101 To reload TC register, specify RAPID_RELOAD. If RAPID_RELOAD is not specified, “No reload” is set. 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 }.
  • Page 127 RAPI_COMPARE_ MATCH_D RAPI_COUNT_CLEAR_A RAPI_COUNT_CLEAR_B RAPI_COUNT_CLEAR_C RAPI_COUNT_CLEAR_D Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 128 (Count source) (Operating states set) Rev.1.01 2007.02.16 RJJ10J1643-0101 Clear counter in sync with the synchronized other timer counter Synchronizes timer on channels 0 and 1. RAPI_TW_F8 }. The default value is RAPI_TW_F1. Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default value is RAPI_TIMER_OFF.
  • Page 129 [2]: Specify the compare match 1 interrupt priority level (0–7). (H8/300H) Specify 0. [data3] Rev.1.01 2007.02.16 RJJ10J1643-0101 If overflow interrupt requests are enabled, specify RAPI_OVERFLOW. If compare match A, compare match B, compare match C, or compare match interrupt requests...
  • Page 130 RAPI_RELOAD_WITH_ WRITE • Specifiable definition values for waveform generation control registers 0–7 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 131 [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 RJJ10J1643-0101 Specify one from { RAPI_SINGLE, RAPI_SR, RAPI_PHASE_DELAYED }. The default value is RAPI_SINGLE. Specify one from { RAPI_OUT_INIT_0, RAPI_OUT_INIT_1 }. The default value is RAPI_OUT_INIT_0.
  • Page 132 [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 RJJ10J1643-0101 Selects 0 output for the output waveform. Selects 1 output for the output waveform. Selects toggle output for the output waveform.
  • Page 133 • 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 RJJ10J1643-0101 __DestroyOutputCompare...
  • Page 134 *p_func[] = {(void*) TimerIntFunc0,(void*) TimerIntFunc1, 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 RJJ10J1643-0101 (void*) TimerIntFunc2};...
  • Page 135: Enableoutputcompare

    If an undefined value is specified in the argument, operation of the API cannot be Remark Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer S. Sets the timer that is set to output compare mode to start operating.
  • Page 136 • 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 RJJ10J1643-0101...
  • Page 137: Destroyoutputcompare

    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 RJJ10J1643-0101 Setup data (content differs with MCU type) Selects timer S. Selects timer C. Selects timer RD channel 0. Selects timer RD channel 1.
  • Page 138 ) /* Destroy the setting of timer C as output compare mode */ __DestroyOutputCompare( RAPI_TIMER_C ); Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 139: Settimerregister

    RAPI_TIMER_RD0 RAPI_TIMER_RD1 RAPI_TIMER_RD2 RAPI_TIMER_RD3 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the buffer in which register value is stored Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2.
  • Page 140 [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 RJJ10J1643-0101...
  • Page 141 [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 RJJ10J1643-0101...
  • Page 142 [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 RJJ10J1643-0101...
  • Page 143 [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 RJJ10J1643-0101...
  • Page 144 • 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 RJJ10J1643-0101 __GetTimerRegister...
  • Page 145: Enabletimerregister

    RAPI_TIMER_Z0 RAPI_TIMER_Z1 RAPI_TIMER_RC RAPI_TIMER_RD0 RAPI_TIMER_RD1 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) 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.
  • Page 146 ) /* Activate timer C */ __EnableTimerRegister( RAPI_TIMER_C|RAPI_TIMER_ON ); Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects timer RD channel 2. Selects timer RD channel 3. Sets the selected timer to start operating. Sets the selected timer to stop operating. __GetTimerRegister...
  • Page 147: Cleartimerregister

    RAPI_TIMER_RC RAPI_TIMER_RD0 RAPI_TIMER_RD1 RAPI_TIMER_RD2 RAPI_TIMER_RD3 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) 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.
  • Page 148 If an undefined value is specified in the argument, operation of the API cannot be Remark 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 RJJ10J1643-0101 __GetTimerRegister...
  • Page 149: Gettimerregister

    RAPI_TIMER_RD0 RAPI_TIMER_RD1 RAPI_TIMER_RD2 RAPI_TIMER_RD3 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Pointer to the buffer in which register value is stored Selects timer A channel 0. Selects timer A channel 1. Selects timer A channel 2. Selects timer A channel 3.
  • Page 150 [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 RJJ10J1643-0101...
  • Page 151 [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 RJJ10J1643-0101...
  • Page 152 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 RJJ10J1643-0101...
  • Page 153 [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 RJJ10J1643-0101...
  • Page 154 • 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 RJJ10J1643-0101 __ClearTimerRegister...
  • Page 155: Setioport

    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 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Setup data 2 (content differs with MCU type) Port P0 RAPI_PORT_0_1 Port P0 RAPI_PORT_0_3 Port P0 RAPI_PORT_0_5 Port P0 RAPI_PORT_0_7...
  • Page 156 RAPI_PORT_3_7 RAPI_PORT_4_4 RAPI_PORT_6_0 RAPI_PORT_6_2 RAPI_PORT_6_4 RAPI_PORT_6_6 The definition values corresponding to each I/O port are listed below. RAPI_PORT_INPUT RAPI_PORT_OUTPUT RAPI_PULLED_HIGH Rev.1.01 2007.02.16 RJJ10J1643-0101 Port P9 RAPI_PORT_9_1 Port P9 RAPI_PORT_9_3 Port P9 RAPI_PORT_9_6 Port P9 RAPI_PORT_10_0 Port P10 RAPI_PORT_10_2 Port P10...
  • Page 157 RAPI_PORT_D_2 RAPI_PORT_D_4 Rev.1.01 2007.02.16 RJJ10J1643-0101 Sets a selected port not to be pulled high. Sets the N-channel output transistor drive capacity of a selected port to High. Specifiable only when port P1 is used. Sets the N-channel output transistor drive capacity of a selected port to Low.
  • Page 158 If an undefined value is specified in the first argument, operation of the API cannot Remark 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 RJJ10J1643-0101 PortPD6 RAPI_PORT_D_7 PortPE0 RAPI_PORT_E_1 PortPE2 RAPI_PORT_E_3 PortPE4 RAPI_PORT_E_5...
  • Page 159 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 RJJ10J1643-0101...
  • Page 160: Readioport

    RAPI_PORT_8_0 RAPI_PORT_8_2 RAPI_PORT_8_4 RAPI_PORT_8_6 RAPI_PORT_9_0 RAPI_PORT_9_2 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the variable in which the value read from I/O port is stored. Port P0 RAPI_PORT_0_1 Port P0 RAPI_PORT_0_3 Port P0 RAPI_PORT_0_5...
  • Page 161 RAPI_PORT_6_7 (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 Rev.1.01 2007.02.16 RJJ10J1643-0101 Port P9 RAPI_PORT_9_6 Port P9 RAPI_PORT_10_0 Port P10 RAPI_PORT_10_2 Port P10 RAPI_PORT_10_4 Port P10 RAPI_PORT_10_6 Port P10 Port P0 RAPI_PORT_0_1 Port P0 RAPI_PORT_0_3...
  • Page 162 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 Rev.1.01 2007.02.16 RJJ10J1643-0101 PortP51 RAPI_PORT_5_2 PortP53 RAPI_PORT_5_4 PortP55 RAPI_PORT_5_6 PortP57 RAPI_PORT_6_0 PortP61 RAPI_PORT_6_2 PortP63 RAPI_PORT_6_4 PortP65 RAPI_PORT_6_6 PortP67 RAPI_PORT_7_0 PortP71 RAPI_PORT_7_2 PortP74...
  • Page 163 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 RJJ10J1643-0101 PortPH4 RAPI_PORT_H_5 PortPH6 RAPI_PORT_H_7 PortPJ0 RAPI_PORT_J_1 PortPH5 PortPH7...
  • Page 164: Writeioport

    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 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Data to be written to I/O port Port P0 RAPI_PORT_0_1 Port P0 RAPI_PORT_0_3 Port P0 RAPI_PORT_0_5 Port P0 RAPI_PORT_0_7 Port P1...
  • Page 165 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 Rev.1.01 2007.02.16 RJJ10J1643-0101 Port P9 RAPI_PORT_9_6 Port P9 RAPI_PORT_10_0 Port P10 RAPI_PORT_10_2 Port P10 RAPI_PORT_10_4 Port P10 RAPI_PORT_10_6 Port P10 Port P0 RAPI_PORT_0_1 Port P0 RAPI_PORT_0_3...
  • Page 166 RAPI_PORT_H_6 RAPI_PORT_J_0 If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned. I/O port Functionality __SetIOPort, __ReadIOPort, __SetIOPortRegister, __ReadIOPortRegister, Reference Rev.1.01 2007.02.16 RJJ10J1643-0101 PortP55 RAPI_PORT_5_6 PortP57 RAPI_PORT_6_0 PortP61 RAPI_PORT_6_2 PortP63 RAPI_PORT_6_4 PortP65 RAPI_PORT_6_6 PortP67...
  • Page 167 Remark be guaranteed. • 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 RJJ10J1643-0101...
  • Page 168: Setioportregister

    Specify the set value for the port direction register corresponding to a selected port. (H8/300H) Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Setup data 2 (content differs with MCU type) Setup data 3 (content differs with MCU type)
  • Page 169 If an undefined value is specified in the first argument, operation of the API cannot Remark 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 RJJ10J1643-0101...
  • Page 170: Readioportregister

    • The specifiable I/O port registers differ with each CPU used. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the variable in which the value read from I/O port register is stored. Port P0 register...
  • Page 171 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 RJJ10J1643-0101...
  • Page 172: Writeioportregister

    Remark be guaranteed. • The specifiable I/O port registers differ with each CPU used. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Data to be written to I/O port register Port P0 register RAPI_PORT_1 Port P2 register...
  • Page 173 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 RJJ10J1643-0101...
  • Page 174: Setinterrupt

    (Input pin) (R8C) RAPI_INT0 RAPI_INT1 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.) Uses _INT0 interrupt. Uses _INT1 interrupt.
  • Page 175 RAPI_WKP RAPI_NOT_INT_ REQUEST RAPI_INT_REQUEST Rev.1.01 2007.02.16 RJJ10J1643-0101 Uses _INT2 interrupt. Uses _INT3 interrupt. Uses key input interrupt. 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.
  • Page 176 If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, Return value Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 177 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 RJJ10J1643-0101 __ClearInterruptFlag...
  • Page 178: Enableinterrupt

    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 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Setup data 2 (content differs with MCU type) Uses _INT0 interrupt.
  • Page 179 Remark 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 RJJ10J1643-0101 __ClearInterruptFlag...
  • Page 180: Getinterruptflag

    If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned. Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the buffer in which the acquired flag data is stored Uses _INT0 interrupt. Uses _INT1 interrupt.
  • Page 181 Remark 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 RJJ10J1643-0101 __ClearInterruptFlag...
  • Page 182: Clearinterruptflag

    Reference • If an undefined value is specified in the first argument, operation of the API cannot Remark Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data (content differs with MCU type) Uses _INT0 interrupt. Uses _INT1 interrupt. Uses _INT2 interrupt. Uses _INT3 interrupt.
  • Page 183 • 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 RJJ10J1643-0101...
  • Page 184: Createadc

    RAPI_AN07 RAPI_AN20 RAPI_AN21 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.) Selects one-shot mode.
  • Page 185 (Input pin) (Operating frequency) (Resolution) (Operating states set) Rev.1.01 2007.02.16 RJJ10J1643-0101 Uses AN pin for the analog input pin. Uses AN pin for the analog input pin. Uses AN pin for the analog input pin. Uses AN pin for the analog input pin.
  • Page 186 • Specifiable definition values when repeat sweep mode 0 is used (RAPI_REPEAT_SWEEP0 specified) (Input pin) (Operating frequency) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 187 (RAPI_DELAYED_TRIGGER0 specified) (Input pin) (Operating frequency) Rev.1.01 2007.02.16 RJJ10J1643-0101 Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is RAPI_8BIT. 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.
  • Page 188 RAPI_AD_OFF RAPI_WITH_SAMPLE_ HOLD RAPI_WITHOUT_ SAMPLE_HOLD Rev.1.01 2007.02.16 RJJ10J1643-0101 Specify one from { RAPI_10BIT, RAPI_8BIT }. The default value is RAPI_8BIT. Specify RAPI_WITH_SAMPLE_HOLD. Specify one from { RAPI_P0_GROUP, RAPI_P10_GROUP, RAPI_P1P9_GROUP, RAPI_P9_GROUP }. The default value is RAPI_P10_GROUP. Specify one from { RAPI_FAD, RAPI_FAD2, RAPI_FAD3, RAPI_FAD4, RAPI_FAD6, RAPI_FAD12 }.
  • Page 189 RAPI_AN0 RAPI_AN1 RAPI_AN2 RAPI_AN3 Rev.1.01 2007.02.16 RJJ10J1643-0101 Selects software trigger. Selects timer RD as trigger. 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.
  • Page 190 • Specifiable definition values when repeat mode is used (RAPI_REPEAT specified) Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 191 Repeat sweep mode 0 Simultaneous sampling mode Delayed trigger mode 0 Rev.1.01 2007.02.16 RJJ10J1643-0101 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.
  • Page 192 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 AdIntFunc ); Rev.1.01 2007.02.16 RJJ10J1643-0101 Specify 1, 2, 3, or 4. Specify 1. Specify 1, 2, 3, or 4. __GetADCAll RAPI_EXTERNAL_TRIGGER |RAPI_AD_ON|RAPI_10BIT,...
  • Page 193: Enableadc

    RAPI_AN06 RAPI_AN07 RAPI_AN20 Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Number of analog input pins used by A/D converter (differs with MCU type) Uses AN pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used.
  • Page 194 RAPI_AN0 RAPI_AN1 RAPI_AN2 RAPI_AN3 Rev.1.01 2007.02.16 RJJ10J1643-0101 Selectable only when one-shot mode or repeat mode is used. Uses AN pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. Uses AN pin for the analog input pin.
  • Page 195 RAPI_AN11 RAPI_AN12 RAPI_AN13 RAPI_AN14 RAPI_AN15 RAPI_AN0_GROUP Rev.1.01 2007.02.16 RJJ10J1643-0101 Uses AN pin for the analog input pin. Uses AN pin for the analog input pin. Uses AN pin for the analog input pin. Uses AN pin for the analog input pin.
  • Page 196 Program example #include "rapi_ad_r8c_13.h" Rev.1.01 2007.02.16 RJJ10J1643-0101 Selectable only when sweep mode or repeat sweep mode 0 is used. Uses AN4-AN7 pins group for the analog input pin. Selectable only when sweep mode or repeat sweep mode 0 is used.
  • Page 197 ) /* Disable A/D converter */ __EnableADC( RAPI_AN0|RAPI_AD_OFF, 1 ); Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 198: Destroyadc

    __CreateADC, __EnableADC, __GetADC, Reference • When used for the H8/300H, this API places a specified timer into module stanby Remark 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 RJJ10J1643-0101 __GetADCAll...
  • Page 199: Getadc

    /* Get an A/D convertered data of A/D register 0 */ __GetADC( RAPI_AD0, &data ); Rev.1.01 2007.02.16 RJJ10J1643-0101 Setup data 1 (content differs with MCU type) Pointer to the buffer in which A/D converted value is stored. Selects A/D register 0.
  • Page 200: Getadcall

    /* Get A/D convertered datas of A/D register */ __GetADCAll( data ); Rev.1.01 2007.02.16 RJJ10J1643-0101 Pointer to the buffer in which A/D converted value is stored. [0] A/D register 0 [1] A/D register 1 [2] A/D register 2...
  • Page 201: Getadcstatus

    /* Get status of A/D convertered */ __GetADCStatus( &status ); Rev.1.01 2007.02.16 RJJ10J1643-0101 Pointer to the buffer in which the register content indicating A/D converter status is stored. Value of A/D conversion start flag (for only the R8C; 0 for the M16C and H8/300H)
  • Page 202: Clearadcstatus

    RAPI_FALSE is returned. A/D converter Functionality __GetADCStatus Reference 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 RJJ10J1643-0101 Status of A/D converter Value of interrupt bit or A/D end flag...
  • Page 203 Renesas Embedded Application Programming Interface Reference Manual Rev. 1.01 Issued: April 2007 Rev.1.01 2007.02.16 RJJ10J1643-0101...
  • Page 204: Reference Manual

    Renesas Embedded Application Programming Interface Reference manual 1753, Shimonumabe, Nakahara-ku, Kawasaki-shi, Kanagawa 211-8668 Japan REJ10J1502-0101...

This manual is also suitable for:

Embedded application programming interface

Table of Contents