Renesas M16C/62P Group Reference Manual
Renesas M16C/62P Group Reference Manual

Renesas M16C/62P Group Reference Manual

Group renesas embedded application programming interface
Hide thumbs Also See for M16C/62P Group:
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 M16C/62P Group

  • 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: Application Programming Interface

    M16C/62P Group Renesas Embedded Application Programming Interface Reference Manual Rev.1.00 2007.11...
  • Page 4 Renesas Embedded Application Programming Interface <M16C/62P Group> Rev.1.00 2007.11.1 REC10B0002-0100 Reference Manual...
  • Page 5: Table Of Contents

    Table of Contents ... 3 1. Introduction... 5 2. Driver ... 6 2.1 Overview... 6 2.2 Driver Features ... 6 2.3 Serial Interface Driver... 7 2.4 Timer Driver ... 8 2.4.1 Timer Mode ... 8 2.4.2 Event Counter Mode ... 8 2.4.3 Pulse Width Modulation Mode (PWM Mode)...
  • Page 6 __DestroyTimer ... 43 __CreateEventCounter ... 44 __EnableEventCounter ... 47 __DestroyEventCounter ... 48 __GetEventCounter... 49 __CreatePulseWidthModulationMode ... 50 __EnablePulseWidthModulationMode ... 53 __DestroyPulseWidthModulationMode ... 54 __CreatePulsePeriodMeasurementMode ... 55 __EnablePulsePeriodMeasurementMode ... 57 __DestroyPulsePeriodMeasurementMode ... 58 __GetPulsePeriodMeasurementMode... 59 __CreatePulseWidthMeasurementMode... 60 __EnablePulseWidthMeasurementMode ... 62 __DestroyPulseWidthMeasurementMode ... 63 __GetPulseWidthMeasurementMode ...
  • Page 7: Introduction

    1. Introduction The Renesas Embedded Application Programming Interface (API) is a unified API for the microcomputers made by Renesas Technology Corporation. Rev.1.00 2007.11.1 REC10B0002-0100...
  • Page 8: 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. 2.2 Driver Features The library described herein has the following features available as a peripheral driver.
  • Page 9: 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.00 2007.11.1 REC10B0002-0100...
  • Page 10: Timer Driver

    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) •...
  • Page 11: 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.00 2007.11.1 REC10B0002-0100...
  • Page 12: 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.00 2007.11.1 REC10B0002-0100...
  • Page 13: A/D Converter Driver

    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. Rev.1.00 2007.11.1 REC10B0002-0100...
  • Page 14: Standard Types

    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)).
  • Page 15: 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 16 __CreatePulseWidthMeasurementMode __EnablePulseWidthMeasurementMode Timer __DestroyPulseWidthMeasurementMode __GetPulseWidthMeasurementMode __SetTimerRegister __EnableTimerRegister __ClearTimerRegister __GetTimerRegister I/O port __SetIOPort __ReadIOPort __WriteIOPort __SetIOPortRegister __ReadIOPortRegister __WriteIOPortRegister External __SetInterrupt interrupt __EnableInterrupt __GetInterruptFlag __ClearInterruptFlag A/D converter __CreateADC __EnableADC __DestroyADC __GetADC __GetADCAll Rev.1.00 2007.11.1 REC10B0002-0100 Sets pulse width measurement mode Controls operation of pulse width measurement mode Clears setting of pulse width measurement mode...
  • Page 17: Description Of Each Api

    4.2 Description of Each API This section describes each API and explains how to use them, showing a program example for each. The description of each API is divided into the following items. Outlines the content of processing performed by the function. It •...
  • Page 18: Serial I/O

    4.2.1 Serial I/O __BasicOpenSerialDriver Synopsis <Open a serial port> Boolean __BasicOpenSerialDriver(unsigned long data) data Description Opens and initializes a specified serial port. For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
  • Page 19: Basiccloseserialdriver

    __BasicCloseSerialDriver Synopsis <Close a serial port> Boolean __BasicCloseSerialDriver(unsigned long data) data Description Closes a specified serial port. For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
  • Page 20: Basicsetserialformat

    __BasicSetSerialFormat Synopsis <Set serial communication> Boolean __BasicSetSerialFormat(unsigned long data1, unsigned char data2) data1 data2 Sets serial communication according to specified parameters. Description [data1] For data1, the following values can be set. To set multiple definition values at the same time, use the symbol “|” to separate each specified value. RAPI_COM1 RAPI_COM3 RAPI_COM5...
  • Page 21 If the API is used in clock synchronous serial communication mode, do not set these values. (UART0, UART1, UART2) RAPI_PARITY_NON RAPI_PARITY_ODD For the clock polarity of serial communication, the following values can be set. If the API is used in clock asynchronous serial communication mode, do not set these values.
  • Page 22 If serial communication was successfully set, RAPI_TRUE is returned; if settings failed, RAPI_FALSE is returned. Functionality Serial I/O Reference • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include ”rapi_sif_m16c_62p”...
  • Page 23: Basicstartserialreceiving

    __BasicStartSerialReceiving Synopsis <Receive 1 data> Boolean __BasicStartSerialReceiving(unsigned long data) data Description Starts receiving 1 data of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If data reception in serial communication was successfully started, RAPI_TRUE is Return value returned;...
  • Page 24: Basicstartserialsending

    __BasicStartSerialSending Synopsis <Transmit 1 data> Boolean _BasicStartSerialSending(unsigned long data1, unsigned int data2) data data Starts sending 1 data of serial communication. Description For data1, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If data transmission in serial communication was successfully started, RAPI_TRUE is Return value returned;...
  • Page 25: Basicreceivingstatusread

    __BasicReceivingStatusRead Synopsis <Read receive status> unsigned int __BasicReceivingStatusRead(unsigned long data) data Description Returns the receive status of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 The receive status of serial communication is returned. The returned value is one of Return value the following.
  • Page 26: Basicsendingstatusread

    __BasicSendingStatusRead Synopsis <Read transmit status> Boolean __BasicSendingStatusRead(unsigned long data) data Description Returns the transmit status of serial communication. For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 Return value If no data exists in the transmit buffer, RAPI_TRUE is returned; if data exists, RAPI_FALSE is returned.
  • Page 27: Basicstopserialreceiving

    __BasicStopSerialReceiving Synopsis <Stop reception> Boolean Rapi_BasicStopSerialReceiving(unsigned long data) data Description Stops receiving data in serial communication [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If data reception in serial communication was successfully stopped, RAPI_TRUE is returned;...
  • Page 28: Basicstopserialsending

    __BasicStopSerialSending Synopsis <Stop transmission> Boolean __BasicStopSerialSending(unsigned long data) data Description Stops transmitting data in serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If data transmission in serial communication was successfully stopped, RAPI_TRUE is returned;...
  • Page 29: Openserialdriver

    __OpenSerialDriver Synopsis <Open a serial port> Boolean __OpenSerialDriver(unsigned long data) data Description Opens and initializes a specified serial port. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned.
  • Page 30: Closeserialdriver

    __CloseSerialDriver Synopsis <Close a serial port> Boolean __CloseSerialDriver(unsigned long data) data Description Closes a specified serial port. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned.
  • Page 31: Configserialdrivernotify

    __ConfigSerialDriverNotify Synopsis <Register a notification function> Boolean __ConfigSerialDriverNotify(unsigned long data, VoidFuncNotify *func) data func Registers the notification function necessary to get various transmit/receive information Description of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 [func] The function to be registered in func must be supplied to the serial I/O driver by the user.
  • Page 32 Return value If the serial port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Serial I/O Reference __StartSerialReceiving, • If an undefined value is specified in the first argument, operation of the API cannot Remark be guaranteed. Program example #include ”rapi_sif_m16c_62p”...
  • Page 33: Setserialformat

    __SetSerialFormat Synopsis <Set serial communication> Boolean __SetSerialFormat(unsigned long data1, unsigned char data2) data1 data2 Sets serial communication according to specified parameters. Description For details about parameters, refer to the description of __BasicSetSerialFormat. If serial communication was successfully set, RAPI_TRUE is returned; if settings failed, Return value RAPI_FALSE is returned.
  • Page 34: Setserialinterrupt

    __SetSerialInterrupt Synopsis <Set serial interrupts> Boolean __SetSerialInterrupt(unsigned long data) data Description Sets serial interrupts according to specified parameters. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 RAPI_COM5 For interrupt settings, the following values can set. (UART0, UART1, UART2) RAPI_INT_TX_DIS RAPI_INT_TX_LV_1 RAPI_INT_TX_LV_2...
  • Page 35 Serial I/O Functionality Reference • Remark If an undefined value is specified in the argument, operation of the API cannot be guaranteed. Program example #include ”rapi_sif_m16c_62p” Boolean func( void ) /* Set interrupt of RAPI_COM1 to serial driver */ return __SetSerialInterrupt( Rev.1.00 2007.11.1...
  • Page 36: Startserialreceiving

    __StartSerialReceiving Synopsis <Start reception> Boolean __StartSerialReceiving(unsigned long data, unsigned char wordNum, unsigned int *RcvDtBuf) data wordNum RcvDtBuf Description Starts reception of serial communication and gets received data by a specified number of words. When acquisition of received data is complete, this API calls a notification function (if a notification function is registered).
  • Page 37: Startserialsending

    __StartSerialSending Synopsis <Start transmission> Boolean __StartSerialSending(unsigned long data, unsigned char wordNum, unsigned int *SndDtBuf) data wordNum SndDtBuf Description Starts transmission of serial communication and writes transmit data to the transmit buffer by a specified number of words. When transmission of all transmit data is complete, this API calls a notification function (if a notification function is registered).
  • Page 38: Stopserialreceiving

    __StopSerialReceiving Synopsis <Stop reception> Boolean __StopSerialReceiving(unsigned long data) data Description Stops reception of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If reception of serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned. Functionality Serial I/O __StartSerialReceiving...
  • Page 39: Stopserialsending

    __StopSerialSending Synopsis <Stop transmission> Boolean __StopSerialSending(unsigned long data) data Description Stops transmission of serial communication. [data] For data, the following values can be set. RAPI_COM1 RAPI_COM3 Return value If transmission of serial communication was successfully stopped, RAPI_TRUE is returned; if failed, RAPI_FALSE is returned. Functionality Serial I/O __StartSerialReceiving...
  • Page 40: Pollingserialreceiving

    __PollingSerialReceiving Synopsis <Polling reception> Boolean __PollingSerialReceiving(unsigned long data) data Description Performs reception of serial communication by polling. This API gets received data by an amount specified by __StartSerialReceiving. When acquisition of received data is complete, it calls a notification function (if a notification function is registered). [data] For data, the following values can be set.
  • Page 41: Pollingserialsending

    __PollingSerialSending Synopsis <Polling transmission> Boolean __PollingSerialSending(unsigned long data) data Description Performs transmission of serial communication by polling. This API sends transmit data by an amount specified by __StartSerialSending from the transmit data buffer specified by __StartSerialSending. When transmission of all transmit data is complete, it calls a notification function (if a notification function is registered).
  • Page 42: Timer

    4.2.2 Timer __CreateTimer Synopsis <Set timer mode> Boolean __CreateTimer(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to timer mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 43 (Count source) (Operating states set) (Pulse output state) (Gate facility) • Specifiable definition values when timer B is used (RAPI_TIMER_B0 to RAPI_TIMER_B5 specified) (Count source) (Operating states set) [data2] Specify the interrupt priority level (0–7) to be set in the interrupt control register. [data3] Specify the value to be set in the timer register in 16 bits.
  • Page 44: Enabletimer

    __EnableTimer Synopsis <Control operation of timer mode> Boolean __EnableTimer(unsigned long data) data Description Controls operation of the timer that is set to specified timer mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 45: Destroytimer

    __DestroyTimer Synopsis <Discard settings of timer mode> Boolean __DestroyTimer(unsigned long data) data Description Discards settings of the timer that is set to specified timer mode. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
  • Page 46: Createeventcounter

    __CreateEventCounter Synopsis <Set event counter mode> Boolean __CreateEventCounter(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to event counter mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 47 RAPI_UP_COUNT RAPI_DOWN_COUNT RAPI_UDF_REGISTER RAPI_TAIOUT RAPI_RISING RAPI_FALLING RAPI_BOTH • Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) (Operating states set) (Pulse output facility) (Gate facility) (Count type) (Count direction) (Count direction switching) (Count edge) • Specifiable definition values when timer B is used (RAPI_TIMER_B0 to RAPI_TIMER_B4 specified) (Count source) (Operating...
  • Page 48 [data4] Specify 0. Return value If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Timer (event counter mode) __EnableEventCounter, __DestroyEventCounter, Reference • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
  • Page 49: Enableeventcounter

    __EnableEventCounter Synopsis <Control operation of event counter mode> Boolean __EnableEventCounter(unsigned long data) data Description Controls operation of the timer that is set to specified timer mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 50: Destroyeventcounter

    __DestroyEventCounter Synopsis <Discard settings of event counter mode> Boolean __DestroyEventCounter(unsigned long data) data Description Discards settings of the timer that is set to specified timer mode. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1...
  • Page 51: Geteventcounter

    __GetEventCounter Synopsis <Get event counter mode counter value> Boolean __GetEventCounter(unsigned long data1, unsigned int *data2) data1 data2 Gets the counter value of the timer that is set to specified event counter mode. Description [data1] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2...
  • Page 52: Createpulsewidthmodulationmode

    __CreatePulseWidthModulationMode Synopsis <Set pulse width modulation mode> Boolean __CreatePulseWidthModulationMode(unsigned long data1, unsigned int data2, unsigned int* data3, void* data4) data1 data2 data3 func Description Sets a specified timer to pulse width modulation mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 53 RAPI_FALLING • Specifiable definition values when timer A is used (RAPI_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The (Count start condition) Specify one from { RAPI_TG_TAIS, RAPI_TG_TAIIN, (Pulse output facility) (Modulator) pin input) [data2] Specify the interrupt priority level (0–7) to be set in the interrupt control register.
  • Page 54 void func( void ) unsigned int p_tim[] = {0xAA, 0xBB, 0xCC}; /* Set up timer A3 as pulse width modulation mode */ __CreatePulseWidthModulationMode( RAPI_TIMER_A3|RAPI_TIMER_ON|RAPI_F8, Rev.1.00 2007.11.1 REC10B0002-0100 5, p_tim, TimerIntFunc);...
  • Page 55: Enablepulsewidthmodulationmode

    __EnablePulseWidthModulationMode Synopsis <Control operation of pulse width modulation mode> Boolean __EnablePulseWidthModulationMode(unsigned long data) data Description Controls operation of the timer that is set to specified pulse width modulation mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 56: Destroypulsewidthmodulationmode

    __DestroyPulseWidthModulationMode Synopsis <Discard settings of pulse width modulation mode> Boolean __DestroyPulseWidthModulationMode(unsigned long data) data Description Discards settings of the timer that is set to specified pulse width modulation mode. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3...
  • Page 57: Createpulseperiodmeasurementmode

    __CreatePulsePeriodMeasurementMode Synopsis <Set pulse period measurement mode> Boolean __CreatePulsePeriodMeasurementMode(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to pulse period measurement mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 58 [data3] Specify 0. [data4] Specify 0. If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, Return value RAPI_TRUE is returned. Functionality Timer (pulse period measurement mode) Reference __EnablePulsePeriodMeasurementMode, __DestroyPulsePeriodMeasurementMode, __GetPulsePeriodMeasurementMode • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
  • Page 59: Enablepulseperiodmeasurementmode

    __EnablePulsePeriodMeasurementMode Synopsis <Control operation of pulse period measurement mode> Boolean __EnablePulsePeriodMeasurementMode(unsigned long data) data Description Controls operation of the timer that is set to specified pulse period measurement mode by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 60: Destroypulseperiodmeasurementmode

    __DestroyPulsePeriodMeasurementMode Synopsis <Discard settings of pulse period measurement mode> Boolean __DestroyPulsePeriodMeasurementMode(unsigned long data) data Description Discards settings of the timer that is set to specified pulse period measurement mode. [data] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 RAPI_TIMER_B3...
  • Page 61: Getpulseperiodmeasurementmode

    __GetPulsePeriodMeasurementMode Synopsis <Get measured value in pulse period measurement mode> Boolean __GetPulsePeriodMeasurementMode(unsigned long data1, unsigned int *data2) data1 data2 Description Gets the counter value of the timer that is set to specified pulse period measurement mode. [data1] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
  • Page 62: Createpulsewidthmeasurementmode

    __CreatePulseWidthMeasurementMode Synopsis <Set pulse width measurement mode> Boolean __CreatePulseWidthMeasurementMode(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4, void* func) data1 data2 data3 data4 func Description Sets a specified timer to pulse with measurement mode. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 63 [data4] Specify 0. Return value If the timer specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Timer (pulse width measurement mode) Reference __EnablePulseWidthMeasurementMode, __DestroyPulseWidthMeasurementMode, __GetPulseWidthMeasurementMode • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed.
  • Page 64: Enablepulsewidthmeasurementmode

    __EnablePulseWidthMeasurementMode Synopsis <Control operation of pulse width measurement mode> Boolean __EnablePulseWidthMeasurementMode(unsigned long data) data Description Controls operation of the timer that is set to specified pulse width measurement mode. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 65: Destroypulsewidthmeasurementmode

    __DestroyPulseWidthMeasurementMode Synopsis <Discard settings of pulse width measurement mode> Boolean __DestroyPulseWidthMeasurementMode(unsigned long data) data Description Discards settings of the timer that is set to specified pulse width measurement mode. [data] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 RAPI_TIMER_B3...
  • Page 66: Getpulsewidthmeasurementmode

    __GetPulseWidthMeasurementMode Synopsis <Get measured value in pulse width measurement mode> Boolean __GetPulseWidthMeasurementMode(unsigned long data1, unsigned int *data2) data1 data2 Description Gets the counter value of the timer that is set to specified pulse width measurement mode. [data1] For data, the following definition values can be set. RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
  • Page 67: Settimerregister

    __SetTimerRegister Synopsis <Set timer register> Boolean __SetTimerRegister(unsigned long data1, unsigned int *data2) data1 data2 Description Sets the registers of a specified timer. [data1] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 [data2] The content of a pointer to the buffer in which the register value is stored must be specified as described below.
  • Page 68 If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. • The specifiable timers differ with each CPU used. Program example #include " rapi_timer_m16c_62p.h" void func( void ) unsigned char data[] = {0,0,0,0,0,0,0}; /* Set up timer A0 register */ __SetTimerRegister( RAPI_TIMER_A0, data );...
  • Page 69: Enabletimerregister

    __EnableTimerRegister Synopsis <Control operation of timer register> Boolean __EnableTimerRegister(unsigned long data) data Description Controls operation of a specified timer by starting or stopping it. [data] For data, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 70: Cleartimerregister

    __ClearTimerRegister Synopsis <Clear timer register> Boolean __ClearTimerRegister(unsigned long data) data Description Sets the timer register of a specified timer to its initial value after reset. [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2...
  • Page 71: Gettimerregister

    __GetTimerRegister Synopsis <Get timer register value> Boolean __GetTimerRegister(unsigned long data1, unsigned int *data2) data1 data2 Gets the counter value of a specified timer. Description [data] For data, the following definition values can be set. RAPI_TIMER_A0 RAPI_TIMER_A1 RAPI_TIMER_A2 RAPI_TIMER_A3 RAPI_TIMER_A4 RAPI_TIMER_B0 RAPI_TIMER_B1 RAPI_TIMER_B2 RAPI_TIMER_B3...
  • Page 72 Reference __SetTimerRegister, __EnableTimerRegister, • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_timer_m16c_62p.h" void func( void ) unsigned int data[7]; /* Get the value of timer A3 registers */ __GetTimerRegister( RAPI_TIMER_A3, data );...
  • Page 73: I/O Port

    4.2.3 I/O Port __SetIOPort Synopsis <Set I/O port> Boolean __SetIOPort(unsigned long data1, unsigned int data2) data1 data2 Sets the operating conditions of a specified I/O port. Description [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 74 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 RAPI_PORT_9_4 RAPI_PORT_9_6 RAPI_PORT_10_0 RAPI_PORT_10_2 RAPI_PORT_10_4 RAPI_PORT_10_6 RAPI_PORT_11_0 RAPI_PORT_11_2 RAPI_PORT_11_4 RAPI_PORT_11_6 RAPI_PORT_12_0 RAPI_PORT_12_2 RAPI_PORT_12_4 RAPI_PORT_12_6 RAPI_PORT_13_0 RAPI_PORT_13_2 RAPI_PORT_13_4 RAPI_PORT_13_6 RAPI_PORT_14_0 The definition values related to port settings are described below. RAPI_PORT_INPUT RAPI_PORT_OUTPUT RAPI_PULLED_HIGH RAPI_NOT_PULLED _HIGH...
  • Page 75 Functionality I/O port Reference __ReadIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister, __WriteIOPortRegister • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_io_port_m16c_62p.h" void func( void ) /* Set up port P03 as input port */ __SetIOPort(RAPI_PORT_0_3| RAPI_PORT_INPUT| RAPI_PULLED_HIGH, 0 );...
  • Page 76: Readioport

    __ReadIOPort Synopsis <Read from I/O port> Boolean __ReadIOPort(unsigned long data1, unsigned int *data2) data1 data2 Gets the value of a specified I/O port. Description [data1] Specify an I/O port from which data is read. The definition values corresponding to each I/O port are listed below. RAPI_PORT_0_0 RAPI_PORT_0_2 RAPI_PORT_0_4...
  • Page 77 RAPI_PORT_9_6 RAPI_PORT_10_0 RAPI_PORT_10_2 RAPI_PORT_10_4 RAPI_PORT_10_6 RAPI_PORT_11_0 RAPI_PORT_11_2 RAPI_PORT_11_4 RAPI_PORT_11_6 RAPI_PORT_12_0 RAPI_PORT_12_2 RAPI_PORT_12_4 RAPI_PORT_12_6 RAPI_PORT_13_0 RAPI_PORT_13_2 RAPI_PORT_13_4 RAPI_PORT_13_6 RAPI_PORT_14_0 Return value If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality I/O port __SetIOPort, __WriteIOPort, __SetIOPortRegister, __ReadIOPortRegister, Reference __WriteIOPortRegister •...
  • Page 78: Writeioport

    __WriteIOPort Synopsis <Write to I/O port> Boolean __WriteIOPort(unsigned long data1, unsigned int data2) data1 data2 Writes data to a specified I/O port. Description [data1] Specify an I/O port to which data is written. The definition values corresponding to each I/O port are listed below. RAPI_PORT_0_0 RAPI_PORT_0_2 RAPI_PORT_0_4...
  • Page 79 RAPI_PORT_9_6 RAPI_PORT_10_0 RAPI_PORT_10_2 RAPI_PORT_10_4 RAPI_PORT_10_6 RAPI_PORT_11_0 RAPI_PORT_11_2 RAPI_PORT_11_4 RAPI_PORT_11_6 RAPI_PORT_12_0 RAPI_PORT_12_2 RAPI_PORT_12_4 RAPI_PORT_12_6 RAPI_PORT_13_0 RAPI_PORT_13_2 RAPI_PORT_13_4 RAPI_PORT_13_6 RAPI_PORT_14_0 Return value If the I/O port specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality I/O port __SetIOPort, __ReadIOPort, __SetIOPortRegister, __ReadIOPortRegister, Reference __WriteIOPortRegister •...
  • Page 80: Setioportregister

    __SetIOPortRegister Synopsis <Set I/O port register> Boolean __SetIOPortRegister(unsigned long data1, unsigned int data2, unsigned int data3, unsigned int data4) data1 data2 data3 data4 Description [data1] Set the operating condition of a specified I/O port in each relevant register. The definition values corresponding to each I/O port register are listed below. RAPI_PORT_0 RAPI_PORT_2 RAPI_PORT_4...
  • Page 81 If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_io_port_m16c_62p.h" void func( void ) /* Set inputs/outputs of port P1 register */ __SetIOPortRegister(RAPI_PORT_1, 0xAA, 0, 0 ); Rev.1.00 2007.11.1 REC10B0002-0100...
  • Page 82: Readioportregister

    __ReadIOPortRegister Synopsis <Read from I/O port register> Boolean __ReadIOPortRegister(unsigned long data1, unsigned int *data2) data1 data2 Gets the value of a specified I/O port from each relevant register. Description [data1] Specify an I/O port register from which data is read. The definition values corresponding to each I/O port register are listed below.
  • Page 83: Writeioportregister

    __WriteIOPortRegister Synopsis <Write to I/O port register> Boolean __WriteIOPortRegister(unsigned long data1, unsigned int data2) data1 data2 Writes the value for a specified I/O port to each relevant register. Description [data1] Specify an I/O port register to which data is written. The definition values corresponding to each I/O port register are listed below.
  • Page 84: External Interrupt

    4.2.4 External interrupt __SetInterrupt Synopsis <Set external interrupt> Boolean __SetInterrupt(unsigned long data1, unsigned int data2, void* func) data1 data2 func Description Sets a specified external interrupt. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 85 Return value If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned. Functionality External interrupt Reference __EnableInterrupt, __GetInterruptFlag, • If an undefined value is specified in the first argument, operation of the API cannot Remark be guaranteed. Program example #include "...
  • Page 86: Enableinterrupt

    __EnableInterrupt Synopsis <Control external interrupt> Boolean __EnableInterrupt(unsigned long data1, unsigned int data2) data1 data2 Changes the operating condition of a specified external interrupt. Description [data1] RAPI_INT0 RAPI_INT1 RAPI_INT2 RAPI_INT3 RAPI_INT4 RAPI_INT5 RAPI_KEY [data2] Specify the interrupt priority level (0–7) to be set in the interrupt control register. If the external interrupt specification is incorrect, RAPI_FALSE is returned;...
  • Page 87: Getinterruptflag

    __GetInterruptFlag Synopsis <Get the status of external interrupt flag> Boolean __GetInterruptFlag(unsigned long data1, unsigned int *data2)) data1 data2 Gets the value of interrupt request flag of a specified external interrupt. Description [data1] RAPI_INT0 RAPI_INT1 RAPI_INT2 RAPI_INT3 RAPI_INT4 RAPI_INT5 RAPI_KEY [data2] Value of interrupt request flag (0: Interrupt not requested;...
  • Page 88: Clearinterruptflag

    __ClearInterruptFlag Synopsis <Clear external interrupt flag> Boolean __ClearInterruptFlag(unsigned long data) data Description Clears the interrupt request flag of a specified external interrupt. [data] RAPI_INT0 RAPI_INT1 RAPI_INT2 RAPI_INT3 RAPI_INT4 RAPI_INT5 RAPI_KEY Return value If the external interrupt specification is incorrect, RAPI_FALSE is returned; otherwise, RAPI_TRUE is returned.
  • Page 89: A/D Converter

    4.2.5 A/D converter __CreateADC Synopsis <Set A/D converter> Boolean __CreateADC(unsigned long data1, unsigned int data2, unsigned int data3, void* func) data1 data2 data3 func Description Sets the A/D converter to specified mode and operating condition. [data1] For data1, the following definition values can be set. To set multiple definition values at the same time, use the symbol “|”...
  • Page 90 RAPI_AN27 RAPI_P0_GROUP RAPI_P10_GROUP RAPI_P2_GROUP RAPI_FAD RAPI_FAD2 RAPI_FAD3 RAPI_FAD4 RAPI_FAD6 RAPI_FAD12 RAPI_10BIT RAPI_8BIT RAPI_AD_ON RAPI_AD_OFF RAPI_WITH_SAMPLE_HOLD RAPI_WITHOUT_SAMPLE_ HOLD RAPI_SOFTWARE_TRIGGER RAPI_EXTERNAL_TRIGGER RAPI_ANEX_UNUSED RAPI_ANEX0 RAPI_ANEX1 RAPI_EXTERNAL_OP_AMP • Specifiable definition values when one-shot mode is used (RAPI_ONE_SHOT specified) (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method)
  • Page 91 (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) • Specifiable definition values when single sweep mode is used (RAPI_SINGLE_SWEEP specified) (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) •...
  • Page 92 (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) • Specifiable definition values when repeat sweep mode 1 is used (RAPI_REPEAT_SWEEP1 specified) (Input pin) (Operating frequency) (Resolution) (Operating states set) (Conversion method) (Trigger) (External Op-Amp Connection) [data2] The set value differs with the A/D conversion mode used. One-shot mode Repeat mode Single sweep mode...
  • Page 93 • Remark If an undefined value is specified in the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_ad_m16c_62p.h" void AdIntFunc( void ){} void func( void ) /* Set up A/D converter as one short mode */ __CreateADC( RAPI_ONE_SHOT|RAPI_AN2|RAPI_FAD2| RAPI_WITH_SAMPLE_HOLD | RAPI_EXTERNAL_TRIGGER |RAPI_AD_ON|RAPI_10BIT| RAPI_ANEX_UNUSED, 1, 5, AdIntFunc );...
  • Page 94: Enableadc

    __EnableADC Synopsis <Control operation of A/D converter> Boolean __EnableADC (unsigned long data1, unsigned int data2) data1 data2 Controls operation of the A/D converter by starting or stopping it. Description [data1] RAPI_AN0 RAPI_AN1 RAPI_AN2 RAPI_AN3 RAPI_AN4 RAPI_AN5 RAPI_AN6 RAPI_AN7 RAPI_AN00 RAPI_AN01 RAPI_AN02 RAPI_AN03 RAPI_AN04...
  • Page 95 RAPI_AN21 RAPI_AN22 RAPI_AN23 RAPI_AN24 RAPI_AN25 RAPI_AN26 RAPI_AN27 RAPI_ANEX0 RAPI_ANEX1 RAPI_P0_GROUP RAPI_P10_GROUP RAPI_P2_GROUP RAPI_AD_ON RAPI_AD_OFF [data2] The set value differs with the A/D conversion mode used. One-shot mode Repeat mode Single sweep mode Repeat sweep mode 0 Repeat sweep mode 1 Return value If A/D converter was successfully controlled, RAPI_TRUE is returned;...
  • Page 96 Program example #include "rapi_ad_m16c_62p.h" void func( void ) /* Disable A/D converter */ __EnableADC( RAPI_AN0|RAPI_AD_OFF, 1 ); Rev.1.00 2007.11.1 REC10B0002-0100...
  • Page 97: Destroyadc

    __DestroyADC Synopsis <Discard settings of A/D converter> Boolean __DestroyADC(void) Description Discards settings of a specified A/D converter. If converter setting was successfully discarded, RAPI_TRUE is returned; if failed, Return value RAPI_FALSE is returned. A/D converter Functionality Reference __CreateADC, __EnableADC, __GetADC, Program example #include "rapi_ad_m16c_62p.h"...
  • Page 98: Getadc

    __GetADC Synopsis <Get A/D converted value (register specified)> Boolean __GetADC(unsigned long data1, unsigned int *data2) data1 data2 Gets the A/D converted value from a specified A/D register. Description For data1, the following values can be set. RAPI_AD0 RAPI_AD1 RAPI_AD2 RAPI_AD3 RAPI_AD4 RAPI_AD5 RAPI_AD6...
  • Page 99: Getadcall

    __GetADCAll Synopsis <Get A/D converted value (all registers)> Boolean __GetADCAll(unsigned int *data) data Description Gets the A/D converted value from all A/D registers. The A/D registers from which A/D converted values are acquired are listed below. [M16C] (16 bytes) Return value If A/D converted values were successfully acquired, RAPI_TRUE is returned;...
  • Page 100 M16C/62P Group Renesas Embedded Application Programming Interface Reference Manual 1753, Shimonumabe, Nakahara-ku, Kawasaki-shi, Kanagawa 211-8668 Japan REC10B0002-0100...

Table of Contents