Renesas M16C/62P Group manual

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

Go to page of

A good user manual

The rules should oblige the seller to give the purchaser an operating instrucion of Renesas M16C/62P Group, along with an item. The lack of an instruction or false information given to customer shall constitute grounds to apply for a complaint because of nonconformity of goods with the contract. In accordance with the law, a customer can receive an instruction in non-paper form; lately graphic and electronic forms of the manuals, as well as instructional videos have been majorly used. A necessary precondition for this is the unmistakable, legible character of an instruction.

What is an instruction?

The term originates from the Latin word „instructio”, which means organizing. Therefore, in an instruction of Renesas M16C/62P Group one could find a process description. An instruction's purpose is to teach, to ease the start-up and an item's use or performance of certain activities. An instruction is a compilation of information about an item/a service, it is a clue.

Unfortunately, only a few customers devote their time to read an instruction of Renesas M16C/62P Group. A good user manual introduces us to a number of additional functionalities of the purchased item, and also helps us to avoid the formation of most of the defects.

What should a perfect user manual contain?

First and foremost, an user manual of Renesas M16C/62P Group should contain:
- informations concerning technical data of Renesas M16C/62P Group
- name of the manufacturer and a year of construction of the Renesas M16C/62P Group item
- rules of operation, control and maintenance of the Renesas M16C/62P Group item
- safety signs and mark certificates which confirm compatibility with appropriate standards

Why don't we read the manuals?

Usually it results from the lack of time and certainty about functionalities of purchased items. Unfortunately, networking and start-up of Renesas M16C/62P Group alone are not enough. An instruction contains a number of clues concerning respective functionalities, safety rules, maintenance methods (what means should be used), eventual defects of Renesas M16C/62P Group, and methods of problem resolution. Eventually, when one still can't find the answer to his problems, he will be directed to the Renesas service. Lately animated manuals and instructional videos are quite popular among customers. These kinds of user manuals are effective; they assure that a customer will familiarize himself with the whole material, and won't skip complicated, technical information of Renesas M16C/62P Group.

Why one should read the manuals?

It is mostly in the manuals where we will find the details concerning construction and possibility of the Renesas M16C/62P Group item, and its use of respective accessory, as well as information concerning all the functions and facilities.

After a successful purchase of an item one should find a moment and get to know with every part of an instruction. Currently the manuals are carefully prearranged and translated, so they could be fully understood by its users. The manuals will serve as an informational aid.

Table of contents for the manual

  • Page 1

    www.renesas.com Reference Manual REC10 B 0002-0100 M16C/62P Group Renesas Embedded Application Programming Interface Reference Manual Rev .1.00 Revision Date: Nov .1, 2007[...]

  • Page 2

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 2 Renesas Embedded Application Programming Interface Reference Manual <M16C/62P Group>[...]

  • Page 3

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 3 T able of Contents T able of Contents ............................................................... 3 1. Introduction ................................................................... 5 2. Driver ....................................................................... 6 2.1 Overview ......................[...]

  • Page 4

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 4 __DestroyT imer .......................................................... 43 __CreateEven tCounter ..................................................... 44 __EnableEve ntCounter ..................................................... 47 __DestroyEventC ounter ..................................................[...]

  • Page 5

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 5 1. Introduction The Renesas Embe dded Applicati o n Programmin g Interface (API) is a unified API for the microcomputers ma de by Re nesas T e chnology Corporation.[...]

  • Page 6

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 6 2. Driver 2.1 Overview The library described herein pr ovid es a peripheral facility control program (peripheral driver) for microc omputers. Use of t he Renesas API perm its the peripheral driver t o be built into a user program. 2.2 Driver Features The library described herein has the following features av[...]

  • Page 7

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 7 2.3 Serial Interface Driver The serial interf ace driver sets serial communicati on, clears settings, transmit/recei ves data, and controls the status of serial communicat ion. There are two kinds of serial in terface driver: a single-data transm ission/recept ion API and a multi-data transmission/reception [...]

  • Page 8

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 8 2.4 Timer Driver The timer driver sets th e timer , clears timer settings, c o ntrols timer oper ation, and acquires a counter value with respect to the following mod es: • Timer mode • Event counter mode • Pulse width modulation mode (PWM mode) • Pulse period m easurement mode • Pulse width measur[...]

  • Page 9

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 9 2.5 I/O Port Driver The I/O port driver sets the I/O port for inpu t or output, writes data to th e I/O port, and reads data from the I/O port.[...]

  • Page 10

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 10 2.6 External Interrupt Driver The external interru pt driver sets external interrupts, controls external interru pts, acquires the status of ext e rnal interrupt fl ags, and clears external interrupt flags.[...]

  • Page 11

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 11 2.7 A/D Converter Drive r The A/D converter dr iver sets the A/ D converter , controls t he A/D converter , clears settings of the A/D con verter , acquires the A/D convert er value, acquires the status of the A/D converter , and clears the status of the A/D converter .[...]

  • Page 12

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 12 3. St andard T ypes This section describes the st andard types defined in the library . For details about the set values, refer to the description of each API. St andard type Description Boolean The Boolean type represents the enum-type data that indic ates whether successful (R API_TRUE (= 1)) or failed (R[...]

  • Page 13

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 13 4. Library Reference 4.1 API List by Peripheral Facility The table below lists the Renesas Embedded APIs classified by peripheral facility . NO Facility classification API A PI operation 1 __BasicOpenSerialDriver Opens serial port 2 __BasicCloseSerial Driver Closes serial port 3 __BasicSetSerialFormat Sets [...]

  • Page 14

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 14 35 __CreatePulseWidthMeasure mentMode Sets pulse width measurement mode 36 __EnablePulseWidthMeasurem entMode Controls operat ion of puls e width measurement mode 37 __DestroyPulseWidthMeasurementMode Clears s etting of pulse width measurement mode 38 __GetPulseWidthMeasurementMode Acquir es meas ured value[...]

  • Page 15

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 15 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 eac h API is divided int o the followin g items. • Synop sis : Outlines the content of processing performed by the f unction. It also shows the syntax of the fun[...]

  • Page 16

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 16 4.2.1 Serial I/O __BasicOpenSerialDriver Synopsis <Open a serial port> Boolean __BasicOpenSerialDri ver(unsigned long data) data Setup data Description Opens and initializes a specifi ed seri al port. For dat a, the follo wing values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM[...]

  • Page 17

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 17 __BasicCloseSerialDriver Synopsis <Close a serial port> Boolean __BasicClos eSerialDri ver(unsigned long dat a) data Setup data Description Closes a specified serial p ort. For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 Return[...]

  • Page 18

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 18 __BasicSetSerialFormat Synopsis <Set serial communication> Boolean __Bas icSetSerialFormat(unsign ed long dat a1, unsigned cha r dat a2) data1 Setup data 1 data2 Setup data 2 Description Sets serial communication according to specified parameters. [data1] For data1, the following values can be set. T [...]

  • Page 19

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 19 If the API is used in clock synchronous seri a l communication mode, do not set these values. (UART0, UAR T 1, UART2) RAPI_P ARIT Y_NON No parity bit R API_P ARITY_EVEN Even parity bit RAPI_P ARITY_ ODD Odd parity bit For the clock polarity of serial communic atio n , the following values can be set. If the[...]

  • Page 20

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 20 If serial communication was successfully set, R API_TRUE is returned; if settings failed, RAPI_F ALSE is returned. Functionality Serial I/O Reference Remark • If an undefined value is spec ified in the first argument, operation of the A PI cannot be guaranteed. Program example #include ”rapi_sif_m16c_62[...]

  • Page 21

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 21 __BasicSt artSerialReceiving Synopsis <Receive 1 data> Boolean __Bas icSt artSerialReceiving(uns igned long dat a) data Setup data Description S tarts receiving 1 data of serial communication. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 S[...]

  • Page 22

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 22 __BasicSt artSerialSending Synopsis <Transmit 1 dat a> Boolean _Basic St artSerialSending( unsigned long dat a1, unsigned int da ta2) data Setup data data T ransmit data Description S tarts sending 1 data of serial communication. For dat a1, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 U[...]

  • Page 23

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 23 __BasicReceivingSt atusRead Synopsis <Read receive status> unsigned int _ _BasicRece ivingSt atusRead(unsigned lo ng dat a) data Setup data Description Returns the re ceive status of serial communication. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2[...]

  • Page 24

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 24 __BasicSendingSt atusRead Synopsis <Read transmit status> Boolean __BasicSe ndingS ta tus R ea d(uns igne d long data) data Setup data Description Returns the transmit status of serial comm unication. For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 [...]

  • Page 25

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 25 __BasicStopSerialReceiving Synopsis <S top reception> Boolean Rapi_B asicS topSerialReceiving(unsigned long da t a) data Setup data Description S tops receiving data in serial communication [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 Return value I[...]

  • Page 26

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 26 __BasicStopSerialSending Synopsis <S top transmission> Boolean __Bas icSt opSerialSending(uns igned long da t a) data Setup data Description S tops transmitting data in serial communication. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 Return value [...]

  • Page 27

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 27 __OpenSerialDriver Synopsis <Open a serial port> Boolean __OpenSeria lDriver(unsigned long da ta) data Setup data Description Opens and initializes a specifi ed seri al port. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/[...]

  • Page 28

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 28 __CloseSerialDriver Synopsis <Close a serial port> Boolean __Clos eSerialDriver(unsigne d long data) data Setup data Description Closes a specif ied serial port. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 Return val[...]

  • Page 29

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 29 __ConfigSerialDriverNotify Synopsis <Register a notifi cation function> Boolean __ConfigSerialDriv erNotify(unsigned lo ng data, V oidFuncNoti fy *func) data Setup data func Function pointer to be registered Description Regist ers the notification f unction necessary to get various transmit/rece ive i[...]

  • Page 30

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 30 Return value If the serial port specification is inco rr ect, RAPI_F ALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Serial I/O Reference __S tartSerialReceiving , __S tartSerialSending Remark • If an undefined value is specified in the fi rst argument, operation of the API cannot be gua[...]

  • Page 31

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 31 __SetSerialFormat Synopsis <Set serial communication> Boolean __SetSeria lFormat(unsigned long dat a1, unsigned char da ta 2) data1 Setup data 1 data2 Setup data 2 Description Sets serial communication according to spec ified parameters. For details about parameters, refer to the description of __Basi[...]

  • Page 32

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 32 __SetSerialInterrupt Synopsis < Set serial inte rrupts> Boolean __SetSerialInterrupt(unsigne d l ong da t a) data Setup data Description Sets serial interrupts accord ing to specified parameters. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM[...]

  • Page 33

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 33 Functionality Serial I/O Reference Remark • If an undefined value is specified in the ar gument, operation of the API cann ot be guaranteed. Program example #include ”rapi_sif_m16c_62p” Boolean func( void ) { /* Set interrupt of RAPI_COM1 to serial driver */ return __SetSerialInterrupt( RAPI_COM1 | RA[...]

  • Page 34

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 34 __St artSerialReceiving Synopsis <S tart reception> Boolean __S tartSerialReceiv i ng(unsigned long da ta, unsigned char wordNum, unsigned int *Rcv DtBuf) data Setup data wordNum Number of words received RcvDtBuf Pointer to the buffer in which received data is stored Description S tarts reception of s[...]

  • Page 35

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 35 __St artSerialSending Synopsis <S tart transmission> Boolean __S tartSerialSending(unsigne d long dat a, unsigned char w ordNum, unsigned int *SndDtBuf) data Setup data wordNum Number of words transmitted SndDtBuf Pointer to the transmit data Description S tarts transmission of serial communication an[...]

  • Page 36

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 36 __StopSerialReceiving Synopsis <S top reception> Boolean __StopSerialReceiving( u nsigned long data) data Setup data Description S tops reception of serial communic ation. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UAR T1 RAPI_COM3 UART2 Return value If reception of se[...]

  • Page 37

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 37 __StopSerialSending Synopsis <S top transmission> Boolean __S topSerialSending(unsigned long data) data Setup data Description S tops transmission of serial communicatio n. [data] For data, the following values can be set. RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 Return value If transmission of[...]

  • Page 38

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 38 __PollingSerialReceiving Synopsis <Polling reception> Boolean __PollingSerialRecei ving(unsigned lon g data ) data Setup data Description Performs reception of serial communicatio n by polling. This API gets received data by an amount specified by __St a rtSerialReceivi ng. When ac quisition of receiv[...]

  • Page 39

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 39 __PollingSerialSending Synopsis <Polling transmission> Boolean __PollingSerialSe nding(unsigne d long data) data Setup data Description Performs transmission of serial communicati on by polling. This API sends transmit data by an amount specified by __St artSerialS ending from the transmit data buffer[...]

  • Page 40

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 40 4.2.2 Timer __CreateTimer Synopsis <Set timer mode> Boolean __Cre ateT imer(unsigned long dat a1, unsigned int dat a2, unsigned int dat a3, unsigned int dat a4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func Callback function pointer (S pecify 0 if no call[...]

  • Page 41

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 41 (Count sou rce) S pecify one from { RAPI_ F1, RAPI_F2, RAPI_F8, RAPI_F32, RAPI_FC32 }. The default value is RAPI_F2. (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TI MER_OFF }. The default value is RAPI_TIMER_OFF . (Pulse output state) S pecify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The[...]

  • Page 42

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 42 __EnableTimer Synopsis <Control o peration of timer mode> Boolean __EnableT imer(unsigned long dat a) data Setup data Description Controls operation of the tim er that is se t to specified timer mode by starting or stopping it. [data] For data, the following definition values can b e set. T o set mult[...]

  • Page 43

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 43 __DestroyTimer Synopsis <Discard settings of timer mode> Boolean __DestroyT imer(unsigned long dat a) data Setup 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 Selects timer A channel 0. RA[...]

  • Page 44

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 44 __CreateEventCounter Synopsis <Set event counter mode> Boolean __Cre ateEventCounter(unsigne d long data 1, unsigned int data2, unsigned int data3, unsigne d int data4, void* fu nc) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func Callback function pointer (S pecify 0 i[...]

  • Page 45

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 45 RAPI_UP_COUNT Selects up-count for the count operation. RAPI_DOWN_COUNT Selects down-count for the count operation. RAPI_UDF_REGISTER Selects the UDF register for the cause of up/down switching. RAPI_T AIOUT Selects the input signal at T A iOU T pin for the cause of up/do wn switching. RAPI_RISING Selects t[...]

  • Page 46

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 46 [data4] Specify 0. Return value If the timer specification is incorrect, R API_F ALSE is returned; other wise, RAPI_TRUE is returned. Functionality T imer (event counter mode) Reference __EnableEventCounter , __DestroyEventCounter , __GetEve ntCounter Remark • If an undefined value is specified i n the fi[...]

  • Page 47

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 47 __EnableEventCounter Synopsis <Control operation of event counter mode> Boolean __Enable E ventCounter(uns igned long data) data Setup data Description Controls operation of the timer that is set to specified timer mode b y starting or stopping it. [data] For data, the following definition values can [...]

  • Page 48

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 48 __DestroyEventCounter Synopsis <Discard settings of event counter mode> Boolean __Des troyEventCounter(unsigne d long data ) data Setup 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 Select[...]

  • Page 49

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 49 __GetEventCounter Synopsis <Get event counter mode counter value> Boolean __GetEv entCounter(unsigned long da ta 1, unsigned int *dat a2) data1 Setup data 1 data2 Pointer to the buffer in which counter value is stored Description Gets the counter value of the timer that is set to specified event count[...]

  • Page 50

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 50 __CreatePulseWid thMo dulationMode Synopsis <Set pulse width modulation mode> Boolean __Cre atePuls eWid thModulationMode(unsig ned long dat a1, unsigned int dat a2, unsigned int* dat a3, void* dat a4) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 func Callback function pointer (S pecify 0 [...]

  • Page 51

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 51 RAPI_F ALLING Select s the falling edge of T A iIN pin input signal as active edge. • Specifiable definition values when timer A is used (R API_TIMER_A0 to RAPI_TIMER_A4 specified) (Count source) S pecify one from { RAPI_F1, R API_F2, RAPI_F32, RAPI_FC32 }. The default value is RAPI_F2. (Operating states [...]

  • Page 52

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 52 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, 5, p_tim, TimerIntFunc); }[...]

  • Page 53

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 53 __EnablePulseWid thModulationMode Synopsis <Control operation of puls e width modulation mode> Boolean __Enable PulseWidthMod ulationMode(unsigned long da t a) data Setup data Description Controls operation of the time r that is se t to specified pulse width modulation mode b y starting or stopping it[...]

  • Page 54

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 54 __DestroyPulseWid thModulationMode Synopsis <Discard settings of pulse width modulation mode> Boolean __Des troyPulseWid thModulationMode(unsig ned long data ) data Setup data Description Discards settings of the timer that is set to specified pulse width modulation mode. [data] For data, the followin[...]

  • Page 55

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 55 __CreatePulsePeriodMeasurementMode Synopsis < Set pulse period measurement mode> Boolean __CreatePul sePeriodMeasu rem entMode(unsigned lon g data1, unsigned int data2, unsigne d int data3, u nsigned int dat a4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 fu[...]

  • Page 56

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 56 [data3] S pecify 0. [data4] S pecify 0. Return value If the timer specification is incorrect , RAPI_F ALSE is returned; otherwise, RAPI_TRUE is returned. Functionality Timer (pulse period measurement mode) Reference __EnablePu lsePeriodMeasurementMode , __DestroyPulsePeriodMeas urementMode , __GetPulsePerio[...]

  • Page 57

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 57 __EnablePulsePeriodMeasurementMode Synopsis <Control operation of pulse pe riod me asurement mode> Boolean __EnablePu lsePeriodMeasurem entMode(unsigned lon g dat a) data Setup data Description Controls operation of the timer that is set to specified pulse period measur ement mode by starting or stopp[...]

  • Page 58

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 58 __DestroyPulsePeriodMeasurementMode Synopsis <Discard settings of pulse period meas ureme nt mode> Boolean __Destro yPulsePeriodMeasuremen tMo d e(unsigned long data) data Setup data Description Discards settings of the timer that is set to specified pulse period measure ment mode. [data] For data, th[...]

  • Page 59

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 59 __GetPulsePeriodMeasurementMode Synopsis <Get measured value in pulse peri od measurement mode> Boolean __GetPulsePeriod MeasurementM od e(unsigned long d ata1, unsigned int *data2) data1 Setup data 1 data2 Pointer to the buffer in which counter value is stored Description Gets the counter value of th[...]

  • Page 60

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 60 __CreatePulseWid thMea surementMode Synopsis <Set pulse width measurement mode> Boolean __CreatePul seWidthMeasurementMode(unsigned long dat a1 , unsigned int dat a2, unsigned int dat a3, unsigned int da t a4, void* func) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 func[...]

  • Page 61

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 61 [data4] S pecify 0. Return value If the timer specification is incorrect, R API_F ALSE is returned; otherwise, RAPI_TRUE is returned. Functionality T imer (pulse width measurement mode) Reference __EnablePulseWidthMeasurementMod e , __DestroyPulseW idthMeasurementMode , __GetPulseWidthMeasurementMode Remark[...]

  • Page 62

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 62 __EnablePulseWid thMeasurementMode Synopsis <Control operation of pulse width measurement mode> Boolean __Enab l ePu lseWidthMeasurementMode(unsig ned long data) data Setup data Description Controls operation of the timer that is se t to specified pulse width measurement mode. [data] For data, the fol[...]

  • Page 63

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 63 __DestroyPulseWid thMeasurement Mode Synopsis <Discard settings of pulse width measurement mode> Boolean __Destro yPulseWidthMeasurementMode(un sign ed long data) data Setup data Description Discards settings of the timer that is set to specified pulse width measurement mode. [data] For data, the foll[...]

  • Page 64

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 64 __GetPulseWid thMeasurementMode Synopsis <Get measured value in pulse width measurement mode> Boolean __GetPulseWidthMeasurementMode(u nsign ed long d ata1, unsigned int *data2) data1 Setup data 1 data2 Pointer to the buffer in which counter value is stored Description Gets the counter value of the ti[...]

  • Page 65

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 65 __SetTimerRegister Synopsis <Set timer register> Boolean __SetT imerRegister(unsigned long dat a1, unsigned int *dat a2) data1 Setup data 1 data2 Pointer to the buffer in which register value is stored Description Sets the registers of a specified timer . [data1] For data, the following definition val[...]

  • Page 66

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 66 If an undefined value is specified in the first argum ent, 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 */ _[...]

  • Page 67

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 67 __EnableTimerRegister Synopsis <Control operation of timer register> Boolean __Enable TimerRegister(uns igned long data ) data Setup data Description Controls operation of a spec ified timer by starting or stopping it. [data] For data, the following definition values can be set. T o set multiple defi [...]

  • Page 68

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 68 __ClearTimerRegister Synopsis <Clear timer register> Boolean __Cle arTime rRegister(unsigned long dat a) data Setup 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 Selects timer A[...]

  • Page 69

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 69 __GetTimerRegister Synopsis <Get timer register value> Boolean __GetT imerRegister(unsigned long dat a1, unsigned int *dat a2) data1 Setup data data2 Pointer to the buffer in which register value is stored Description Gets the counter value of a specified timer . [data] For data, the following definit[...]

  • Page 70

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 70 Reference __SetT imerRegister , __EnableTimerRegister , __ClearTimerRegister Remark • If an undefined value is specified i n the first argument, operation of the AP I cannot be guaranteed. Program example #include " rapi_timer_m16c_62p.h" void func( void ) { unsigned int data[7]; /* Get the valu[...]

  • Page 71

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 71 4.2.3 I/O Port __SetIOPort Synopsis <Set I/O port> Boolean __SetIOPort(uns igned long dat a1, unsigned int dat a2) data1 Setup data 1 data2 Setup data 2 Description Sets the operating conditions of a specified I/O port. [data1] For data1, the following definition values can be set. T o set multiple de[...]

  • Page 72

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 72 RAPI_PORT_7_2 Port P7 2 RAPI_PORT_7_3 Port P7 3 RAPI_PORT_7_4 Port P7 4 RAPI_PORT_7_5 Port P7 5 RAPI_PORT_7_6 Port P7 6 RAPI_PORT_7_7 Port P7 7 RAPI_PORT_8_0 Port P8 0 RAPI_PORT_8_1 Port P8 1 RAPI_PORT_8_2 Port P8 2 RAPI_PORT_8_3 Port P8 3 RAPI_PORT_8_4 Port P8 4 RAPI_PORT_8_5 Port P8 5 RAPI_PORT_8_6 Port P[...]

  • Page 73

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 73 Functionality I/O port Reference __ReadIOPort , __WriteIOPort , __SetIOPortRegister , __ReadIOPortRegister , __WriteIOPortRegister Remark • If an undefined value is specified i n the first argument, operation of the API cannot be guaranteed. Program example #include " rapi_io_port_m16c_62p.h" vo[...]

  • Page 74

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 74 __ReadIOPort Synopsis <Read from I/O port> Boolean __Rea dIOPort(unsigned long da ta1, unsigned int *data2) data1 Setup data 1 data2 Pointer to the variable in which the value read from I/O port is stored. Description Gets the value of a specified I/O port. [data1] S pecify an I/O port from which data[...]

  • Page 75

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 75 RAPI_PORT_9_6 Port P9 6 RAPI_PORT_9_7 Port P9 7 RAPI_PORT_10_0 Port P10 0 RAPI_PORT_10_1 Port P10 1 RAPI_PORT_10_2 Port P10 2 RAPI_PORT_10_3 Port P10 3 RAPI_PORT_10_4 Port P10 4 RAPI_PORT_10_5 Port P10 5 RAPI_PORT_10_6 Port P10 6 RAPI_PORT_10_7 Port P10 7 RAPI_PORT_1 1_0 Port P1 1 0 RAPI_PORT_1 1 _1 Port P1[...]

  • Page 76

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 76 __WriteIOPort Synopsis <Write to I/ O port> Boolean __W riteIOPort(unsigned long dat a1, unsigned int da t a2) data1 Setup data 1 data2 Data to be written to I/O port Description Writes data to a specified I/O port. [data1] S pecify an I/O port to which data is written. The definition values correspon[...]

  • Page 77

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 77 RAPI_PORT_9_6 Port P9 6 RAPI_PORT_9_7 Port P9 7 RAPI_PORT_10_0 Port P10 0 RAPI_PORT_10_1 Port P10 1 RAPI_PORT_10_2 Port P10 2 RAPI_PORT_10_3 Port P10 3 RAPI_PORT_10_4 Port P10 4 RAPI_PORT_10_5 Port P10 5 RAPI_PORT_10_6 Port P10 6 RAPI_PORT_10_7 Port P10 7 RAPI_PORT_1 1_0 Port P1 1 0 RAPI_PORT_1 1_1 Port P1 [...]

  • Page 78

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 78 __SetIOPortRegister Synop sis <Set I/O port register> Boolean __Set IOPortRegiste r(unsigne d l ong da t a1, unsigned int da t a2, unsigned int dat a3, unsigned int dat a4) data1 Setup data 1 data2 Setup data 2 data3 Setup data 3 data4 Setup data 4 Description [dat a1] Set the operating cond ition of [...]

  • Page 79

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 79 If an undefined value is specified in the first argum ent, 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 ); }[...]

  • Page 80

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 80 __ReadIOPortRegister Synopsis <Read from I/O port register> Boolean __ReadIOPortRegi ster(unsigned long data 1, unsigned int *dat a2) data1 Setup data 1 data2 Pointer to the var iable in which the val ue read from I/O port register i s stored. Description Gets the value of a specified I/O port from ea[...]

  • Page 81

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 81 __WriteIOPortRegister Synopsis <Write to I/O port register> Boolean __W riteIOPortRegister(unsigned long dat a1, unsigned int dat a2) data1 Setup dat a 1 data2 Dat a to be written to I/O port register Description Writes the value for a specified I/O port to eac h relevant register . [data1] S pecify a[...]

  • Page 82

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 82 4.2.4 External interrupt __SetInterrupt Synopsis <Set external interrupt> Boolean __SetInterrupt(uns igned long dat a1, unsigned int dat a2, void* func) data1 Setup data 1 data2 Setup data 2 func Callback function pointer (S pecify 0 if no callback functions are set.) Description Sets a specified exte[...]

  • Page 83

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 83 Return value If the external interrupt specification is inc orrect, RAPI_F ALSE is returned; other wise, RAPI_TRUE is returned. Functionality External interrupt Reference __EnableInterrupt , __GetInterruptFlag , __ClearInterruptFlag Remark • If an undefined value is specified in the first argum ent, opera[...]

  • Page 84

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 84 __EnableInterrupt Synopsis <Control external interrupt> Boolean __Enable Interrupt(unsigned long dat a1, unsigned int dat a2) data1 Setup data 1 data2 Setup data 2 Description Changes the operating conditi on of a specified external interrupt. [data1] RAPI_INT0 Uses _INT0 interrupt. RAPI_INT1 Uses _IN[...]

  • Page 85

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 85 __GetInterruptFlag Synopsis <Get the status of external interrupt flag> Boolean __GetInterruptFlag (unsigned long dat a1, unsigned int *dat a2)) data1 Setup data 1 data2 Pointer to the buffer in which the acquired flag data is stored Description Gets the value of interrupt request fl ag of a specified[...]

  • Page 86

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 86 __ClearInterruptFlag Synopsis <Clear external interrupt flag> Boolean __Cle arInterruptFlag(unsigne d long data ) data Setup data Description Clears the interrupt request flag of a specified exter nal interrupt. [data] RAPI_INT0 Uses _INT0 interrupt. RAPI_INT1 Uses _INT1 interrupt. RAPI_INT2 Uses _INT[...]

  • Page 87

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 87 4.2.5 A/D converter __CreateADC Synopsis <Set A/D converter> Boolean __Cre ateADC(unsigned l ong data1 , unsigned int dat a2, unsigned int dat a3, void* func) data1 Setup data 1 data2 Number of analog input pins used by A/D converter data3 Setup data 3 func Callback function pointer (Specify 0 if no c[...]

  • Page 88

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 88 RAPI_AN27 Uses AN 27 pin for the analog input pin. RAPI_P0_GROUP Uses port P 0 group for the analog input pin. RAPI_P10_GROUP Uses port P 10 group for the analog input pin. RAPI_P2_GROUP Uses port P 2 group for the analog input pin. RAPI_F AD Sets the AD converter ’s operating frequency to f AD . RAPI_F A[...]

  • Page 89

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 89 (Input pin) S pecify one from { RA PI_AN0, RAPI_AN1, RAPI_AN2, R API_AN3, RAPI_AN4, RAPI_AN5, R API_AN6, RAPI_AN7, RAP I_AN00, R API_AN01, RA PI_AN02, RAPI_AN 03, RAPI_AN04, RA PI_AN05, R API_AN06 , RAPI_AN 07, RAPI_AN20, RAPI_AN 21, RAPI_AN22, RA PI_AN23, R API_AN24 , RAPI_AN 25, RAPI_AN26, RAPI_AN27, RAPI[...]

  • Page 90

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 90 (Operating states set) S pecify one from { RAPI_AD_ON, RAPI_AD_ OFF }. The default value is RAPI_AD_OFF . (Conversion method) S pecify one from { RAPI_WITH_S AMPLE_HOLD, RAPI_WITHOUT_SAMPLE_HOLD }. The default value is RAPI_WITHOUT_SAMPLE_HOLD. (T ri gger) S pecify one from { RAPI_S OFTWARE_TRIGGER, RAPI_EX[...]

  • Page 91

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 91 Remark • If an undefined value is spec ified in th e fi rst ar gument, operat ion of the API cannot be guaranteed. Program example #include " rapi_ad_ m16 c_62p.h" void AdIntFunc( void ){} void func( void ) { /* Set up A/D converter as one short mode */ __CreateADC( RAPI_ONE_SHOT|RAPI_AN2|RAPI_F[...]

  • Page 92

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 92 __EnableADC Synopsis <Control operation of A/D converter> Boolean __EnableA DC (unsigned long dat a1, unsigned int dat a2) data1 Setup data 1 data2 Number of analog input pins used by A/D converter Description Controls operation of the A/D conv erter by starting or stopping it. [data1] RAPI_AN0 Uses A[...]

  • Page 93

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 93 RAPI_AN21 Uses AN 21 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN22 Uses AN 22 pin for the analog input pin. Selectable only when one-shot mode or repeat mode is used. RAPI_AN23 Uses AN 23 pin for the analog input pin. Selectable only when one-shot mode or[...]

  • Page 94

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 94 Program example #include "rapi_ad_ m16 c_62p.h" void func( void ) { /* Disable A/D converter */ __EnableADC( RAPI_AN0|RAPI_AD_OFF, 1 ); }[...]

  • Page 95

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 95 __DestroyADC Synopsis <Discard settings of A/D converter> Boolean __Destroy ADC(void) Description Discards settings of a specified A/D converter . Return value If converter setting was successfully discar ded, RAPI_TRUE is returned; if failed, RAPI_F ALSE is returned. Functionality A/D converter Refer[...]

  • Page 96

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 96 __GetADC Synopsis <Get A/D converted val ue (register spec ified)> Boolean __GetA DC(unsigned long dat a1, unsigned int *dat a2) data1 Setup data 1 data2 Pointer to the buffer in which A/D converted value is stored. Description Gets the A/D converted value fr om a specified A/D register . For data1, t[...]

  • Page 97

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 97 __GetADCAll Synopsis <Get A/D converted va lue (all registers)> Boolean __Get ADCAll(unsigned int *data) data Pointer to the buffer in which A/D converted value is stored. Description Gets the A/D converted valu e from all A/D registers. The A/D registers from which A/D convert ed values are acquired [...]

  • Page 98

    Rev .1.00 2007.1 1.1 REC10 B0002-0 100 98 M16C/62P Group Renesas Embedded Application Programming Interface Reference Manual Rev . 1.00 Issued: November 2007[...]