Renesas RJJ10J1643-0101 manuel d'utilisation

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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

Aller à la page of

Un bon manuel d’utilisation

Les règles imposent au revendeur l'obligation de fournir à l'acheteur, avec des marchandises, le manuel d’utilisation Renesas RJJ10J1643-0101. Le manque du manuel d’utilisation ou les informations incorrectes fournies au consommateur sont à la base d'une plainte pour non-conformité du dispositif avec le contrat. Conformément à la loi, l’inclusion du manuel d’utilisation sous une forme autre que le papier est autorisée, ce qui est souvent utilisé récemment, en incluant la forme graphique ou électronique du manuel Renesas RJJ10J1643-0101 ou les vidéos d'instruction pour les utilisateurs. La condition est son caractère lisible et compréhensible.

Qu'est ce que le manuel d’utilisation?

Le mot vient du latin "Instructio", à savoir organiser. Ainsi, le manuel d’utilisation Renesas RJJ10J1643-0101 décrit les étapes de la procédure. Le but du manuel d’utilisation est d’instruire, de faciliter le démarrage, l'utilisation de l'équipement ou l'exécution des actions spécifiques. Le manuel d’utilisation est une collection d'informations sur l'objet/service, une indice.

Malheureusement, peu d'utilisateurs prennent le temps de lire le manuel d’utilisation, et un bon manuel permet non seulement d’apprendre à connaître un certain nombre de fonctionnalités supplémentaires du dispositif acheté, mais aussi éviter la majorité des défaillances.

Donc, ce qui devrait contenir le manuel parfait?

Tout d'abord, le manuel d’utilisation Renesas RJJ10J1643-0101 devrait contenir:
- informations sur les caractéristiques techniques du dispositif Renesas RJJ10J1643-0101
- nom du fabricant et année de fabrication Renesas RJJ10J1643-0101
- instructions d'utilisation, de réglage et d’entretien de l'équipement Renesas RJJ10J1643-0101
- signes de sécurité et attestations confirmant la conformité avec les normes pertinentes

Pourquoi nous ne lisons pas les manuels d’utilisation?

Habituellement, cela est dû au manque de temps et de certitude quant à la fonctionnalité spécifique de l'équipement acheté. Malheureusement, la connexion et le démarrage Renesas RJJ10J1643-0101 ne suffisent pas. Le manuel d’utilisation contient un certain nombre de lignes directrices concernant les fonctionnalités spécifiques, la sécurité, les méthodes d'entretien (même les moyens qui doivent être utilisés), les défauts possibles Renesas RJJ10J1643-0101 et les moyens de résoudre des problèmes communs lors de l'utilisation. Enfin, le manuel contient les coordonnées du service Renesas en l'absence de l'efficacité des solutions proposées. Actuellement, les manuels d’utilisation sous la forme d'animations intéressantes et de vidéos pédagogiques qui sont meilleurs que la brochure, sont très populaires. Ce type de manuel permet à l'utilisateur de voir toute la vidéo d'instruction sans sauter les spécifications et les descriptions techniques compliquées Renesas RJJ10J1643-0101, comme c’est le cas pour la version papier.

Pourquoi lire le manuel d’utilisation?

Tout d'abord, il contient la réponse sur la structure, les possibilités du dispositif Renesas RJJ10J1643-0101, l'utilisation de divers accessoires et une gamme d'informations pour profiter pleinement de toutes les fonctionnalités et commodités.

Après un achat réussi de l’équipement/dispositif, prenez un moment pour vous familiariser avec toutes les parties du manuel d'utilisation Renesas RJJ10J1643-0101. À l'heure actuelle, ils sont soigneusement préparés et traduits pour qu'ils soient non seulement compréhensibles pour les utilisateurs, mais pour qu’ils remplissent leur fonction de base de l'information et d’aide.

Table des matières du manuel d’utilisation

  • Page 1

    www.renesas.com REJ10J1502-0101 Renesas Embedded Application Programming Interface Reference manual Rev .1.01 Feb 1 6, 2007[...]

  • Page 2

    Rev .1.01 2007.02.16 RJJ10J1643-0101 2 REVISION HISTOR Y Rev . Summary Date 1.00 06.04.07 1.01 ・ Additions and corrections made for support of libraries for the H8/36094, H8/36077, H8/36109, and R8C/24 and 25 ・ Unnecessary periods in Chapte r 1, “Instruction,” deleted ・ Port P73 of H8 deleted ・ Channels A–D written in CreateInputCaptu[...]

  • Page 3

    Rev .1.01 2007.02.16 RJJ10J1643-0101 3 ・ Description of third argument in __CreateInput Capture corrected ・ W ording “specified” uni fie d to “specified” ・ RAPI_BOTH deleted from the description of timer B1 count edges of H8/300H in __CreateEventCounter ・ RAPI_FTIOA and RAPI_FTIOB added to __CreatePulsePeriodMeasurem entMode and __C[...]

  • Page 4

    Rev .1.01 2007.02.16 RJJ10J1643-0101 4 ・ RAPI_AN30, RAPI_AN31, RAPI_AN32, and RAPI_P9_GROUP add e d to the item for data1 of M16C in __CreateADC ・ RAPI_AN30, RAPI_AN31, RAPI_AN32, and RAPI_P9_GROUP add e d to the item for data1 of M16C in __EnableADC ・ Error in writing of H8/300H interrupt set values in __CreateOutputCompare corrected ・ Err[...]

  • Page 5

    Rev .1.01 2007.02.16 RJJ10J1643-0101 5 T able of Contents T able of Contents ............................................................... .5 1. Introduction ................................................................... 8 2. Driver ....................................................................... 9 2.1 Overview .......................[...]

  • Page 6

    Rev .1.01 2007.02.16 RJJ10J1643-0101 6 __CreateT imer ........................................................... 54 __EnableT imer ........................................................... 60 __DestroyT imer .......................................................... 62 __CreateEven tCounter ..................................................... 6[...]

  • Page 7

    Rev .1.01 2007.02.16 RJJ10J1643-0101 7 __GetADC ............................................................. 197 __GetADCAll ........................................................... 198 __GetADCS tatus ......................................................... 199 __ClearADCS tatus ....................................................... 200[...]

  • Page 8

    Rev .1.01 2007.02.16 RJJ10J1643-0101 8 1. Introduction The Renesas Embe dded Applic ation Programming Interface ( API) is a unified API for the microcomputers ma de by Re nesas T e chnology Corporation.[...]

  • Page 9

    Rev .1.01 2007.02.16 RJJ10J1643-0101 9 2. Driver 2.1 Overview The library described herein pr ovid es a peripheral facility control program (peripheral driver) for microc o mputers. Use of t he Renesas API permits the p eripheral driver to be built into a user program. Configuration of R enesas APIs is shown below . File name Description rapi_ xxx [...]

  • Page 10

    Rev .1.01 2007.02.16 RJJ10J1643-0101 10 2.2 Driver Features The library described herein has the following features available as a peripheral driver . (1) Serial I/O control feature It comprises a serial int erface driver , which sets or clears the conditi ons of serial communication, as well as control s and manages the transmission/reception of c[...]

  • Page 11

    Rev .1.01 2007.02.16 RJJ10J1643-0101 11 2.3 Serial Interface Driver The serial interf ace driver sets serial communic ation, clears settings, trans mit/receives data, and controls the status of serial communicat ion. There are two kinds of serial in terface driver: a single-data tran smission/recept ion API and a multi-data transmission/reception A[...]

  • Page 12

    Rev .1.01 2007.02.16 RJJ10J1643-0101 12 2.4 Timer Driver The timer driver sets th e timer , clears timer settings, c ontrols timer operation, and acquires a counter value with respect to the following m o des: • Timer mode • Event counter mode • Pulse width modulation mode (PWM mode) • Pulse period m easurement mode • Pulse width measur e[...]

  • Page 13

    Rev .1.01 2007.02.16 RJJ10J1643-0101 13 2.4.7 Output Comp are Mode In this mode, the timer generates an inte rrupt request wh en the timer counter and a comparison value m atch. When a compare match int errupt or an underflow or an overflow interrupt occurs, it calls a preset callbac k function.[...]

  • Page 14

    Rev .1.01 2007.02.16 RJJ10J1643-0101 14 2.5 I/O Port Driver The I/O port driver sets the I/O port for inpu t or output, writes data to th e I/O port, and reads data from the I/O port.[...]

  • Page 15

    Rev .1.01 2007.02.16 RJJ10J1643-0101 15 2.6 External Interrupt Driver The external interru pt driver sets external interrupts, controls external interru pts, acquires the status of ext ernal interrupt fl ags, and clears external interrupt flags.[...]

  • Page 16

    Rev .1.01 2007.02.16 RJJ10J1643-0101 16 2.7 A/D Converter Driver The A/D converter dr iver sets the A/ D converter , controls the A/D conver ter , clears settings of the A/D con verter , acquires the A/D conv erter value, acquires the status of the A/D converter , and clears the status of the A/D converter . [A/D converter driv er usage example (si[...]

  • Page 17

    Rev .1.01 2007.02.16 RJJ10J1643-0101 17 Program example #include "rapi_ad_r8c_13.h" void main( void ) { unsigned int status, data; /* Set up A/D converter as one short mode */ __ CreateADC( RAPI _ ONE _ SHOT|RAPI _ AN0|RAPI _ FAD2| RAPI_WITH_SAMPLE_HOLD| RAPI_AD_OFF|RAPI_10BIT, 1, 0, 0 ); while( 1 ){ /* Disable A/D converter */ __EnableAD[...]

  • Page 18

    Rev .1.01 2007.02.16 RJJ10J1643-0101 18 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-typ e data that ind icates whether successful (R API_TRUE (= 1)) or failed (RA[...]

  • Page 19

    Rev .1.01 2007.02.16 RJJ10J1643-0101 19 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 P I operation 1 __BasicOpenSerialDriver Opens serial port 2 __BasicCloseSerial Driver Closes serial port 3 __BasicSetSerialFormat Sets s[...]

  • Page 20

    Rev .1.01 2007.02.16 RJJ10J1643-0101 20 35 __CreatePulseWidthMeasure mentMode Sets pulse width measurement mode 36 __EnablePulseWidthMeasurem entMode Controls opera tion of pulse width measurement mode 37 __DestroyPulseWidthMeasurementMode Clears s etting of pulse width measurement mode 38 __GetPulseWidthMeasurementMode Acquir es measured value of [...]

  • Page 21

    Rev .1.01 2007.02.16 RJJ10J1643-0101 21 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 into the followin g items. • Synop sis : Outlines the content of processing performed by the f unction. It also shows the syntax of the functi[...]

  • Page 22

    Rev .1.01 2007.02.16 RJJ10J1643-0101 22 4.2.1 Serial I/O __BasicOpenSerialDriver Synopsis <Open a serial port> Boolean __BasicOpenSerialDri ver(unsigned long d ata) data Setup data Description Opens and initializes a specifi ed serial port. For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_[...]

  • Page 23

    Rev .1.01 2007.02.16 RJJ10J1643-0101 23 __BasicCloseSerialDriver Synopsis <Close a serial port> Boolean __BasicClos eSerialDriver(unsigned long dat a) data Setup data Description Closes a specified serial p ort. For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 (R[...]

  • Page 24

    Rev .1.01 2007.02.16 RJJ10J1643-0101 24 __BasicSetSerialFormat Synopsis <Set serial communication> Boolean __Bas icSetSerialFormat(unsigned long dat a1, unsigned cha r data2 ) 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 o s[...]

  • Page 25

    Rev .1.01 2007.02.16 RJJ10J1643-0101 25 If the API is used in clock synchronous seri a l communication mode, do not set these values. (M16C) (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 ation, the following values can be set. If [...]

  • Page 26

    Rev .1.01 2007.02.16 RJJ10J1643-0101 26 (R8C) (UART0, UART1) RAPI_SM_SYNC Clock synchronous serial communication mode RAPI_SM_ASYNC Clock asy nchron ous serial communication mode For the data length format of clock asynchro nous serial communication, the follo wing values can be set. If the API is used in clock synchronous seri a l communication mo[...]

  • Page 27

    Rev .1.01 2007.02.16 RJJ10J1643-0101 27 RAPI_COM3 SCI3 channel 3 For serial communication mode, the follo wing values can be set. (H8/300H) (SCI3 channel 1, SCI3 chan nel 2, SCI3 channel 3) RAPI_SM_SYNC Clock synchronous serial communication mode RAPI_SM_ASYNC Clock asynchronous serial communication mode For the data length format of clock asynchro[...]

  • Page 28

    Rev .1.01 2007.02.16 RJJ10J1643-0101 28 Functionality Serial I/O Remark • The specifiable serial p orts differ w it h each CPU used. • If an undefined value is spec ified in the first argument, operation of the A PI cannot be guaranteed. Program example #include ”rapi_sif_r8c_13.h” Boolean func( void ) { /* Set the data of RAPI_COM1 to seri[...]

  • Page 29

    Rev .1.01 2007.02.16 RJJ10J1643-0101 29 __BasicSt artSerialReceiving Synopsis <Receive 1 data> Boolean __Bas icStartSe rialReceiving(unsigned long d ata) data Setup data Description S tarts receiving 1 data of serial communication. [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_CO[...]

  • Page 30

    Rev .1.01 2007.02.16 RJJ10J1643-0101 30 __BasicSt artSerialSending Synopsis <Transmit 1 dat a> Boolean _Basic Sta rtSerialSending(unsigne d long data 1, unsigned int dat a2) data Setup data data T ransmit data Description S tarts sending 1 data of serial communication. For data1, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_CO[...]

  • Page 31

    Rev .1.01 2007.02.16 RJJ10J1643-0101 31 __BasicReceivingSt atusRead Synopsis <Read receive status> unsigned int _ _BasicReceivingSt atusRead(unsigned long data) data Setup data Description Returns the receive status of serial communication. [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART[...]

  • Page 32

    Rev .1.01 2007.02.16 RJJ10J1643-0101 32 Remark • The specifiable serial ports differ with each CPU used. • If an undefined value is specified in the argument, operation of the API cannot be guaranteed. Program example #include ”rapi_sif_r8c_13.h” void func( void ) { unsigned int rcv_data; .......... rcv_data = __BasicReceivingStatusRead( RA[...]

  • Page 33

    Rev .1.01 2007.02.16 RJJ10J1643-0101 33 __BasicSendingSt atusRead Synopsis <Read transmit status> Boolean __BasicSe ndingS t a tus R ea d(uns igne d lon g data) data Setup data Description Returns the transmit status of serial comm unication. For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAP[...]

  • Page 34

    Rev .1.01 2007.02.16 RJJ10J1643-0101 34 __BasicStopSerialReceiving Synopsis <S top reception> Boolean Rapi_B asicStopSerialReceiv ing(unsigned long dat a) data Setup data Description S tops receiving data in serial communication [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 (R8C) RAPI[...]

  • Page 35

    Rev .1.01 2007.02.16 RJJ10J1643-0101 35 __BasicStopSerialSending Synopsis <S top transmission> Boolean __Bas icStopSerialSending( unsigned long dat a) data Setup data Description S tops transmitting data in serial communication. [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 (R8C) RAPI[...]

  • Page 36

    Rev .1.01 2007.02.16 RJJ10J1643-0101 36 __OpenSerialDriver Synopsis <Open a serial port> Boolean __OpenSeria lDri ver(unsigned lon g data) data Setup data Description Opens and initializes a specifi ed serial port. [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM[...]

  • Page 37

    Rev .1.01 2007.02.16 RJJ10J1643-0101 37 __CloseSerialDriver Synopsis <Close a serial port> Boolean __Clos eSerialDriver(unsigned long dat a) data Setup data Description Closes a specified serial port. [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI_COM4 SI/O3 RAPI_COM5 SI/O4 (R8C) [...]

  • Page 38

    Rev .1.01 2007.02.16 RJJ10J1643-0101 38 __ConfigSerialDriverNotify Synopsis <Register a notifi cation function> Boolean __ConfigSerialDriv erNotify(unsigned long dat a, V oidFuncNotify *func) data Setup data func Function pointer to be registered Description Regist ers the notification f unction necessar y to get various transmit/receive info[...]

  • Page 39

    Rev .1.01 2007.02.16 RJJ10J1643-0101 39 (R8C) (H8/300H) 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 • The specifiable serial ports differ with each CPU used. • If an undefined val[...]

  • Page 40

    Rev .1.01 2007.02.16 RJJ10J1643-0101 40 Program example #include ”rapi_sif_r8c_13.h” void Notify(unsigned char result) { if ((result&RAPI_OVER_ERR) == RAPI_OVER_ERR) { /* Overrun error */ } if ((result&RAPI_FRAMING_ERR) == RAPI_FRAMING_ERR) { /* Framing error */ } if ((result&RAPI_PARITY_ERR) == RAPI_PARITY_ERR) { /* Parity error */[...]

  • Page 41

    Rev .1.01 2007.02.16 RJJ10J1643-0101 41 __SetSerialFormat Synopsis <Set serial communication> Boolean __SetSeria lFormat(unsigned long dat a1, unsigned char data2) data1 Setup data 1 data2 Setup data 2 Description Sets serial communication according to spec ified parameters. For details about pa rameters, refer to the description of __BasicSe[...]

  • Page 42

    Rev .1.01 2007.02.16 RJJ10J1643-0101 42 __SetSerialInterrupt Synopsis < Set serial interrupts> 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. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 RAPI[...]

  • Page 43

    Rev .1.01 2007.02.16 RJJ10J1643-0101 43 RAPI_COM1 UART0 RAPI_COM2 UART1 For interrupt settings, the following values can set. RAPI_INT_TX_DIS T ransmit interrupt disabled RAPI_INT_TX_L V_1 T ransmit interrup t priority level 1 RAPI_INT_TX_L V_2 T ransmit interrupt priority level 2 RAPI_INT_TX_L V_3 T ransmit interrup t priority level 3 RAPI_INT_TX_[...]

  • Page 44

    Rev .1.01 2007.02.16 RJJ10J1643-0101 44 Boolean func( void ) { ……………… /* Set interrupt of RAPI_COM1 to serial driver */ return __SetSerialInterrupt( RAPI_COM1 | RAPI_INT_TX_LV_1 | RAPI_INT_RX_LV_2 ); ……………… }[...]

  • Page 45

    Rev .1.01 2007.02.16 RJJ10J1643-0101 45 __St artSerialReceiving Synopsis <S tart reception> Boolean __S tartSerialReceiv ing(unsigned long dat a, unsigned char w ordNum, unsigned int *Rcv DtBuf) data Setup data wordNum Number of words received RcvDtBuf Pointer to the buf fer in which received data is stored Description S tarts reception of se[...]

  • Page 46

    Rev .1.01 2007.02.16 RJJ10J1643-0101 46 unsigned int buffer[10]; void func( void ) { ……………… /* Get 5 word data received in serial communication */ __StartSerialReceiving( RAPI_COM1, 5, buffer ); ……………… }[...]

  • Page 47

    Rev .1.01 2007.02.16 RJJ10J1643-0101 47 __St artSerialSending Synopsis <S tart transmission> Boolean __S tartSerialSending(uns igned long data , unsigned char wordNum, unsigned int *SndDtBuf) data Setup data wordNum Number of words transmitted SndDtBuf Pointer to the t ransmit data Description S tarts transmission of serial communication and [...]

  • Page 48

    Rev .1.01 2007.02.16 RJJ10J1643-0101 48 unsigned int buffer[10]; void func( void ) { ……………… /* Set 5 word data to transmit buffer of serial communication */ __StartSerialSending( RAPI_COM1, 5, buffer ); ……………… }[...]

  • Page 49

    Rev .1.01 2007.02.16 RJJ10J1643-0101 49 __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. (M16C) RAPI_COM1 UART0 RAPI_COM2 UAR T1 RAPI_COM3 UART2 (R8C) RAPI_COM1 UART0 RAPI[...]

  • Page 50

    Rev .1.01 2007.02.16 RJJ10J1643-0101 50 __StopSerialSending Synopsis <S top transmission> Boolean __S topSerialSending(unsigne d long data ) data Setup data Description S tops transmission of serial communicatio n. [data] For data, the following values can be set. (M16C) RAPI_COM1 UART0 RAPI_COM2 UART1 RAPI_COM3 UART2 (R8C) RAPI_COM1 UART0 RA[...]

  • Page 51

    Rev .1.01 2007.02.16 RJJ10J1643-0101 51 __PollingSerialReceiving Synopsis <Polling reception> unsigned int __PollingSerialRec eiving(unsigned l ong data) data Setup data Description Performs reception of serial communicatio n by polling. T his API gets received data by an amount specified by __St artSerialR eceivi ng. When ac quisition of rec[...]

  • Page 52

    Rev .1.01 2007.02.16 RJJ10J1643-0101 52 __PollingSerialSending Synopsis <Polling transmission> Unsigned __Polli ngSerialSending(unsigned long da ta) 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 53

    Rev .1.01 2007.02.16 RJJ10J1643-0101 53 unsigned int buffer[10],count; void func( void ) { ……………… /* Transmission interrupt disable */ __SetSerialInterrupt( RAPI_COM1 | RAPI_INT_TX_DIS | RAPI_INT_RX_DIS ); /* Start transmission */ __StartSerialSending( RAPI_COM1, 5, buffer ); do{ count = __PollingSerialSending( RAPI_COM1 ); }while(count[...]

  • Page 54

    Rev .1.01 2007.02.16 RJJ10J1643-0101 54 4.2.2 Timer __CreateTimer Synopsis <Set timer mode> Boolean __Cre ateTimer(unsigned l ong data1, uns igned int data2 , unsigned int dat a3, unsigned int dat a4, void* func) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) data3 Setup data 3 (content d[...]

  • Page 55

    Rev .1.01 2007.02.16 RJJ10J1643-0101 55 (Operating states set) Specify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default value is RAPI_TIMER_OFF . (Pulse output state) Specify one from { RAPI_PULSE_ON, RAPI_PULSE_OFF }. The default value is RAPI_PULSE_OFF . (Gate facility) S pecify one from { RAPI _GA TE_L, RAPI_GA TE_H }. If omitted, “No g[...]

  • Page 56

    Rev .1.01 2007.02.16 RJJ10J1643-0101 56 (Count source) S pecify one from { RAPI_F1, RAPI_F8, RAPI_F RING }. The default value is RAPI_F1. (Operating states set) S pecify one fro m { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default value is RAPI_TIMER_OFF . (Write control) S pecify one from { RAPI_WRI TE_RELOAD_ONL Y , RAPI_WRITE_RELOAD_BOTH }. The defa[...]

  • Page 57

    Rev .1.01 2007.02.16 RJJ10J1643-0101 57 RAPI_TB1_F256 T imer B1 counts with internal clock φ /256. RAPI_TB1_F512 T imer B1 counts with internal clock φ /512. RAPI_TB1_F2048 T imer B1 counts with internal clock φ /2048. RAPI_TB1_F8192 T imer B1 counts with internal clock φ /8192. RAPI_TV_F4 T imer V counts on falling edges of internal clock φ /[...]

  • Page 58

    Rev .1.01 2007.02.16 RJJ10J1643-0101 58 (Interrupt) If overflow interrupt requests are enabled, specify RAPI_OVERFLOW . If no interrupts are specified, “No interrupt request” is set. (Operating states set) S pecify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default value is RAPI_TIMER_OFF . [data2] (M16C) (R8C) S pecify the interrupt prior[...]

  • Page 59

    Rev .1.01 2007.02.16 RJJ10J1643-0101 59 void func( void ) { /* Set up timer X as timer mode */ __CreateTimer( RAPI_TIMER_X|RAPI_TIMER_ON|RAPI_F8, 5, 0x80, 0x80, TimerIntFunc ); }[...]

  • Page 60

    Rev .1.01 2007.02.16 RJJ10J1643-0101 60 __EnableTimer Synopsis <Control o peration of timer mode> Boolean __EnableT imer(unsigned long dat a) data Setup data (content differs w i th MCU type) Description Controls operation of the tim er that is se t to specified timer mod e by starting or stopping it. [data] For data, the following definition[...]

  • Page 61

    Rev .1.01 2007.02.16 RJJ10J1643-0101 61 Remark • If an undefined value is specif ied in t he arg ument, operation of the API cannot be guaranteed. • The specifiable timers differ with each CPU used. Program example #include "rapi_timer_r8c_13.h" void func( void ) { /* Disable timer Y as timer mode */ __EnableTimer( RAPI_TIMER_Y| RAPI_[...]

  • Page 62

    Rev .1.01 2007.02.16 RJJ10J1643-0101 62 __DestroyTimer Synopsis <Discard settings of timer mode> Boolean __DestroyT imer(unsigned long dat a) data Setup data (content differs with MCU type) Description Discards s ettings of the timer that is set to specified timer mode. [data] For data, the following definition values can be set. (M16C) RAPI_[...]

  • Page 63

    Rev .1.01 2007.02.16 RJJ10J1643-0101 63 void func( void ) { /* Destroy the setting of timer Z as timer mode */ __DestroyTimer( RAPI_TIMER_Z ); }[...]

  • Page 64

    Rev .1.01 2007.02.16 RJJ10J1643-0101 64 __CreateEventCounter Synopsis <Set event counter mode> Boolean __Cre ateE ventCounter(unsigne d long dat a1, unsigned int dat a2, unsigned int data3, unsign ed int data4 , void* func) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) data3 Setup data 3[...]

  • Page 65

    Rev .1.01 2007.02.16 RJJ10J1643-0101 65 RAPI_UDF_REGISTER Selects the UDF register for the cause of up/down switching. RAPI_T AIOUT Selects the input signal at T A iOUT pin for the cause of up/down switching. RAPI_RISING Select s the rising edge of count source as active edge. RAPI_F ALLING Selects the falling edge of count source as active edge. R[...]

  • Page 66

    Rev .1.01 2007.02.16 RJJ10J1643-0101 66 RAPI_WRITE_ RELOAD_ BOTH 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 . RAPI_RISING Select s the rising edge of count source as active edge. RAPI_F ALLING Selects the falling edge of c[...]

  • Page 67

    Rev .1.01 2007.02.16 RJJ10J1643-0101 67 RAPI_RISING Select s the rising edge of count source as active edge. RAPI_F ALLING Selects the falling edge of count source as active edge. RAPI_BOTH Selects both rising and falling edges of count source as active edges. RAPI_TRGV_RISING Selects the rising edge of TR GV pin input signal as active edge. RAPI_ [...]

  • Page 68

    Rev .1.01 2007.02.16 RJJ10J1643-0101 68 [data4] (M16C) (H8/300H) Specify 0. (R8C) Specify the set value for the prescaler register in 8 bits. Return value If the timer specification is incorrect, R API_F ALSE is returned; other wise, RAPI_TRUE is returned. Functionality T imer (event counter mode) Reference __EnableEventCounter , __DestroyEventCoun[...]

  • Page 69

    Rev .1.01 2007.02.16 RJJ10J1643-0101 69 __EnableEventCounter Synopsis <Control operation of event counter mode> Boolean __Enable E ventCounter(uns igned long data ) data Setup data (content differs with MCU type) Description Controls operation of the timer that is set to specified timer mode b y starting or stopping it. [data] For data, the f[...]

  • Page 70

    Rev .1.01 2007.02.16 RJJ10J1643-0101 70 Functionality Ti mer (event counter mo de) Reference __CreateEvent Counter , __DestroyEventCoun ter , __GetEventCounter Remark • If an undefined value is specified in th e argument, oper ation of the API cannot be guaranteed. • The specifiable timers differ with each CPU used. Program example #include &qu[...]

  • Page 71

    Rev .1.01 2007.02.16 RJJ10J1643-0101 71 __DestroyEventCounter Synopsis <Discard settings of event counter mode> Boolean __Des tro yEventCounter(uns igned long dat a) data Setup data (content differs with MCU type) Description Discards settings of the timer that is set to specified timer mode. [data] For data, the following definition values c[...]

  • Page 72

    Rev .1.01 2007.02.16 RJJ10J1643-0101 72 void func( void ) { /* Destroy the setting of timer Y as event counter mode */ __DestroyEventCounter( RAPI_TIMER_Y ); }[...]

  • Page 73

    Rev .1.01 2007.02.16 RJJ10J1643-0101 73 __GetEventCounter Synopsis <Get event counter mode counter value> Boolean __GetEv entCounter(unsigned long da ta1, unsi gned int *data 2) data1 Setup data 1 (content differs with MCU type) data2 Pointer to the buffer in which counter value is stored Description Gets the counter value of the timer that i[...]

  • Page 74

    Rev .1.01 2007.02.16 RJJ10J1643-0101 74 [1]: The value of timer RA register is stored. (H8/300H) • When using timer B1 (RAPI_ TIMER_B1 specified) [0]: The value of timer counter B1 is stored. • When using timer V (RAPI_T IMER_V specified) [0]: The value of timer counter V is stored. Return value If the timer specification is incorrect, R API_F [...]

  • Page 75

    Rev .1.01 2007.02.16 RJJ10J1643-0101 75 __CreatePulseWid thMo dulationMode Synopsis <Set pulse width modulation mode> Boolean __Creat ePulseW id thMod ulationM ode(unsigne d long da t a 1, unsigned int dat a2, unsigned int* dat a3, void* dat a4) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU ty[...]

  • Page 76

    Rev .1.01 2007.02.16 RJJ10J1643-0101 76 RAPI_RISING Selects the rising edge of T A iIN pin input signal as active edge. RAPI_F ALLING Selects 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) Specify one fro m { RAPI_F1, RAPI[...]

  • Page 77

    Rev .1.01 2007.02.16 RJJ10J1643-0101 77 (Count source) S pecify one from { RAPI_F 1, RAPI_F2, RAPI_F8, RAPI_TIMER_Y_UNDERFLOW}. The default value is RAPI_F1. (Operating states set) S pecify one fro m { RAPI_TIMER_ON, RAPI_ TIMER_OFF }. The default value is RAPI_TIMER_OFF . (Output) Specify one from { RAPI_H_L_L, RAPI_L_H_H }. The default value is R[...]

  • Page 78

    Rev .1.01 2007.02.16 RJJ10J1643-0101 78 • Specifiable definition values when timer V is u sed (RAPI_TIMER_V specified ) (Clock) S pecify one from { RAPI_TV_F4, RAPI_TV_F8, RAPI_TV_F16, RAPI_TV_F32, RAPI_TV_F64, RAPI_TV_F1 28 }. If clock specification is omitted, s pecify “Disable clock input.” (Interrupt) If compare match A interrupt requests[...]

  • Page 79

    Rev .1.01 2007.02.16 RJJ10J1643-0101 79 Reference __EnablePulseWidthModulationMode , __De stroyPulseWidthModulationMode Remark • If an undefined value is specified in the fi rst a rgument, operation of the API cannot be guaranteed. • The specifiable timers differ with each CPU used. • For the H8/300H, make sure that comparison value A < co[...]

  • Page 80

    Rev .1.01 2007.02.16 RJJ10J1643-0101 80 __EnablePulseWid thModulationMode Synopsis <Control operation of puls e width modulation mode> Boolean __Enable PulseWidt hModulationMode(unsigned lon g data) data Setup data (content differs with MCU type) Description Controls operation of the time r that is se t to specified pulse width modulation mod[...]

  • Page 81

    Rev .1.01 2007.02.16 RJJ10J1643-0101 81 Remark • If an undefined value is specif ied in the argument, operati on of the API cannot be guaranteed. • The specifiable timers differ with each CPU used. Program example #include "rapi_timer_r8c_13.h" void func( void ) { /* Enable timer Y as pulse width modulation mode */ __EnablePulseWidthM[...]

  • Page 82

    Rev .1.01 2007.02.16 RJJ10J1643-0101 82 __DestroyPulseWid thModulationMode Synopsis <Discard settings of pulse width modulation mode> Boolean __Des tro yPulseWid thModulationMode(u nsigned long dat a) data Setup data (content differs with MCU type) Description Discards settings of the timer that is set to specified pulse width modulation mode[...]

  • Page 83

    Rev .1.01 2007.02.16 RJJ10J1643-0101 83 __CreatePulsePeriodMeasurementMode Synopsis <Set pulse period meas urement mode> Boolean __CreatePul sePeriodM easu rementMode(unsign ed long data1, unsigned int dat a2, unsigned int dat a3, unsigned int data4, v oid* func) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content d[...]

  • Page 84

    Rev .1.01 2007.02.16 RJJ10J1643-0101 84 RAPI_TIMER_RA Uses timer RA. RAPI_F1 Selects f 1 for the count source. RAPI_F2 Selects f 2 for the count source. RAPI_F8 Selects f 8 for the count source. RAPI_F32 Selects f 32 for the count source. RAPI_FC32 Selects f C32 for the count source. RAPI_FOCO Selects fOCO for the count source. RAPI_TIMER_ON Sets t[...]

  • Page 85

    Rev .1.01 2007.02.16 RJJ10J1643-0101 85 RAPI_TIMER_RD3 Uses timer RD0 channel 3. RAPI_TW_F1 T imer W counts with internal clock φ . RAPI_TW_F2 T imer W counts with internal clock φ /2. RAPI_TW_F4 T imer W counts with internal clock φ /4. RAPI_TW_F8 T imer W counts with internal clock φ /8. RAPI_TZ_F1 T i mer Z counts with internal clock φ . RA[...]

  • Page 86

    Rev .1.01 2007.02.16 RJJ10J1643-0101 86 RAPI_FTIOB Use FTIOB pin as input pin. • Specifiable definition values when timer W is used (RAPI_TIMER_W specified ) (Count source) Specify one from { RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4, RAPI_TW_F8 }. The default value is RAPI_TW_F1. (Operating states set) S pecify one from { RAPI_TIMER_ ON, RAPI_TIMER_OFF[...]

  • Page 87

    Rev .1.01 2007.02.16 RJJ10J1643-0101 87 (Interrupt) If overflow interrupt requests are enabled, specify RAPI_OVERFLOW . If no interrupts are specified, “No interrupt request” is set. (Input pin) S pecify one from { RAPI_ FTIOA, RAPI_FTIOB }. The default value is RAPI_FTIOA. (Clock for digital filter) S pecify one from { RAPI_T RC_FIL TER_F1, RA[...]

  • Page 88

    Rev .1.01 2007.02.16 RJJ10J1643-0101 88 __EnablePulsePeriodMeasurementMode Synopsis <Control operation of pulse pe riod measurement mode> Boolean __EnablePu lsePeriodMeasu rem entMode(unsigned long data) data Setup data (content differs with MCU type) Description Controls operation of the timer that is set to specified pulse period measur eme[...]

  • Page 89

    Rev .1.01 2007.02.16 RJJ10J1643-0101 89 RAPI_TIMER_ OFF Sets the timer that is set to pulse period measurement mode to stop operating. Return value If the timer specification is incorrect, R API_F ALSE is returned; otherwise, RAPI_TRUE is returned. Functionality T imer (pulse p eriod measurement mode) Reference __CreatePulsePeriodMeas urementMode ,[...]

  • Page 90

    Rev .1.01 2007.02.16 RJJ10J1643-0101 90 __DestroyPulsePeriodMeasurementMode Synopsis <Discard settings of pulse period meas urement mode> Boolean __Destro yPulsePeriodMeasurem en tMo de(unsigned lon g dat a) data Setup data (content differs with MCU type) Description Discards settings of the timer that is set to specified pulse period measure[...]

  • Page 91

    Rev .1.01 2007.02.16 RJJ10J1643-0101 91 • When used for the H8/300H, this API plac es a specified ti mer into module stanby state after discarding it. Program example #include "rapi_timer_r8c_13.h" void func( void ) { /* Destro y the setting of timer X as pulse period measurement mode */ __DestroyPulsePeriodMeasurementMode( RAPI_TIMER_X[...]

  • Page 92

    Rev .1.01 2007.02.16 RJJ10J1643-0101 92 __GetPulsePeriodMeasurementMode Synopsis <Get measured value in pulse peri od measurement mode> Boolean __GetPulsePeriod MeasurementM o de(unsigned lo ng data1, unsigned int *data2) data1 Setup data 1 (content differs with MCU type) data2 Pointer to the buffer in which counter value is stored Descriptio[...]

  • Page 93

    Rev .1.01 2007.02.16 RJJ10J1643-0101 93 [0]: The value of timer RA prescaler register i s stored. [1]: The value of timer RA register is stored. (H8/300H) • When using timer W (RAPI_TIMER_W specified) [0]: (The value of gener al register A) – (The value of gen eral register C) is stored. [1]: (The value of gener al register B) – (The value of[...]

  • Page 94

    Rev .1.01 2007.02.16 RJJ10J1643-0101 94 __CreatePulseWid thMeasurementMode Synopsis <Set pulse width measurement mode> Boolean __CreatePul seWidthMeasurementMode(unsigned lo ng data1, unsigned int dat a2, unsigned int dat a3, unsigned int data4, v oid* func) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differ[...]

  • Page 95

    Rev .1.01 2007.02.16 RJJ10J1643-0101 95 RAPI_FOCO Selects fO CO for the count source . RAPI_TIMER_ON Sets the timer to st art operating in __C reatePulsePeriodMeasureme ntMode. RAPI_TIMER _OFF Sets the timer t o stop operating in __Cre atePulsePeriodMeasurementM ode. RAPI_RISING_ RISING Selects measurement of an interval from the rise to the next r[...]

  • Page 96

    Rev .1.01 2007.02.16 RJJ10J1643-0101 96 RAPI_TW_F8 Timer W count s with internal clock φ /8. RAPI_TZ_F1 Timer Z counts with internal clock φ . RAPI_TZ_F2 Timer Z counts with internal clock φ /2. RAPI_TZ_F4 Timer Z counts with internal clock φ /4. RAPI_TZ_F8 Timer Z counts with internal clock φ /8. RAPI_TRC_F1 T i mer RC counts with internal cl[...]

  • Page 97

    Rev .1.01 2007.02.16 RJJ10J1643-0101 97 (Count source) S pecify one from { RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4, RAPI_TW_F8 }. The default value is RAPI_TW_F1. (Operating states set) S pecify one from { RAPI_TIMER_ON, RAPI_TIMER_OFF }. The default value is RAPI_TIMER_OFF . (Interrupt) If overflow interrupt requests are enabled, specify RAPI_OVERFLOW [...]

  • Page 98

    Rev .1.01 2007.02.16 RJJ10J1643-0101 98 S pecify the interrupt priority le vel (0 – 7) to be set in the interrupt control register . (H8/300H) Specify the interrupt priority level (0–1) to be set in the interrupt control register. F or the CPUs that do not have an inte rrupt control register, specify 0. [data3] (M16C)(H8/300H) S pecify 0. (R8C)[...]

  • Page 99

    Rev .1.01 2007.02.16 RJJ10J1643-0101 99 __EnablePulseWid thMeasurementMode Synopsis <Control operation of pulse width measurement mode> Boolean __Enab l ePu lseWidthMeasurementMode(un signed long data) data Setup data (content differs with MCU type) Description Controls operation of the timer that is se t to specified pulse width measurement [...]

  • Page 100

    Rev .1.01 2007.02.16 RJJ10J1643-0101 100 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 __CreatePulseWidthMeasure mentMode , __DestroyPulseW idthMeasurementMode , __GetPulseWidthMeasurementMode Remark • If an undefined [...]

  • Page 101

    Rev .1.01 2007.02.16 RJJ10J1643-0101 101 __DestroyPulseWid thMeasurementMode Synopsis <Discard settings of pulse width measurement mode> Boolean __Destro yPulseWidthMeasurementMode(un sign ed long data) data Setup data (content differs with MCU type) Description Discards settings of the timer that is set to specified pulse width measurement m[...]

  • Page 102

    Rev .1.01 2007.02.16 RJJ10J1643-0101 102 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 ); }[...]

  • Page 103

    Rev .1.01 2007.02.16 RJJ10J1643-0101 103 __GetPulseWid thMeasurementMode Synopsis <Get measured value in puls e width measurement mode> Boolean __GetPulseWidthMeasurementMode(u nsign ed long d ata1, unsigned int *data2) data1 Setup data 1 (content differs with MCU type) data2 Pointer to the buffer in which counter value is stored Description [...]

  • Page 104

    Rev .1.01 2007.02.16 RJJ10J1643-0101 104 [0]: The value of timer RA prescaler register i s stored. [1]: The value of timer RA register is stored. (H8/300H) • When using timer W (RAPI_TIMER_W specified) [0]: (The value of gener al register A) – (The value of gen eral register C) is stored. [1]: (The value of gener al register B) – (The value o[...]

  • Page 105

    Rev .1.01 2007.02.16 RJJ10J1643-0101 105 __CreateInputCapture Synopsis <Set input capture mode> Boolean __Cre ateInputCapture(unsigned long dat a1, unsigne d int* data2, unsigned int* da ta3, unsigne d int* data4, v oid** data5) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) data3 Setup d[...]

  • Page 106

    Rev .1.01 2007.02.16 RJJ10J1643-0101 106 RAPI_F ALLING Selects the falling edge of measurement pulse as active edge. RAPI_BOTH Select s both rising and falling edges of measurement pulse as active edge. RAPI_FIL TER_F1 Uses the digital filter facility that has a sampling frequency f 1 . RAPI_FIL TER_F8 Uses the digital filter facility that has a sa[...]

  • Page 107

    Rev .1.01 2007.02.16 RJJ10J1643-0101 107 (Inter rupt) If overflo w interrupt reques ts are enabled, specify RAPI_OVERFLOW. If input capture A, input capture B, input capture C, or input capture D interrupt requests are enabled, specify RAPI_INPUT_CAPURE_A, RAPI_INPUT_CAPURE_B, RAPI_INPUT_CAPURE _C, or RAPI_INPUT_CAPURE_D, respectively . When not sp[...]

  • Page 108

    Rev .1.01 2007.02.16 RJJ10J1643-0101 108 RAPI_TRD_F4 T i mer RD counts with internal clock φ /4. RAPI_TRD_F8 T i mer RD counts with internal clock φ /8. RAPI_TRD_F32 T imer RD counts with internal clock φ /32. RAPI_TRD_F40M T imer RD counts with internal clock φ 40M. RAPI_TIMER_ON Sets the timer to st art operating in __CreateInputCapture. RAPI[...]

  • Page 109

    Rev .1.01 2007.02.16 RJJ10J1643-0101 109 (Counter clear) T o 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_CLEA R_C, or RAPI_COUNT_CLEAR_D, respectively . If cleared at the same time a synchronously operating counter on anot her channel is cleare[...]

  • Page 110

    Rev .1.01 2007.02.16 RJJ10J1643-0101 110 (Operating states set) S pecify one from [RAPI_TIME R_ON, RAPI_TIMER_OFF]. The default is RAPI_TIMER_OFF . (Interrupt) If overflow interrupt r equests are enabled, specify RAPI_OVERFLOW. If input capture A, input capture B, i nput capture C, or input capture D interrupt requests are enabled, specify RAPI_INP[...]

  • Page 111

    Rev .1.01 2007.02.16 RJJ10J1643-0101 111 [2]: S pecify the set value for time measurement control re gister 2. [3]: S pecify the set value for time measurement control re gister 3. [4]: S pecify the set value for time measurement control re gister 4. [5]: S pecify the set value for time measurement control re gister 5. [6]: S pecify the set value f[...]

  • Page 112

    Rev .1.01 2007.02.16 RJJ10J1643-0101 112 RAPI_TRD_RISING Selects the rising edge of measurement pulse as active edge. RAPI_TRD_F ALLING Selects the falling edge of measurement pulse as active edge. RAPI_TRD_BOTH Selects both ris ing and falling edges of measurement pulse as active edge. RAPI_FIL TER_ON Selects digital filter on. If not select “RA[...]

  • Page 113

    Rev .1.01 2007.02.16 RJJ10J1643-0101 113 RAPI_CHANNEL1 Selects channel 1. RAPI_CHANNEL2 Selects channel 2. RAPI_CHANNEL3 Selects channel 3. RAPI_CHANNEL4 Selects channel 4. RAPI_CHANNEL5 Selects channel 5. RAPI_CHANNEL6 Selects channel 6. RAPI_CHANNEL7 Selects channel 7. (R8C) (H8/300H) S pecify 0. [data5] (M16C) S pecify a point er to the array in[...]

  • Page 114

    Rev .1.01 2007.02.16 RJJ10J1643-0101 114 void func( void ) { /* Set up timer C as imput capture mode */ __CreateInputCapture( RAPI_TIMER_C|RAPI_TIMER_ON|RAPI_BOTH|RAPI_F32| RAPI_FRING128, 5, TimerIntFunc); }[...]

  • Page 115

    Rev .1.01 2007.02.16 RJJ10J1643-0101 115 __EnableInputCapture Synopsis <Control operation of input capture mod e> Boolean __Enable InputCapture(unsigned long dat a) data Setup data (content differs with MCU type) Description Controls operation of the time r that is set to specified input capture mod e by starting or stopping it. [data] For da[...]

  • Page 116

    Rev .1.01 2007.02.16 RJJ10J1643-0101 116 • 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 ); }[...]

  • Page 117

    Rev .1.01 2007.02.16 RJJ10J1643-0101 117 __DestroyInputCapture Synopsis <Discard settings of input capture mode> Boolean __DestroyInputCa pture(unsigned long dat a) data Setup data (content differs with MCU type) Description Discards settings of the timer that is set to specified input capture mode. [data] For data, the following definition v[...]

  • Page 118

    Rev .1.01 2007.02.16 RJJ10J1643-0101 118 void func( void ) { /* Destroy the setting of timer C as input capture mode */ __DestroyInputCapture( RAPI_TIMER_C ); }[...]

  • Page 119

    Rev .1.01 2007.02.16 RJJ10J1643-0101 119 __GetInputCapture Synopsis <Get input capture mode counter value> Boolean __GetInputCa p ture(unsigned long dat a1, unsigned int *dat a2) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) Description Gets the counter value of the timer that is set to [...]

  • Page 120

    Rev .1.01 2007.02.16 RJJ10J1643-0101 120 • When timer RD is used (R API_TIMER_RD0- RAPI_TIMER_ RD1 specified) [0]: S tores the value of timer counter . [1]: S tores the value of general register A. [2]: S tores the value of general register B. [3]: S tores the value of general register C. [4]: S tores the value of general register D. (H8/300H) [0[...]

  • Page 121

    Rev .1.01 2007.02.16 RJJ10J1643-0101 121 __CreateOutputCompare Synopsis <Set output compare mode> Boolean __Cre ateOutputCompare(uns igned long data 1, unsigned int* dat a2, unsigned int* dat a3, unsigned int* dat a4, void** dat a5) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) data3 Set[...]

  • Page 122

    Rev .1.01 2007.02.16 RJJ10J1643-0101 122 RAPI_TRD_F32 Selects f 32 for the timer RD count source. RAPI_TRD_F40M Selects fOCO40M for the timer RD count source. RAPI_TRE_F4 Selects f 4 for the timer RE count source. RAPI_TRE_F8 Selects f 8 for the timer RE count source. RAPI_TRE_F32 Selects f 32 for the timer RE count source. RAPI_TRE_FC4 Selects fC4[...]

  • Page 123

    Rev .1.01 2007.02.16 RJJ10J1643-0101 123 RAPI_UNCHANGE_0 Leaves CMP0 output unchanged even when matched in compare 0. RAPI_REVERSE_0 Inverts CMP0 output upon compare 0 match signal. RAPI_L_0 Forces CMP0 output low upon compare 0 match signal. RAPI_H_0 Forces CMP0 output high upon compare 0 match signal. RAPI_UNCHANGE_1 Leaves CMP1 output unchanged [...]

  • Page 124

    Rev .1.01 2007.02.16 RJJ10J1643-0101 124 (TC reload) T o reload TC register , specify RAPID_RELOAD. If RAPID_RELOAD is not specified, “No reload” is set. (CMP0 output mode) S pecify one from { RAPI_UNCHA NGE_0, RAPI_REVERSE_0, RAPI_L_0, RAPI_H_0 }. The default value is RAPI_UNCHANGE_0. (CMP1 output mode) S pecify one from { RAPI_UNCHA NGE_1, RA[...]

  • Page 125

    Rev .1.01 2007.02.16 RJJ10J1643-0101 125 RAPI_TIMER_W Uses timer W. RAPI_TIMER_Z0 Uses timer Z channel 0. RAPI_TIMER_Z1 Uses timer Z channel 1. RAPI_TIMER_RC Uses timer RC. RAPI_TIMER_RD0 Uses timer RD0 channel 0. RAPI_TIMER_RD1 Uses timer RD0 channel 1. RAPI_TIMER_RD2 Uses timer RD0 channel 2. RAPI_TIMER_RD3 Uses timer RD0 channel 3. RAPI_TW_F1 T [...]

  • Page 126

    Rev .1.01 2007.02.16 RJJ10J1643-0101 126 RAPI_COUNT_CLEAR_S YNC Clear counter in sync with the synchronized other timer counter RAPI_TIMER_SYNC S ynchronizes timer on channels 0 and 1. • Specifiable definition values when timer W is used (RAPI_TIMER_W specified ) (Count source) S pecify one from { RAPI_TW_F1, RAPI_TW_F2, RAPI_TW_F4, RAPI_TW_F8 }.[...]

  • Page 127

    Rev .1.01 2007.02.16 RJJ10J1643-0101 127 (Interrupt) If overflow interrupt reques ts are enabled, specify RAPI_OVERFLOW. If compare match A, comp are match B, compare match C, or compare match D interrupt requests are enabled, specify RAPI_COMP A RE_MA TCH_A, RAPI_COMP ARE_MA TCH_B, RAPI_COMP A RE_MA TCH_C, or RAPI_COMP ARE_M A TCH_D, respectively [...]

  • Page 128

    Rev .1.01 2007.02.16 RJJ10J1643-0101 128 (M16C) S pecif y a pointer to the array in which the set value for the waveform generation control register or waveform g eneration r egister is stored. [0]: S pecify the set value for waveform generation control re gister 0. [1]: S pecify the set value for waveform generation control re gister 1. [2]: S pec[...]

  • Page 129

    Rev .1.01 2007.02.16 RJJ10J1643-0101 129 (Output mode) S pecify one from { RAPI_SINGLE, RAPI_SR, RAPI_PHASE_DELA YED }. The default value is RAPI_SINGLE. (Initial output value) S pecify one from { RAPI_OUT_ INIT_0, RAPI_OUT_INIT_1 }. Th e default value is RAPI_OUT_INIT_0. (Output inversion) T o invert the output, specify RAPI_OUTPUT_REVERSED. If ou[...]

  • Page 130

    Rev .1.01 2007.02.16 RJJ10J1643-0101 130 [6]: S pecify the comparison value of general register C i n 16 bits. [7]: S pecify the comparison value of general register D i n 16 bits. To specify output operation for each output compare of array elements, the following definition values can be used. To specify multiple definition values at the same tim[...]

  • Page 131

    Rev .1.01 2007.02.16 RJJ10J1643-0101 131 [1]: S pecify a pointer to the callba ck function for IC/OC interrupt 0. If this pointer is not specified, 0 is set. [2]: S pecify a pointer to the callba ck function for IC/OC interrupt 1. If this pointer is not specified, 0 is set. (R8C) • When timer C is used (R API_TIMER_C specified) S pecify a point e[...]

  • Page 132

    Rev .1.01 2007.02.16 RJJ10J1643-0101 132 #include "rapi_timer_r8c_13.h" void TimerIntFunc0( void ){} void TimerIntFunc1( void ){} void TimerIntFunc2( void ){} void func( void ) { unsigned int *p_func[] = {(void*) TimerIntFunc0,(void*) TimerIntFunc1, (void*) TimerIntFunc2}; unsigned char p_ic[] = {1,2,3}; unsigned int p_cmp[] = {0x1234, 0x[...]

  • Page 133

    Rev .1.01 2007.02.16 RJJ10J1643-0101 133 __EnableOutputComp are Synopsis <Control operation of output compare mode> Boolean __EnableOutputCo mpare(unsigned long da ta) data Setup data (content differs with MCU type) Description Controls operation of the timer that is set to specifi ed output compare mode by starting or stopping it. [data] For[...]

  • Page 134

    Rev .1.01 2007.02.16 RJJ10J1643-0101 134 guaranteed. • The specifiable timers differ with each CPU used. Program example #include "rapi_timer_r8c_13.h" void func( void ) { /* Enable timer C as output compare mode */ __EnableOutputCompare( RAPI_TIMER_C|RAPI_TIMER_ON ); }[...]

  • Page 135

    Rev .1.01 2007.02.16 RJJ10J1643-0101 135 __DestroyOutputCompare Synopsis <Discard settings of output compare mode> Boolean __DestroyOutputComp are(unsigned long data) data Setup data (content differs with MCU type) Description Discards settings of the timer that is set to specified output compare mode. [data] For data, the following definitio[...]

  • Page 136

    Rev .1.01 2007.02.16 RJJ10J1643-0101 136 void func( void ) { /* Destroy the setting of timer C as output compare mode */ __DestroyOutputCompare( RAPI_TIMER_C ); }[...]

  • Page 137

    Rev .1.01 2007.02.16 RJJ10J1643-0101 137 __SetTimerRegister Synopsis <Set timer register> Boolean __SetT imerRegister(unsigned long dat a1, unsigned int *dat a2) data1 Setup dat a 1 (content differs with MCU type) data2 Pointer to the buf fer in which register value is stored Description Sets the registers of a specified timer . [data1] For d[...]

  • Page 138

    Rev .1.01 2007.02.16 RJJ10J1643-0101 138 [data2] The content of a pointer to the buffer in which the register value is stored must be specifie d as described below . The value is set in each r egister in order of buffer pointer element s. (M16C) • When using timer A (RAPI_TIMER_A0 to RAPI_TIMER_A 4 specified) [0]: S pecify the set value for t he [...]

  • Page 139

    Rev .1.01 2007.02.16 RJJ10J1643-0101 139 [27]: S pecify the set value for waveform generation register 4. [28]: S pecify the set value for waveform generation register 5. [29]: S pecify the set value for waveform generation register 6. [30]: S pecify the set value for waveform generation register 7. [31]: S pecify the set value for the facility sel[...]

  • Page 140

    Rev .1.01 2007.02.16 RJJ10J1643-0101 140 [1]: S pecify the set value for the timer RB I/O control register . [2]: S pecify the set value for the timer RB prescaler register . [3]: S pecify the set value for the timer RB primary register . [4]: S pecify the set value for the timer RB secondary register. [5]: S pecify the set value for the timer RB m[...]

  • Page 141

    Rev .1.01 2007.02.16 RJJ10J1643-0101 141 [3]: S pecify the set value fo r timer control register V0. [4]: S pecify the set value fo r timer control register V1. [5]: S pecify the set value for ti mer control/status register V . • When using timer W (RAPI_TIMER_W specified) [0]: S pecify the set value for timer control register W . [1]: S pecify t[...]

  • Page 142

    Rev .1.01 2007.02.16 RJJ10J1643-0101 142 [1 1]: S pecify the set value for general registe r C. [12]: S pecify the set value for general register D. [13]: S pecify the set value for timer RC mode register . • When using timer RD (RAPI_TIMER_RD 0 to RAPI_TIMER_RD3 specified) [0]: S pecify the set value for the timer RD mode register . [1]: S pecif[...]

  • Page 143

    Rev .1.01 2007.02.16 RJJ10J1643-0101 143 __EnableTimerRegister Synopsis <Control operation of timer register> Boolean __Enable TimerRegister (unsigned long dat a) data Setup data (content differs with MCU type) Description Controls operation of a spec ified timer by starting or stopping it. [data] For data, the following definition values can[...]

  • Page 144

    Rev .1.01 2007.02.16 RJJ10J1643-0101 144 RAPI_TIMER_RD2 Selects timer RD channel 2. RAPI_TIMER_RD3 Selects timer RD channel 3. RAPI_TIMER_ON Sets the selected timer to start operating. RAPI_TIMER_OFF Sets the selected timer to stop operating. Return value If the timer specification is incorrect, R API_F ALSE is returned; otherwise, RAPI_TRUE is ret[...]

  • Page 145

    Rev .1.01 2007.02.16 RJJ10J1643-0101 145 __ClearTimerRegister Synopsis <Clear timer register> Boolean __Cle arTimerRegister(unsigne d long data) data Setup data (content differs w i th MCU type) Description Sets the timer register of a specified timer to its initial value after reset. [data] For data, the following definition values can be se[...]

  • Page 146

    Rev .1.01 2007.02.16 RJJ10J1643-0101 146 Return value If the timer specification is incorrec t, RAPI_F ALSE is returned; otherwise, RAPI_TRUE is returned. Functionality T imer (register mani pulation) Reference __SetT imerRe gister , __EnableTimerRegister , __GetTimerRegister Remark • If an undefined value is specified in the ar gument, operation[...]

  • Page 147

    Rev .1.01 2007.02.16 RJJ10J1643-0101 147 __GetTimerRegister Synopsis <Get timer register value> Boolean __GetT imerRegister(unsigned long dat a1, unsigned int *dat a2) data1 Setup data (content differs with MCU type) data2 Pointer to the buffer in which register value is stored Description Gets the counter value of a specified timer . [data] [...]

  • Page 148

    Rev .1.01 2007.02.16 RJJ10J1643-0101 148 [data2] S pecify a point er to the array in which the acquired reg ister value is stored. The content of the array is described bel ow . (M16C) • When using timer A (RAPI_TIMER_ A0 to RAPI_TIMER_A4 specified) [0]: S tore the value of timer Ai mode register (i = 0 –4). [1]: S tore the value of timer Ai re[...]

  • Page 149

    Rev .1.01 2007.02.16 RJJ10J1643-0101 149 [26]: S tore the value of time measurement r egister 3/waveform generation register 3. [27]: S tore the value of time measurement r egister 4/waveform generation register 4. [28]: S tore the value of time measurement r egister 5/waveform generation register 5. [29]: S tore the value of time measurement r egi[...]

  • Page 150

    Rev .1.01 2007.02.16 RJJ10J1643-0101 150 • When using timer RB (R API_TIMER_RB specified) [0]: S pecify the set value for the timer RB one shot control register . [1]: S pecify the set value for t he timer RB I/O control register . [2]: S pecify the set value for t he timer RB prescaler register . [3]: S pecify the set value for the timer RB prim[...]

  • Page 151

    Rev .1.01 2007.02.16 RJJ10J1643-0101 151 [1]: S tore the value of time constant register A. [2]: S tore the value of time constant register B. [3]: S tore the value of timer control register V0. [4]: S tore the value of timer control register V1. [5]: S tore the value of timer control/status register V . • When using timer W (RAPI_TI MER_W specif[...]

  • Page 152

    Rev .1.01 2007.02.16 RJJ10J1643-0101 152 [9]: S pecify the set value for general register A. [10]: S pecify the set value for general register B. [1 1]: S pecify the set value for general registe r C. [12]: S pecify the set value for general register D. [13]: S pecify the set value for timer RC mode register . • When using timer RD (RAPI_TIMER_RD[...]

  • Page 153

    Rev .1.01 2007.02.16 RJJ10J1643-0101 153 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 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) Description Sets the operating conditions of a specified I/O port. [data1] For data1, [...]

  • Page 154

    Rev .1.01 2007.02.16 RJJ10J1643-0101 154 RAPI_PORT_9_0 Port P9 0 RAPI_PORT_9_1 Port P9 1 RAPI_PORT_9_2 Port P9 2 RAPI_PORT_9_3 Port P9 3 RAPI_PORT_9_5 Port P9 5 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_1[...]

  • Page 155

    Rev .1.01 2007.02.16 RJJ10J1643-0101 155 RAPI_NOT_PULLED_HIGH Sets a selected port not to be pulled high. RAPI_DRIVE_CAP ACITY_H Sets the N-channel output transistor drive capacity of a selected port to High. S pecifiable only when port P1 is used. RAPI_DRIVE_CAP ACITY_L Sets the N-channel output transistor drive capacity of a selected port to Low [...]

  • Page 156

    Rev .1.01 2007.02.16 RJJ10J1643-0101 156 RAPI_PORT_D_6 PortPD6 RAPI_PORT_D_7 PortPD7 RAPI_PORT_E_0 PortPE0 RAPI_PORT_E_1 PortPE1 RAPI_PORT_E_2 PortPE2 RAPI_PORT_E_3 PortPE3 RAPI_PORT_E_4 PortPE4 RAPI_PORT_E_5 PortPE5 RAPI_PORT_E_6 PortPE6 RAPI_PORT_E_7 PortPE7 RAPI_PORT_F_0 PortPF0 RAPI_PORT_G_0 PortPG0 RAPI_PORT_G_1 PortPG1 RAPI_PORT_G_2 PortPG2 R[...]

  • Page 157

    Rev .1.01 2007.02.16 RJJ10J1643-0101 157 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 ); }[...]

  • Page 158

    Rev .1.01 2007.02.16 RJJ10J1643-0101 158 __ReadIOPort Synopsis <Read from I/O port> Boolean __Rea dIOPort(unsigned long dat a1, unsigned int *dat a2) data1 Setup data 1 (content differs with MCU type) data2 Pointer to the variable in which the value read from I/O po rt is stored. Description Gets the value of a specified I/O port. [data1] S p[...]

  • Page 159

    Rev .1.01 2007.02.16 RJJ10J1643-0101 159 RAPI_PORT_9_5 Port P9 5 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 (R8C) RAPI_PORT_0_0 Port P0 0[...]

  • Page 160

    Rev .1.01 2007.02.16 RJJ10J1643-0101 160 RAPI_PORT_5_1 PortP51 RAPI_PORT_5_2 PortP52 RAPI_PORT_5_3 PortP53 RAPI_PORT_5_4 PortP54 RAPI_PORT_5_5 PortP55 RAPI_PORT_5_6 PortP56 RAPI_PORT_5_7 PortP57 RAPI_PORT_6_0 PortP60 RAPI_PORT_6_1 PortP61 RAPI_PORT_6_2 PortP62 RAPI_PORT_6_3 PortP63 RAPI_PORT_6_4 PortP64 RAPI_PORT_6_5 PortP65 RAPI_PORT_6_6 PortP66 R[...]

  • Page 161

    Rev .1.01 2007.02.16 RJJ10J1643-0101 161 RAPI_PORT_H_4 PortPH4 RAPI_PORT_H_5 PortPH5 RAPI_PORT_H_6 PortPH6 RAPI_PORT_H_7 PortPH7 RAPI_PORT_J_0 PortPJ0 RAPI_PORT_J_1 PortPJ1 Return value If the I/O port specification is incorrect , RAPI_F ALSE is returned; otherwise, RAPI_TRUE is returned. Functionality I/O port Reference __SetIOPort , __WriteIOPort[...]

  • Page 162

    Rev .1.01 2007.02.16 RJJ10J1643-0101 162 __WriteIOPort Synopsis <Write to I/O p ort> Boolean __W riteIOPort(unsigned long dat a1, unsigned i nt data2) data1 Setup data 1 (content differs with MCU type) 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. T[...]

  • Page 163

    Rev .1.01 2007.02.16 RJJ10J1643-0101 163 RAPI_PORT_9_5 Port P9 5 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 (R8C) RAPI_PORT_0_0 Port P0 0[...]

  • Page 164

    Rev .1.01 2007.02.16 RJJ10J1643-0101 164 RAPI_PORT_5_5 PortP55 RAPI_PORT_5_6 PortP56 RAPI_PORT_5_7 PortP57 RAPI_PORT_6_0 PortP60 RAPI_PORT_6_1 PortP61 RAPI_PORT_6_2 PortP62 RAPI_PORT_6_3 PortP63 RAPI_PORT_6_4 PortP64 RAPI_PORT_6_5 PortP65 RAPI_PORT_6_6 PortP66 RAPI_PORT_6_7 PortP67 RAPI_PORT_7_0 PortP70 RAPI_PORT_7_1 PortP71 RAPI_PORT_7_2 PortP72 R[...]

  • Page 165

    Rev .1.01 2007.02.16 RJJ10J1643-0101 165 __WriteIOPortRegister Remark • If an undefined value is specified in the first argum ent, operation of the API cannot 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[...]

  • Page 166

    Rev .1.01 2007.02.16 RJJ10J1643-0101 166 __SetIOPortRegister Synop sis <Set I/O port register> Boolean __Set IOPortRegiste r(unsigne d l ong da t a1, unsigned int dat a2, unsigned int dat a3, unsigned int dat a4) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) data3 Setup data 3 (content d[...]

  • Page 167

    Rev .1.01 2007.02.16 RJJ10J1643-0101 167 S pecify the set value for the port contro l register corresponding to a select ed port. [data3] (M16C) (R8C) S pecif y the set value for the pullup control re gister corresponding to a s elected port. (H8/300H) S pecif y the set value for the pullup control re gister corresponding to a s elected port. [data[...]

  • Page 168

    Rev .1.01 2007.02.16 RJJ10J1643-0101 168 __ReadIOPortRegister Synopsis <Read from I/O port register> Boolean __ReadIOPortRegi ster(unsigned long dat a1, unsigned int *dat a2) data1 Setup data 1 (content differs with MCU type) data2 Pointer to the variable in which the val ue read from I/O port register i s stored. Description Gets the value o[...]

  • Page 169

    Rev .1.01 2007.02.16 RJJ10J1643-0101 169 • Ports in port B of the H8/300H that are us ed 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 ); }[...]

  • Page 170

    Rev .1.01 2007.02.16 RJJ10J1643-0101 170 __WriteIOPortRegister Synopsis <W rite to I/O port register> Boolean __W riteIOPortRegister(unsigned long dat a1, unsigned int dat a2) data1 Setup data 1 (content differs with MCU type) data2 Data to be written to I/O port register Description Writes the value for a specified I/O port to eac h relevant[...]

  • Page 171

    Rev .1.01 2007.02.16 RJJ10J1643-0101 171 Program example #include " rapi_io_port_r8c_13.h" void func( void ) { /* Set the data to port P1 register */ __WriteIOPortRegister( RAPI_PORT_1, 0xFF ); }[...]

  • Page 172

    Rev .1.01 2007.02.16 RJJ10J1643-0101 172 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 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) func Callback function pointer (S pecify 0 if no[...]

  • Page 173

    Rev .1.01 2007.02.16 RJJ10J1643-0101 173 RAPI_INT2 Uses _INT2 interrupt. RAPI_INT3 Uses _INT3 interrupt. RAPI_KEY Uses key input interrupt. RAPI_INT_RISING S pecifies a rising edge for the active edge of a selected external interrupt. RAPI_INT_F ALLING Specifies a falling edge for the active edge of a selected external interrupt. RAPI_INT_BOTH Spec[...]

  • Page 174

    Rev .1.01 2007.02.16 RJJ10J1643-0101 174 RAPI_INT_RISING S pecifies a rising edge for the ac tive edge of a selected external interrupt. RAPI_INT_F ALLING S pecifies a falling edge fo r the active edge of a selected external interrupt. RAPI_WKP0_F ALLING Enables _WKP0 pin input whose falling edge is the active edge. RAPI_WKP0_RISING Enables _WKP0 p[...]

  • Page 175

    Rev .1.01 2007.02.16 RJJ10J1643-0101 175 RAPI_TRUE is returned. Functionality External interrupt Reference __EnableInterrupt , __GetInterruptFlag , __ClearInterruptF lag Remark • If an undefined value is specified in the first argum ent, operation of the API cannot be guaranteed. • The specifiable exter nal interrupts differ with each CPU used.[...]

  • Page 176

    Rev .1.01 2007.02.16 RJJ10J1643-0101 176 __EnableInterrupt Synopsis <Control external interrupt> Boolean __Enable Interrupt(unsigned long dat a1, unsigned int da ta2) data1 Setup data 1 (content differs with MCU type) data2 Setup data 2 (content differs with MCU type) Description Changes the operating conditi on of a specified external inter [...]

  • Page 177

    Rev .1.01 2007.02.16 RJJ10J1643-0101 177 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 __SetInterrupt , __GetInterruptFlag , __C learInterruptFlag Remark • If an undefined value is specified in the first argum ent, operatio[...]

  • Page 178

    Rev .1.01 2007.02.16 RJJ10J1643-0101 178 __GetInterruptFlag Synopsis <Get the status of external interrupt flag> Boolean __GetInterruptFlag (unsigned long dat a1, unsigned int *dat a2)) data1 Setup data 1 (content differs with MCU type) data2 Pointer to the buffer in which the acquired flag data is stored Description Gets the value of interru[...]

  • Page 179

    Rev .1.01 2007.02.16 RJJ10J1643-0101 179 Functionality External interrupt Reference __SetInterrupt , __EnableInter rupt , __ClearInterruptFlag Remark • If an undefined value is specified in the first argum ent, operation of the API cannot be guaranteed. • The specifiable exter nal interrupts differ with each CPU used. Program example #include &[...]

  • Page 180

    Rev .1.01 2007.02.16 RJJ10J1643-0101 180 __ClearInterruptFlag Synopsis <Clear external interrupt flag> Boolean __Cle arInterruptFlag(unsigned long da ta) data Setup data (content differs with MCU type) Description Clears the interrupt request flag of a specified exter nal interrupt. [data] (M16C) RAPI_INT0 Uses _INT0 interrupt. RAPI_INT1 Uses[...]

  • Page 181

    Rev .1.01 2007.02.16 RJJ10J1643-0101 181 be guaranteed. • The specifiable exter nal 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 ); }[...]

  • Page 182

    Rev .1.01 2007.02.16 RJJ10J1643-0101 182 4.2.5 A/D converter __CreateADC Synopsis <Set A/D converter> Boolean __Cre ate ADC(unsigne d long data 1, unsigned int dat a2, unsigned int dat a3, void* func) data1 Setup data 1 (content differs with MCU type) data2 Number of analog input pins used by A/D converter (differs with MCU t ype) data3 Setup[...]

  • Page 183

    Rev .1.01 2007.02.16 RJJ10J1643-0101 183 RAPI_AN22 Uses AN 22 pin for the analog input pin. RAPI_AN23 Uses AN 23 pin for the analog input pin. RAPI_AN24 Uses AN 24 pin for the analog input pin. RAPI_AN25 Uses AN 25 pin for the analog input pin. RAPI_AN26 Uses AN 26 pin for the analog input pin. RAPI_AN27 Uses AN 27 pin for the analog input pin. RAP[...]

  • Page 184

    Rev .1.01 2007.02.16 RJJ10J1643-0101 184 (Conversion method) S pecify one from { RAPI_WITH_S AMPLE_HOLD, RAPI_WITHOUT_SAMPLE_HOLD }. The default value is RAPI_WITHOUT_SAMPLE_HOLD. (T rigge r) S pecify one from { RAPI_SOFTWARE_TRIGGER, RAPI_EXTERNAL_TRIGGER }. The default value is RAPI_SOFTWARE_TRIGGER. • Specifiable definition values when repeat [...]

  • Page 185

    Rev .1.01 2007.02.16 RJJ10J1643-0101 185 (Resolution) Specify o ne from { RAPI_10BIT , RAPI_8BIT }. The default value is RAPI_8BIT . (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 i[...]

  • Page 186

    Rev .1.01 2007.02.16 RJJ10J1643-0101 186 (Resolution) Specify o ne from { RAPI_10BIT , RAPI_8BIT }. The default value is RAPI_8BIT . (Conversion method) S pecify RAPI_WITH_SAMPLE_HOLD. • Specifiable definition values when dela yed trigger mode 1 is used (RAPI_DELA YE D_TRIGGER1 specified) (Input pin) S pecify one from { RAPI_P0_GROUP , RAPI_P10_G[...]

  • Page 187

    Rev .1.01 2007.02.16 RJJ10J1643-0101 187 RAPI_SOFTW A RE_TRI GGER Selects sof tware trigger. RAPI_TIMER_RD_TRIG GER Selects timer RD as trigger . • Speci fiable definition v alues when one-shot mode i s used (RAPI_ONE_S HO T specified) (Input pin) S pecify one from { RAPI_AN 0, RAPI_AN1, RAPI_AN2, RAPI_AN3, RAPI_AN4, RAPI_AN5, RAPI_AN6, RAPI_AN7,[...]

  • Page 188

    Rev .1.01 2007.02.16 RJJ10J1643-0101 188 RAPI_AN4 Uses AN4 pin for the analog input pin. RAPI_AN5 Uses AN5 pin for the analog input pin. RAPI_AN6 Uses AN6 pin for the analog input pin. RAPI_AN7 Uses AN7 pin for the analog input pin. RAPI_AN8 Uses AN8 pin for the analog input pin. RAPI_AN9 Uses AN9 pin for the analog input pin. RAPI_AN10 Uses AN10 p[...]

  • Page 189

    Rev .1.01 2007.02.16 RJJ10J1643-0101 189 (Input pin) S pecify one from { RAPI_AN0, RAPI_AN 1, RAPI_AN2, RAPI_AN 3, RAPI_AN4, RAPI_AN5, RAPI _AN6, RAPI_AN7 , RAPI_AN8, RAPI _AN9, RAPI_AN1 0, RAPI_AN1 1, RAPI_AN12, RAPI_AN13, RAPI_A N14, RAPI_AN15 } T he default value is RAPI_A N0. (Conversion time) S pecify one from { RAPI_134 _ST A TES, RAPI_ 70_ST[...]

  • Page 190

    Rev .1.01 2007.02.16 RJJ10J1643-0101 190 Delayed trigger mode 1 Repeat sweep mode S pecify 1, 2, 3, or 4. (R8C) S pecify 1. (H8/300H) One-shot mode S pecify 1. Repeat mode Single sweep mode Specify 1, 2, 3, or 4. Repeat sweep mode 0 [data3] (M16C) (R8C) S pecify the interrupt priority le vel (0 – 7) to be set in the interrupt control register . ([...]

  • Page 191

    Rev .1.01 2007.02.16 RJJ10J1643-0101 191 __EnableADC Synopsis <Control operation of A/D converter> Boolean __EnableA DC (unsigned long dat a1, unsigned int da ta2) data1 Setup data 1 (content differs with MCU type) data2 Number of analog input pins used by A/D converter (differs with MCU type) Description Controls operation of the A/D conv er[...]

  • Page 192

    Rev .1.01 2007.02.16 RJJ10J1643-0101 192 Selectable only when one -shot mode or repeat mode is used. 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 fo[...]

  • Page 193

    Rev .1.01 2007.02.16 RJJ10J1643-0101 193 RAPI_AN4 Uses AN 4 pin for the analog input pin. RAPI_AN5 Uses AN 5 pin for the analog input pin. RAPI_AN6 Uses AN 6 pin for the analog input pin. RAPI_AN7 Uses AN 7 pin for the analog input pin. RAPI_AN8 Uses AN 8 pin for the analog input pin. RAPI_AN9 Uses AN 9 pin for the analog input pin. RAPI_AN10 Uses [...]

  • Page 194

    Rev .1.01 2007.02.16 RJJ10J1643-0101 194 Selectable only when sweep mode or repeat s weep mode 0 is used. RAPI_AN4_GROUP Uses AN4-AN7 pi ns group for the analog input pin. Selectable only when sweep mode or repeat s weep mode 0 is used. RAPI_AN8_GROUP Uses AN8-AN1 1 pi ns group for the analog input pin. Selectable only when sweep mode or repeat s w[...]

  • Page 195

    Rev .1.01 2007.02.16 RJJ10J1643-0101 195 void func( void ) { /* Disable A/D converter */ __EnableADC( RAPI_AN0|RAPI_AD_OFF, 1 ); }[...]

  • Page 196

    Rev .1.01 2007.02.16 RJJ10J1643-0101 196 __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 Refere[...]

  • Page 197

    Rev .1.01 2007.02.16 RJJ10J1643-0101 197 __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 (content differs with MCU type) data2 Pointer to the buffer in which A/D converted value is stored. Description Gets the A/D converted value fr om a specif[...]

  • Page 198

    Rev .1.01 2007.02.16 RJJ10J1643-0101 198 __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 a[...]

  • Page 199

    Rev .1.01 2007.02.16 RJJ10J1643-0101 199 __GetADCSt atus Synopsis <Get the status of A/D converter> Boolean __GetADCSta tu s(u nsigned int *st atu s) st at us Pointer to the buffer in which the r egister content indicating A/D converter status is stored. Description Gets the status of a s pecified A/D converter . The status of interrupt bit ([...]

  • Page 200

    Rev .1.01 2007.02.16 RJJ10J1643-0101 200 __ClearADCSt atus Synopsis <Clear the status of A/D converter> Boolean __Clear ADCSt atus(unsig n ed int st atu s) status S tatus of A/D converter Description Clears the status flag of a specified A/D converter . S pecify the status of interrupt bit (when using the M16C or R8C) or the value of A/D end [...]

  • Page 201

    Rev .1.01 2007.02.16 RJJ10J1643-0101 201 Renesas Embedded Application Programming Interface Reference Manual Rev . 1.01 Issued: April 2007[...]

  • Page 202

    2- 6 -2, Ote-machi, Chiyoda-ku, Tokyo, 1 00-0004, Japan Renesas Embedded Application Programming Interface Reference manual[...]