R5F21238DFP#U0 Renesas Electronics America, R5F21238DFP#U0 Datasheet
![IC R8C/23 MCU FLASH 48-LQFP](/photos/12/38/123822/r5f21238dfp_u0_sml.jpg)
R5F21238DFP#U0
Specifications of R5F21238DFP#U0
Available stocks
Related parts for R5F21238DFP#U0
R5F21238DFP#U0 Summary of contents
Page 1
To our customers, Old Company Name in Catalogs and Other Documents st On April 1 , 2010, NEC Electronics Corporation merged with Renesas Technology Corporation, and Renesas Electronics Corporation took over all the business of both companies. Therefore, although the ...
Page 2
All information included in this document is current as of the date this document is issued. Such information, however, is subject to change without any prior notice. Before purchasing or using any Renesas Electronics products listed herein, please confirm ...
Page 3
R8C/22 Group, 16 R8C/23 Group Hardware Manual RENESAS MCU R8C FAMILY / R8C/2x SERIES All information contained in these materials, including products and product specifications, represents information on the product at the time of publication and is subject to change ...
Page 4
This document is provided for reference purposes only so that Renesas customers may select the appropriate Renesas products for their use. Renesas neither makes warranties or representations with respect to the accuracy or completeness of the information contained in ...
Page 5
General Precautions in the Handling of MPU/MCU Products The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the products covered by this manual, refer to the relevant sections of the manual. If ...
Page 6
How to Use This Manual 1. Purpose and Target Readers This manual is designed to provide the user with an understanding of the hardware functions and electrical characteristics of the MCU intended for users designing application systems incorporating ...
Page 7
Notation of Numbers and Symbols The notation conventions for register names, bit names, numbers, and symbols used in this manual are described below. (1) Register Names, Bit Names, and Pin Names Registers, bits, and pins are referred to in ...
Page 8
Register Notation The symbols and terms used in register diagrams are described below. XXX Register Bit Symbol XXX0 XXX1 XXX4 XXX5 XXX6 XXX7 *1 Blank: Set ...
Page 9
List of Abbreviations and Acronyms Abbreviation ACIA bps CRC DMA DMAC GSM Hi-Z IEBus I/O IrDA LSB MSB NC PLL PWM SIM UART VCO All trademarks and registered trademarks are the property of their respective owners. All trademarks and ...
Page 10
SFR Page Reference ........................................................................................................................... Overview ......................................................................................................................................... 1 1.1 Applications ............................................................................................................................................... 1 1.2 Performance Overview .............................................................................................................................. 2 1.3 Block Diagram .......................................................................................................................................... 4 1.4 Product Information .................................................................................................................................. 5 1.5 Pin Assignments ........................................................................................................................................ 7 1.6 Pin Functions ............................................................................................................................................. 8 ...
Page 11
Monitoring Vdet2 ............................................................................................................................... 41 6.2 Voltage Monitor 1 Reset ......................................................................................................................... 42 6.3 Voltage Monitor 2 Interrupt and Voltage Monitor 2 Reset ..................................................................... 43 7. Programmable I/O Ports ............................................................................................................... 45 7.1 Functions of Programmable I/O Ports ..................................................................................................... 45 7.2 Effect ...
Page 12
Peripheral Function Interrupt .............................................................................................................. 98 12.1.5 Interrupts and Interrupt Vector ........................................................................................................... 99 12.1.6 Interrupt Control ............................................................................................................................... 101 12.2 INT Interrupt ......................................................................................................................................... 110 12.2.1 INTi Interrupt ( .................................................................................................................. 110 12.2.2 INTi Input Filter ( ...
Page 13
Timer RE ............................................................................................................................................... 267 14.4.1 Output Compare Mode ..................................................................................................................... 268 14.4.2 Notes on Timer RE ........................................................................................................................... 274 15. Serial Interface ............................................................................................................................ 275 15.1 Clock Synchronous Serial I/O Mode ..................................................................................................... 281 15.1.1 Polarity Select Function .................................................................................................................... 284 15.1.2 LSB First/MSB ...
Page 14
Acceptance Mask Registers ................................................................................................................... 374 18.4 CAN SFR Registers ............................................................................................................................... 375 18.4.1 C0MCTLi Register ( 15) ....................................................................................................... 375 18.4.2 C0CTLR Register ............................................................................................................................. 376 18.4.3 C0STR Register ................................................................................................................................ 377 18.4.4 C0SSTR Register .............................................................................................................................. 378 18.4.5 C0ICR Register ...
Page 15
ROM Code Protect Function ............................................................................................................ 420 20.4 CPU Rewrite Mode ............................................................................................................................... 421 20.4.1 EW0 Mode ........................................................................................................................................ 422 20.4.2 EW1 Mode ........................................................................................................................................ 422 20.4.3 Software Commands ......................................................................................................................... 431 20.4.4 Status Registers ................................................................................................................................. 436 20.4.5 Full Status Check .............................................................................................................................. 437 20.5 ...
Page 16
Notes on On-Chip Debugger ...................................................................................................... 495 24. Notes on Emulator Debugger ..................................................................................................... 496 Appendix 1. Package Dimensions ........................................................................................................ 497 Appendix 2. Connection Examples between Serial Writer and On-Chip Debugging Emulator ............ 498 Appendix 3. Example of Oscillation Evaluation Circuit ...
Page 17
SFR Page Reference Address Register 0000h 0001h 0002h 0003h 0004h Processor Mode Register 0 0005h Processor Mode Register 1 0006h System Clock Control Register 0 0007h System Clock Control Register 1 0008h 0009h 000Ah Protect Register 000Bh 000Ch Oscillation Stop ...
Page 18
Address Register 0080h 0081h 0082h 0083h 0084h 0085h 0086h 0087h 0088h 0089h 008Ah 008Bh 008Ch 008Dh 008Eh 008Fh 0090h 0091h 0092h 0093h 0094h 0095h 0096h 0097h 0098h 0099h 009Ah 009Bh 009Ch 009Dh 009Eh 009Fh 00A0h UART0 Transmit/Receive Mode Register 00A1h ...
Page 19
Address Register 0100h Timer RA Control Register 0101h Timer RA I/O Control Register 0102h Timer RA Mode Register 0103h Timer RA Prescaler Register 0104h Timer RA Register 0105h 0106h LIN Control Register 0107h LIN Status Register 0108h Timer RB Control ...
Page 20
Address Register 01A0h 01A1h 01A2h 01A3h 01A4h 01A5h 01A6h 01A7h 01A8h 01A9h 01AAh 01ABh 01ACh 01ADh 01AEh 01AFh 01B0h 01B1h 01B2h 01B3h Flash Memory Control Register 4 01B4h 01B5h Flash Memory Control Register 1 01B6h 01B7h Flash Memory Control Register ...
Page 21
Address Register 1380h CAN0 Slot 2: Identifier/DLC 1381h 1382h 1383h 1384h 1385h 1386h CAN0 Slot 2: Data Field 1387h 1388h 1389h 138Ah 138Bh 138Ch 138Dh 138Eh CAN0 Slot 2: Time Stamp 138Fh 1390h CAN0 Slot 3: Identifier/DLC 1391h 1392h 1393h ...
Page 22
Address Register 1400h CAN0 Slot 10: Identifier/DLC 1401h 1402h 1403h 1404h 1405h 1406h CAN0 Slot 10: Data Field 1407h 1408h 1409h 140Ah 140Bh 140Ch 140Dh 140Eh CAN0 Slot 10: Time Stamp 140Fh 1410h CAN0 Slot 11: Identifier/DLC 1411h 1412h 1413h ...
Page 23
R8C/22 Group, R8C/23 Group RENESAS MCU 1. Overview This MCU is built using the high-performance silicon gate CMOS process using the R8C CPU core and is packaged in a 48-pin plastic molded LQFP. This MCU operates using sophisticated instructions featuring ...
Page 24
R8C/22 Group, R8C/23 Group 1.2 Performance Overview Table 1.1 outlines the Functions and Specifications for R8C/22 Group and Table 1.2 outlines the Functions and Specifications for R8C/23 Group. Table 1.1 Functions and Specifications for R8C/22 Group Item CPU Number of ...
Page 25
R8C/22 Group, R8C/23 Group Table 1.2 Functions and Specifications for R8C/23 Group Item CPU Number of fundamental instructions 89 instructions Minimum instruction execution time 50 ns (f(XIN MHz, VCC = 3.0 to 5.5 V) Operating mode Address space ...
Page 26
R8C/22 Group, R8C/23 Group 1.3 Block Diagram Figure 1.1 shows a Block Diagram. I/O port Timer Timer RA (8 bits) Timer RB (8 bits) × 2 channels Timer RD (16 bits Timer RE (8 bits) Watchdog timer (15 bits) Figure ...
Page 27
R8C/22 Group, R8C/23 Group 1.4 Product Information Table 1.3 lists Product Information for R8C/22 Group and Table 1.4 lists Product Information for R8C/23 Group. Table 1.3 Product Information for R8C/22 Group Type No. ROM Capacity R5F21226DFP 32 Kbytes R5F21227DFP 48 ...
Page 28
R8C/22 Group, R8C/23 Group Table 1.4 Product Information for R8C/23 Group Type No. Program ROM R5F21236DFP 32 Kbytes R5F21237DFP 48 Kbytes R5F21238DFP 64 Kbytes R5F21236JFP 32 Kbytes R5F21237JFP 48 Kbytes R5F21238JFP 64 Kbytes R5F2123AJFP 96 Kbytes R5F2123CJFP 128 Kbytes R5F21236KFP ...
Page 29
R8C/22 Group, R8C/23 Group 1.5 Pin Assignments Figure 1.4 shows Pin Assignments (Top View). Pin assignments (top view) P0_6/AN1 37 P0_5/AN2 38 P0_4/AN3 39 P4_2/VREF 40 P6_0/TREO 41 P6_2/CRX0 42 P6_1/CTX0 43 P0_3/AN4 44 P0_2/AN5 45 P0_1/AN6 46 P0_0/AN7 47 ...
Page 30
R8C/22 Group, R8C/23 Group 1.6 Pin Functions Table 1.5 lists the Pin Functions and Table 1.6 lists the Pin Name Information by Pin Number. Table 1.5 Pin Functions Type Power Supply Input VCC VSS Analog Power Supply AVCC, AVSS Input ...
Page 31
R8C/22 Group, R8C/23 Group Table 1.6 Pin Name Information by Pin Number Pin Control Pin Port Number 1 P3_5 2 P3_3 3 P3_4 4 MODE 5 P4_3 6 P4_4 7 RESET 8 XOUT P4_7 9 VSS/AVSS 10 XIN P4_6 11 ...
Page 32
R8C/22 Group, R8C/23 Group 2. Central Processing Unit (CPU) Figure 2.1 shows the CPU Registers. The CPU contains 13 registers. Of these, R0, R1, R2, R3, A0, A1, and FB comprise a register bank. Two sets of register banks are ...
Page 33
R8C/22 Group, R8C/23 Group 2.1 Data Registers (R0, R1, R2 and R3 16-bit register for transfer, arithmetic, and logic operations. The same applies R3. R0 can be split into high-order bit (R0H) and low-order ...
Page 34
R8C/22 Group, R8C/23 Group 2.8.7 Interrupt Enable Flag (I) The I flag enables a maskable interrupt. An interrupt is disabled when the I flag is set to 0, and are enabled when the I flag is set to 1. The ...
Page 35
R8C/22 Group, R8C/23 Group 3. Memory 3.1 R8C/22 Group Figure 3.1 shows a Memory Map of R8C/22 Group. The R8C/22 Group has 1 Mbyte of address space from address 00000h to FFFFFh. The internal ROM is allocated lower addresses, beginning ...
Page 36
R8C/22 Group, R8C/23 Group 3.2 R8C/23 Group Figure 3.2 shows a Memory Map of R8C/23 Group. The R8C/23 Group has 1 Mbyte of address space from address 00000h to FFFFFh. The internal ROM (program ROM) is allocated lower addresses, beginning ...
Page 37
R8C/22 Group, R8C/23 Group 4. Special Function Registers (SFRs) An SFR (special function register control register for a peripheral function. Table 4.1 to Table 4.13 list the SFR Information. Table 4.1 SFR Information (1) Address 0000h 0001h 0002h ...
Page 38
R8C/22 Group, R8C/23 Group Table 4.2 SFR Information (2) Address 0040h 0041h 0042h 0043h CAN0 Wake Up Interrupt Control Register 0044h CAN0 Successful Reception Interrupt Control Register 0045h CAN0 Successful Transmission Interrupt Control Register 0046h CAN0 State/Error Interrupt Control Register ...
Page 39
R8C/22 Group, R8C/23 Group Table 4.3 SFR Information (3) Address 0080h 0081h 0082h 0083h 0084h 0085h 0086h 0087h 0088h 0089h 008Ah 008Bh 008Ch 008Dh 008Eh 008Fh 0090h 0091h 0092h 0093h 0094h 0095h 0096h 0097h 0098h 0099h 009Ah 009Bh 009Ch 009Dh ...
Page 40
R8C/22 Group, R8C/23 Group Table 4.4 SFR Information (4) Address 00C0h A/D Register 00C1h 00C2h 00C3h 00C4h 00C5h 00C6h 00C7h 00C8h 00C9h 00CAh 00CBh 00CCh 00CDh 00CEh 00CFh 00D0h 00D1h 00D2h 00D3h 00D4h A/D Control Register 2 00D5h 00D6h A/D ...
Page 41
R8C/22 Group, R8C/23 Group Table 4.5 SFR Information (5) Address 0100h Timer RA Control Register 0101h Timer RA I/O Control Register 0102h Timer RA Mode Register 0103h Timer RA Prescaler Register 0104h Timer RA Register 0105h 0106h LIN Control Register ...
Page 42
R8C/22 Group, R8C/23 Group Table 4.6 SFR Information (6) Address 0140h Timer RD Control Register 0 0141h Timer RD I/O Control Register A0 0142h Timer RD I/O Control Register C0 0143h Timer RD Status Register 0 0144h Timer RD Interrupt ...
Page 43
R8C/22 Group, R8C/23 Group Table 4.7 SFR Information (7) Address 0180h 0181h 0182h 0183h 0184h 0185h 0186h 0187h 0188h 0189h 018Ah 018Bh 018Ch 018Dh 018Eh 018Fh 0190h 0191h 0192h 0193h 0194h 0195h 0196h 0197h 0198h 0199h 019Ah 019Bh 019Ch 019Dh ...
Page 44
R8C/22 Group, R8C/23 Group Table 4.8 SFR Information (8) Address 1300h CAN0 Message Control Register 0 1301h CAN0 Message Control Register 1 1302h CAN0 Message Control Register 2 1303h CAN0 Message Control Register 3 1304h CAN0 Message Control Register 4 ...
Page 45
R8C/22 Group, R8C/23 Group Table 4.9 SFR Information (9) Address 1340h 1341h 1342h CAN0 Acceptance Filter Support Register 1343h 1344h 1345h 1346h 1347h 1348h 1349h 134Ah 134Bh 134Ch 134Dh 134Eh 134Fh 1350h 1351h 1352h 1353h 1354h 1355h 1356h 1357h 1358h ...
Page 46
R8C/22 Group, R8C/23 Group Table 4.10 SFR Information (10) Address 1380h CAN0 Slot 2: Identifier/DLC 1381h 1382h 1383h 1384h 1385h 1386h CAN0 Slot 2: Data Field 1387h 1388h 1389h 138Ah 138Bh 138Ch 138Dh 138Eh CAN0 Slot 2: Time Stamp 138Fh ...
Page 47
R8C/22 Group, R8C/23 Group Table 4.11 SFR Information (11) Address 13C0h CAN0 Slot 6: Identifier/DLC 13C1h 13C2h 13C3h 13C4h 13C5h 13C6h CAN0 Slot 6: Data Field 13C7h 13C8h 13C9h 13CAh 13CBh 13CCh 13CDh 13CEh CAN0 Slot 6: Time Stamp 13CFh ...
Page 48
R8C/22 Group, R8C/23 Group Table 4.12 SFR Information (12) Address 1400h CAN0 Slot 10: Identifier/DLC 1401h 1402h 1403h 1404h 1405h 1406h CAN0 Slot 10: Data Field 1407h 1408h 1409h 140Ah 140Bh 140Ch 140Dh 140Eh CAN0 Slot 10: Time Stamp 140Fh ...
Page 49
R8C/22 Group, R8C/23 Group Table 4.13 SFR Information (13) Address 1440h CAN0 Slot 14: Identifier/DLC 1441h 1442h 1443h 1444h 1445h 1446h CAN0 Slot 14: Data Field 1447h 1448h 1449h 144Ah 144Bh 144Ch 144Dh 144Eh CAN0 Slot 14: Time Stamp 144Fh ...
Page 50
R8C/22 Group, R8C/23 Group 5. Resets There are resets: hardware reset, power-on reset, voltage monitor 1 reset, voltage monitor 2 reset, watchdog timer reset, and software reset. Table 5.1 lists the Reset Names and Sources. Table 5.1 Reset Names and ...
Page 51
R8C/22 Group, R8C/23 Group Table 5.2 lists the Pin Functions after Reset, Figure 5.2 shows CPU Register Status after Reset, Figure 5.3 shows Reset Sequence, and Figure 5.4 shows the OFS Register. Table 5.2 Pin Functions after Reset Pin Name ...
Page 52
R8C/22 Group, R8C/23 Group fOCO-S RESET pin 10 cycles or more are needed fOCO-S clock × 32 cycles Internal reset signal Start time of flash memory (CPU clock × 14 cycles) CPU clock Address (internal address signal) NOTES: 1. Hardware ...
Page 53
R8C/22 Group, R8C/23 Group 5.1 Hardware Reset A reset is applied using the RESET pin. When an “L” signal is applied to the RESET pin while the power supply voltage meets the recommended performance condition, the pins, CPU, and SFR ...
Page 54
R8C/22 Group, R8C/23 Group VCC RESET Figure 5.5 Example of Hardware Reset Circuit and Operation RESET Figure 5.6 Example of Hardware Reset Circuit (Usage Example of External Supply Voltage Detection Circuit) and Operation Rev.2.00 Aug 20, 2008 Page 32 of ...
Page 55
R8C/22 Group, R8C/23 Group 5.2 Power-On Reset Function When the RESET pin is connected to the VCC pin via a pull-up resistor, and the VCC pin voltage level rises, the power-on reset function is enabled and the MCU resets its ...
Page 56
R8C/22 Group, R8C/23 Group 5.3 Voltage Monitor 1 Reset A reset is applied using the on-chip voltage detection 1 circuit. The voltage detection 1 circuit monitors the input voltage to the VCC pin. The voltage to monitor is Vdet1. When ...
Page 57
R8C/22 Group, R8C/23 Group 6. Voltage Detection Circuit The voltage detection circuit is a circuit to monitor the input voltage to the VCC pin. This circuit monitors the VCC input voltage by the program. And the voltage monitor 1 reset, ...
Page 58
R8C/22 Group, R8C/23 Group VCC Internal reference voltage Figure 6.1 Block Diagram of Voltage Detection Circuit Voltage detection 1 circuit VCA26 VCC + Internal - reference voltage Voltage detection 1 signal is held “H” when VCA26 bit is set to ...
Page 59
R8C/22 Group, R8C/23 Group Voltage detection 2 circuit fOCO-S VCA27 VCA13 VCC + Noise filter Internal Voltage - reference detection 2 signal voltage (Filter width: 200ns) Voltage detection 2 signal is held “H” when VCA27 bit is set to 0 ...
Page 60
R8C/22 Group, R8C/23 Group Voltage Detection Register Symbol VCA1 Bit Symbol — (b2-b0) VCA13 — (b7-b4) NOTES: 1. The VCA13 bit is enabled w ...
Page 61
R8C/22 Group, R8C/23 Group Voltage Monitor 1 Circuit Control Register Symbol VW1C Bit Symbol VW1C0 VW1C1 VW1C2 — (b3) VW1F0 VW1F1 VW1C6 VW1C7 NOTES: 1. Set the PRC3 bit in the ...
Page 62
R8C/22 Group, R8C/23 Group Voltage Monitor 2 Circuit Control Register Symbol VW2C Bit Symbol VW2C0 VW2C1 VW2C2 VW2C3 VW2F0 VW2F1 VW2C6 VW2C7 NOTES: 1. Set the PRC3 bit in the PRCR register ...
Page 63
R8C/22 Group, R8C/23 Group 6.1 VCC Input Voltage 6.1.1 Monitoring Vdet1 Vdet1 cannot be monitored. 6.1.2 Monitoring Vdet2 Set the VCA27 bit in the VCA2 register to 1 (voltage detection 2 circuit enabled). After td(E-A) has elapsed (refer to 21. ...
Page 64
R8C/22 Group, R8C/23 Group 6.2 Voltage Monitor 1 Reset Table 6.2 lists the Procedure for Setting Bits Associated with Voltage Monitor 1 Reset and Figure 6.7 shows an Example of Voltage Monitor 1 Reset Operation. To use the voltage monitor ...
Page 65
R8C/22 Group, R8C/23 Group 6.3 Voltage Monitor 2 Interrupt and Voltage Monitor 2 Reset Table 6.3 lists the Procedure for Setting Bits Associated with Voltage Monitor 2 Interrupt and Reset. Figure 6.8 shows an Example of Voltage Monitor 2 Interrupt ...
Page 66
R8C/22 Group, R8C/23 Group Vdet2 (1) 2.7 V VCA13 bit VW2C2 bit When the VW2C1 bit is set to 0 (digital filter enabled) Voltage monitor 2 interrupt request (VW2C6 = 0) Internal reset signal (VW2C6 = 1) VW2C2 bit When ...
Page 67
R8C/22 Group, R8C/23 Group 7. Programmable I/O Ports There are 41 programmable Input/Output ports (I/O ports P2, P3_0, P3_1, P3_3 to P3_5, P3_7, P4_3 to P4_5, and P6. Also, P4_6 and P4_7 can be used as input-only ports ...
Page 68
R8C/22 Group, R8C/23 Group 7.2 Effect on Peripheral Functions Programmable I/O ports function as I/O of peripheral functions (refer to Table 1.6 Pin Name Information by Pin Number). Table 7.3 lists the Setting of PDi_j Bit when Functioning as I/O ...
Page 69
R8C/22 Group, R8C/23 Group P0 Data bus P1_0 to P1_3 Output from each peripheral function Data bus Input to each peripheral function P1_4 Output from each peripheral function Data bus NOTE: 1. symbolizes a parasitic diode. Ensure the input voltage ...
Page 70
R8C/22 Group, R8C/23 Group P1_5 and P1_7 Output from each peripheral function Data bus Port latch INT1 input Input to each peripheral function P1_6 and P2 Output from each peripheral function Data bus Port latch Input to each peripheral function ...
Page 71
R8C/22 Group, R8C/23 Group P3_0 and P3_1 Output from each peripheral function Data bus P3_3 to P3_5 and P3_7 Output from each peripheral function Data bus Input to each peripheral function NOTE: 1. Ensure the input voltage on each port ...
Page 72
R8C/22 Group, R8C/23 Group P4_2/VREF P4_3 and P4_4 Data bus NOTE: 1. Ensure the input voltage on each port will not exceed VCC. Figure 7.4 Configuration of Programmable I/O Ports (4) Rev.2.00 Aug 20, 2008 Page 50 of 501 REJ09B0251-0200 ...
Page 73
R8C/22 Group, R8C/23 Group P4_5 Data bus INT0 and input to each peripheral function P4_6/XIN P4_7/XOUT NOTES: 1. Ensure the input voltage on each port will not exceed VCC. 2. When CM05 = 1, CM10 = 1, or CM13 = ...
Page 74
R8C/22 Group, R8C/23 Group P6_0 and P6_1 Output from each peripheral function Data bus P6_2 Output from each peripheral function Data bus Input to each peripheral function P6_3 to P6_5 Data bus NOTE: 1. Ensure the input voltage on each ...
Page 75
R8C/22 Group, R8C/23 Group P6_6 Output from each peripheral function Data bus P6_7 Data bus Input to each peripheral function NOTE: 1. Ensure the input voltage on each port will not exceed VCC. Figure 7.7 Configuration of Programmable I/O Ports ...
Page 76
R8C/22 Group, R8C/23 Group MODE MODE signal input RESET RESET signal input NOTE: 1. Ensure the input voltage on each port will not exceed VCC. Figure 7.8 Configuration of I/O Pins Rev.2.00 Aug 20, 2008 Page 54 of 501 REJ09B0251-0200 ...
Page 77
R8C/22 Group, R8C/23 Group Port Pi Direction Register ( Symbol (3) PD0 PD1 PD2 PD3 PD4 PD6 Bit Symbol PDi_0 PDi_1 PDi_2 PDi_3 PDi_4 PDi_5 PDi_6 PDi_7 ...
Page 78
R8C/22 Group, R8C/23 Group Pull-Up Control Register Symbol PUR0 Bit Symbol PU00 PU01 PU02 PU03 PU04 PU05 PU06 PU07 NOTE: 1. When this bit is set to 1 (pulled up), the ...
Page 79
R8C/22 Group, R8C/23 Group 7.4 Port Settings Table 7.4 to Table 7.47 list the port settings. Table 7.4 Port P0_0/AN7 Register PD0 Bit PD0_0 CH2 0 X Setting 1 X value NOTE: 1. Pulled ...
Page 80
R8C/22 Group, R8C/23 Group Table 7.9 Port P0_5/AN2 Register PD0 Bit PD0_5 CH2 0 X Setting 1 X value NOTE: 1. Pulled up by setting the PU01 bit in the PUR0 register to 1. ...
Page 81
R8C/22 Group, R8C/23 Group Table 7.14 Port P1_2/KI2/AN10 Register PD1 KIEN Bit PD1_2 KI2EN Setting value NOTE: 1. Pulled up by setting the PU02 bit in the PUR0 ...
Page 82
R8C/22 Group, R8C/23 Group Table 7.18 Port P1_6/CLK0 Register PD1 Bit PD1_6 SMD2 0 X Setting 1 value NOTE: 1. Pulled up by setting the PU03 bit in the PUR0 register to ...
Page 83
R8C/22 Group, R8C/23 Group Table 7.22 Port P2_2/TRDIOC0 Register PD2 TRDOER1 Bit PD2_2 EC0 CMD1 Setting value NOTE: 1. Pulled up by ...
Page 84
R8C/22 Group, R8C/23 Group Table 7.25 Port P2_5/TRDIOB1 Register PD2 TRDOER1 Bit PD2_5 EB1 CMD1 Setting 1 value ...
Page 85
R8C/22 Group, R8C/23 Group Table 7.28 Port P3_0/TRAO Register PD3 Bit PD3_0 0 Setting 1 value NOTE: 1. Pulled up by setting the PU06 bit in the PUR0 register to 1. Table 7.29 Port P3_1/TRBO ...
Page 86
R8C/22 Group, R8C/23 Group Table 7.32 Port P3_5/SCL/SSCK Clock Synchronous Serial I/O with Chip Select Register PD3 (Refer to Table 16.4 Association between Communication Modes and I/O Pins.) Bit PD3_5 SSCK output control Setting ...
Page 87
R8C/22 Group, R8C/23 Group Table 7.37 Port P4_5/INT0 Register PD4 Bit PD4_5 0 Setting 1 value NOTE: 1. Pulled up by setting the PU11 bit in the PUR0 register to 1. Table 7.38 Port P4_6/XIN ...
Page 88
R8C/22 Group, R8C/23 Group Table 7.42 Port P6_2/CRX0 Register PD6 Bit PD6_2 0 Setting 1 value NOTE: 1. Pulled up by setting the PU14 bit in the PUR0 register to 1. Table 7.43 Port P6_3 ...
Page 89
R8C/22 Group, R8C/23 Group Table 7.47 Port P6_7/INT3/RXD1 Register PD6 Bit PD6_7 U1PINSEL 0 1 Setting value NOTE: 1. Pulled up by setting the PU15 bit in the PUR0 register to 1. Rev.2.00 Aug ...
Page 90
R8C/22 Group, R8C/23 Group 7.5 Unassigned Pin Handling Table 7.48 lists Unassigned Pin Handling. Table 7.48 Unassigned Pin Handling Pin Name Ports P0 to P2, P3_0, P3_1, P3_3 to P3_7, P4_3 to P4_5, P6 Ports P4_6, P4_7 Port P4_2/VREF (3) ...
Page 91
R8C/22 Group, R8C/23 Group 8. Processor Mode 8.1 Processor Modes Single-chip mode can be selected as processor mode. Table 8.1 lists Features of Processor Mode. Figure 8.1 shows the PM0 Register and Figure 8.2 shows the PM1 Register. Table 8.1 ...
Page 92
R8C/22 Group, R8C/23 Group 9. Bus The bus cycles differ when accessing ROM/RAM, and when accessing SFR. Table 9.1 lists Bus Cycles by Access Space of the R8C/22 Group and Table 9.2 lists Bus Cycles by Access Space of the ...
Page 93
R8C/22 Group, R8C/23 Group 10. Clock Generation Circuit The clock generation circuit has: • XIN clock oscillation circuit • Low-speed on-chip oscillator • High-speed on-chip oscillator Table 10.1 lists Specifications of Clock Generation Circuit. Figure 10.1 shows a Clock Generation ...
Page 94
R8C/22 Group, R8C/23 Group FRA00 CM14 S Q CM10 = 1 (stop mode) R RESET Power-on reset Software reset S Q Interrupt request WAIT R instruction CM13 XIN XOUT CM13 CM05 CM02, CM05, CM06: Bits in CM0 register CM10, CM13, ...
Page 95
R8C/22 Group, R8C/23 Group System Clock Control Register Symbol CM0 Bit Symbol — (b1-b0) CM02 — (b3) — (b4) CM05 CM06 — (b7) NOTES: 1. Set ...
Page 96
R8C/22 Group, R8C/23 Group System Clock Control Register Symbol CM1 Bit Symbol CM10 — (b2-b1) CM13 CM14 CM15 CM16 CM17 NOTES: 1. Set the PRC0 bit in the PRCR ...
Page 97
R8C/22 Group, R8C/23 Group Oscillation Stop Detection Register Symbol OCD Bit Symbol OCD0 OCD1 OCD2 OCD3 — (b7-b4) NOTES: 1. Set the PRC0 bit in the PRCR register ...
Page 98
R8C/22 Group, R8C/23 Group High-Speed On-Chip Oscillator Control Register Symbol FRA0 Bit Symbol FRA00 FRA01 — (b7-b2) NOTES: Set the PRC0 bit in the PRCR ...
Page 99
R8C/22 Group, R8C/23 Group High-Speed On-Chip Oscillator Control Register Symbol FRA2 Bit Symbol FRA20 FRA21 FRA22 — (b7-b3) NOTES: Set the PRC0 bit in the PRCR ...
Page 100
R8C/22 Group, R8C/23 Group CAN0 Clock Select Register Symbol CCLKR Bit Symbol CCLK0 CCLK1 CCLK2 CCLK3 — (b7-b4) NOTES: Set the PRC0 bit in the PRCR register to 1 (enables w riting) ...
Page 101
R8C/22 Group, R8C/23 Group The following describes the clocks generated by the clock generation circuit. 10.1 XIN Clock This clock is supplied by a XIN clock oscillation circuit. This clock is used as the clock source for the CPU and ...
Page 102
R8C/22 Group, R8C/23 Group 10.2 On-Chip Oscillator Clocks This clock is supplied by an on-chip oscillator. The on-chip oscillator contains a high-speed on-chip oscillator and a low-speed on-chip oscillator. Either an on-chip oscillator clock is selected by the FRA01 bit ...
Page 103
R8C/22 Group, R8C/23 Group 10.3 CPU Clock and Peripheral Function Clock There are two type clocks: a CPU clock to operate the CPU and a peripheral function clock to operate the peripheral functions. Refer to Figure 10.1 Clock Generation Circuit. ...
Page 104
R8C/22 Group, R8C/23 Group 10.3.8 fOCO128 fOCO128 is generated by fOCO divided-by-128. The clock fOCO128 is used for capture signal of timer RD (channel 0). Rev.2.00 Aug 20, 2008 Page 82 of 501 REJ09B0251-0200 10. Clock Generation Circuit ...
Page 105
R8C/22 Group, R8C/23 Group 10.4 Power Control There are three power control modes. All modes other than wait and stop modes are referred to as standard operating mode. 10.4.1 Standard Operating Mode Standard operating mode is further separated into three ...
Page 106
R8C/22 Group, R8C/23 Group 10.4.1.3 Low-Speed On-Chip Oscillator Mode If the CM14 bit in the CM1 register is set to 0 (low-speed on-chip oscillator on) or the FRA01bit in the FRA0 register is set to 0, the low-speed on-chip oscillator ...
Page 107
R8C/22 Group, R8C/23 Group 10.4.2.4 Exiting Wait Mode The MCU exits wait mode by a hardware reset or peripheral function interrupt. When using a hardware reset to exit wait mode, set the ILVL2 to ILVL0 bits for the peripheral function ...
Page 108
R8C/22 Group, R8C/23 Group FMR0 Register Time until Flash Memory is Activated (T1) FMSTP Bit 0 Period of system clock (flash memory × 12 cycles + 30 µ s (max.) operates) 1 Period of system clock (flash memory × 12 ...
Page 109
R8C/22 Group, R8C/23 Group 10.4.2.5 Reducing Internal Power Consumption Internal power consumption can be reduced by using low-speed on-chip oscillator mode. Figure 10.11 shows the Procedure for Enabling Reduced Internal Power Consumption Using VCA20 bit. When enabling reduced internal power ...
Page 110
R8C/22 Group, R8C/23 Group 10.4.3 Stop Mode Since the oscillator circuits stop in wait mode, the CPU clock and peripheral function clock stop and the CPU and peripheral functions clocked by these clocks stop operating. The least power required to ...
Page 111
R8C/22 Group, R8C/23 Group FMR0 Register Time until Flash Memory is Activated (T2) FMSTP Bit 0 Period of system clock (flash memory × 12 cycles + 30 µs (max.) operates) 1 Period of system clock (flash memory × 12 cycles ...
Page 112
R8C/22 Group, R8C/23 Group Figure 10.13 shows the State Transitions in Power Control Mode. State Transition in Power Control Mode Standard operating mode High-speed clock mode CM05 = 0 CM13 = 1 OCD2 = 0 Interrupt Wait mode CPU operation ...
Page 113
R8C/22 Group, R8C/23 Group 10.5 Oscillation Stop Detection Function The oscillation stop detection function is a function to detect the stop of the XIN clock oscillating circuit. The oscillation stop detection function can be enabled and disabled by the OCD0 ...
Page 114
R8C/22 Group, R8C/23 Group Table 10.6 Determining Interrupt Source for Oscillation Stop Detection, Watchdog Timer, Voltage Monitor 1, and Voltage Monitor 2 Interrupts Generated Interrupt Source Oscillation Stop Detection ((a) or (b)) Watchdog Timer Voltage Monitor 2 No Figure 10.14 ...
Page 115
R8C/22 Group, R8C/23 Group Interrupt sources judgment OCD3 = 1? (XIN clock stops) YES OCD1 = 0 (Oscillation stop detection (1) interrupt disable) Jump to oscillation stop detection interrupt process routine. NOTE: 1. This disables multiple oscillation stop detection interrupts. ...
Page 116
R8C/22 Group, R8C/23 Group 10.6 Notes on Clock Generation Circuit 10.6.1 Stop Mode When entering stop mode, set the FMR01 bit to “0” (CPU rewrite mode disabled) and the CM10 bit to “1” (stop mode). An instruction queue pre-reads 4 ...
Page 117
R8C/22 Group, R8C/23 Group 11. Protection Protection function protects important registers from being easily overwritten when a program runs out of control. Figure 11.1 shows the PRCR Register. The following lists the registers protected by the PRCR register. • Registers ...
Page 118
R8C/22 Group, R8C/23 Group 12. Interrupts 12.1 Interrupt Overview 12.1.1 Types of Interrupts Figure 12.1 shows the Interrupts. Software (non-maskable interrupt) Interrupt Hardware NOTES: 1. Peripheral function interrupts in the MCU are used to generate the peripheral interrupt ...
Page 119
R8C/22 Group, R8C/23 Group 12.1.2 Software Interrupts A software interrupt is generated when an instruction is executed. The software interrupts are non-maskable interrupts. 12.1.2.1 Undefined Instruction Interrupt The undefined instruction interrupt is generated when the UND instruction is executed. 12.1.2.2 ...
Page 120
R8C/22 Group, R8C/23 Group 12.1.3 Special Interrupts Special interrupts are non-maskable interrupts. 12.1.3.1 Watchdog Timer Interrupt The watchdog timer interrupt is generated by the watchdog timer. For details, refer to 13. Watchdog Timer. 12.1.3.2 Oscillation Stop Detection Interrupt Oscillation Stop ...
Page 121
R8C/22 Group, R8C/23 Group 12.1.5 Interrupts and Interrupt Vector There are 4 bytes in one vector. Set the starting address of interrupt routine in each vector table. When an interrupt request is acknowledged, the CPU branches to the address set ...
Page 122
R8C/22 Group, R8C/23 Group 12.1.5.2 Relocatable Vector Tables The relocatable vector tables occupy 256 bytes from the starting address set in the INTB register. Table 12.2 lists the Relocatable Vector Tables. Table 12.2 Relocatable Vector Tables Vector Address Interrupt Source ...
Page 123
R8C/22 Group, R8C/23 Group 12.1.6 Interrupt Control The following describes enable/disable the maskable interrupts and set the priority order to acknowledge. The contents explained does not apply to the nonmaskable interrupts. Use the I flag in the FLG register, IPL ...
Page 124
R8C/22 Group, R8C/23 Group (1) Interrupt Control Register Symbol TRD0IC TRD1IC SSUIC/IICIC Bit Symbol ILVL0 ILVL1 ILVL2 IR — (b7-b4) NOTES rew rite the interrupt control register, rew rite it ...
Page 125
R8C/22 Group, R8C/23 Group INTi Interrupt Control Register ( Symbol INT2IC INT1IC INT3IC INT0IC Bit Symbol ILVL0 ILVL1 ILVL2 IR POL — (b5) — (b7-b6) NOTES: 1. ...
Page 126
R8C/22 Group, R8C/23 Group 12.1.6.1 I Flag The I flag enables or disables the maskable interrupt. Setting the I flag to 1 (enabled) enables the maskable interrupt. Setting the I flag to 0 (disabled) disables all maskable interrupts. 12.1.6.2 IR ...
Page 127
R8C/22 Group, R8C/23 Group 12.1.6.4 Interrupt Sequence An interrupt sequence is performed between an interrupt request acknowledgement and interrupt routine execution. When an interrupt request is generated while an instruction is executed, the CPU determines its interrupt priority level after ...
Page 128
R8C/22 Group, R8C/23 Group 12.1.6.5 Interrupt Response Time Figure 12.7 shows an Interrupt Response Time. The interrupt response time is the period between an interrupt request generation and the execution of the first instruction in an interrupt routine. An interrupt ...
Page 129
R8C/22 Group, R8C/23 Group 12.1.6.7 Saving a Register In the interrupt sequence, the FLG register and PC are saved to the stack. After 4 high-order bits in the PC and 4 high-order (IPL) and 8 low-order bits in the FLG ...
Page 130
R8C/22 Group, R8C/23 Group 12.1.6.8 Returning from an Interrupt Routine When the REIT instruction is executed at the end of an interrupt routine, the FLG register and PC, which have been saved to the stack, are automatically returned. The program, ...
Page 131
R8C/22 Group, R8C/23 Group 12.1.6.10 Interrupt Priority Judgement Circuit The interrupt priority judgement circuit selects the highest priority interrupt. Figure 12.11 shows the Interrupt Priority Level Judgement Circuit. Priority level of each interrupt INT3 Timer RB Timer RA CAN0 error ...
Page 132
R8C/22 Group, R8C/23 Group 12.2 INT Interrupt 12.2.1 INTi Interrupt ( The INTi interrupt is generated by an INTi input. When using the INTi interrupt, the INTiEN bit in the INTEN register is set to 1 ...
Page 133
R8C/22 Group, R8C/23 Group _____ INT Input Filter Select Register Symbol INTF Bit Symbol INT0F0 INT0F1 INT1F0 INT1F1 INT2F0 INT2F1 INT3F0 INT3F1 Figure 12.13 INTF Register Rev.2.00 Aug 20, 2008 Page 111 ...
Page 134
R8C/22 Group, R8C/23 Group 12.2.2 INTi Input Filter ( The INTi input contains a digital filter. The sampling clock is selected by the INTiF1 to INTiF0 bits in the INTF register. The IR bit in the ...
Page 135
R8C/22 Group, R8C/23 Group 12.3 Key Input Interrupt A key input interrupt request is generated by one of the input edges of the K10 to K13 pins. The key input interrupt can be used as a key-on wake-up function to ...
Page 136
R8C/22 Group, R8C/23 Group (1) Key Input Enable Register Symbol KIEN Bit Symbol KI0EN KI0PL KI1EN KI1PL KI2EN KI2PL KI3EN KI3PL NOTE: 1. The IR bit in the KUPIC register may be ...
Page 137
R8C/22 Group, R8C/23 Group 12.4 CAN0 Wake-Up Interrupt A CAN0 wake-up interrupt request is generated by a falling edge of the CRX pin. The CAN0 wake-up interrupt is enabled when the PortEn bit is 1 (CTX/CRX function) and Sleep bit ...
Page 138
R8C/22 Group, R8C/23 Group 12.5 Address Match Interrupt An address match interrupt request is generated immediately before executing the instruction at the address indicated by the RMADi register ( 1). This interrupt is used for a break ...
Page 139
R8C/22 Group, R8C/23 Group Address Match Interrupt Enable Register Symbol AIER Bit Symbol AIER0 AIER1 — (b7-b2) Address Match Interrupt Register (b23) (b19) (b16) (b15) b7 ...
Page 140
R8C/22 Group, R8C/23 Group 12.6 Timer RD Interrupt, Clock Synchronous Serial I/O with Chip Select Interrupts 2 and I C bus Interface Interrupts (Interrupts with Multiple Interrupt Request Sources) Timer RD (channel 0), timer RD (channel 1), clock synchronous serial ...
Page 141
R8C/22 Group, R8C/23 Group Controlling an interrupt with the I flag, IR bit, ILVL0 to ILVL2 bits and IPL by Timer RD (channel 0), Timer RD (channel 1), clock synchronous serial I/O with chip select and I maskable interrupts. However, ...
Page 142
R8C/22 Group, R8C/23 Group 12.7 Notes on Interrupts 12.7.1 Reading Address 00000h Do not read the address 00000h by a program. When a maskable interrupt request is acknowledged, the CPU reads interrupt information (interrupt number and interrupt request level) from ...
Page 143
R8C/22 Group, R8C/23 Group 12.7.4 Changing Interrupt Sources The IR bit in the interrupt control register may be set to 1 (interrupt requested) when the interrupt source changes. When using an interrupt, set the IR bit to 0 (no interrupt ...
Page 144
R8C/22 Group, R8C/23 Group 12.7.5 Changing Interrupt Control Register Contents (a) Each interrupt control register can only be changed while interrupt requests corresponding to that register are not generated. If interrupt requests may be generated, disable the interrupts before changing ...
Page 145
R8C/22 Group, R8C/23 Group 13. Watchdog Timer The watchdog timer is a function to detect when the program is out of control. To use the watchdog timer is recommend for improving reliability of a system. The watchdog timer contains a ...
Page 146
R8C/22 Group, R8C/23 Group Option Function Select Register Symbol OFS Bit Symbol WDTON — (b1) ROMCR ROMCP1 — (b5-b4) LVD1ON CSPROINI NOTES: 1. The OFS register is on the ...
Page 147
R8C/22 Group, R8C/23 Group Watchdog Timer Reset Register b7 b0 Symbol WDTR When w riting 00h before w riting FFh, the w atchdog timer is reset. The default value of the w atchdog timer is set to 7FFFh w hen ...
Page 148
R8C/22 Group, R8C/23 Group 13.1 Count Source Protection Mode Disabled The count source of the watchdog timer is the CPU clock when count source protection mode is disabled. Table 13.2 lists the Watchdog Timer Specifications (with Count Source Protection Mode ...
Page 149
R8C/22 Group, R8C/23 Group 13.2 Count Source Protection Mode Enabled The count source of the watchdog timer is the low-speed on-chip oscillator clock when count source protection mode is enabled. If the CPU clock stops when the program is out ...
Page 150
R8C/22 Group, R8C/23 Group 14. Timers The MCU contains two 8-bit timers with 8-bit prescaler, two 16-bit timers, and a timer with a 4-bit counter, and an 8- bit counter. The two 8-bit timers with the 8-bit prescaler contain timer ...
Page 151
R8C/22 Group, R8C/23 Group Table 14.1 Functional Comparison of Timers Item Configuration Count Count Sources Function Timer mode Pulse output mode Event counter mode Pulse width measurement mode Pulse period measurement mode Programmable waveform generation mode Programmable one- shot generation ...
Page 152
R8C/22 Group, R8C/23 Group 14.1 Timer RA Timer 8-bit timer with an 8-bit prescaler. The prescaler and timer consist of the reload register and counter. The reload register and counter are allocated at the same address. When ...
Page 153
R8C/22 Group, R8C/23 Group (4) Timer RA Control Register Symbol TRACR Bit Symbol TSTART TCSTF TSTOP — (b3) TEDGF TUNDF — (b7-b6) NOTES: 1. Refer to 14.1.6 Notes on Tim er RA ...
Page 154
R8C/22 Group, R8C/23 Group (1) Timer RA Mode Register Symbol TRAMR Bit Symbol TMOD0 TMOD1 TMOD2 — (b3) TCK0 TCK1 TCK2 TCKCUT NOTE: 1. When both the TSTART and TCSTF bits in ...
Page 155
R8C/22 Group, R8C/23 Group Timer RA Register b7 b0 Symbol Mode All Modes NOTE: 1. When the TSTOP bit in the TRACR register is set to 1, the TRA register is set to FFh. Figure 14.4 TRA Register Rev.2.00 Aug ...
Page 156
R8C/22 Group, R8C/23 Group 14.1.1 Timer Mode In this mode, the timer counts an internally generated count source (see Table 14.2 Timer Mode Specifications). Figure 14.5 shows the TRAIOC Register in Timer Mode. Table 14.2 Timer Mode Specifications Item Count ...
Page 157
R8C/22 Group, R8C/23 Group 14.1.1.1 Timer Write Control during Count Operation Timer RA has a prescaler and a timer (which counts the prescaler underflows). The prescaler and timer each consist of a reload register and a counter. When writing to ...
Page 158
R8C/22 Group, R8C/23 Group 14.1.2 Pulse Output Mode Pulse output mode is mode to count the count source internally generated and outputs the pulse which inverts the polarity from the TRAIO pin each time the timer underflows (see Table 14.3 ...
Page 159
R8C/22 Group, R8C/23 Group Timer RA I/O Control Register Symbol TRAIOC Bit Symbol TEDGSEL TOPCR TOENA TIOSEL TIPF0 TIPF1 — (b7-b6) Figure 14.7 TRAIOC Register in Pulse Output Mode Rev.2.00 ...
Page 160
R8C/22 Group, R8C/23 Group 14.1.3 Event Counter Mode Event counter mode is mode to count an external signal which inputs from the INT1/TRAIO pin (see Table 14.4 Event Counter Mode Specifications). Figure 14.8 shows the TRAIOC Register in Event Counter ...
Page 161
R8C/22 Group, R8C/23 Group Timer RA I/O Control Register Symbol TRAIOC Bit Symbol TEDGSEL TOPCR TOENA TIOSEL TIPF0 TIPF1 — (b7-b6) NOTE: 1. When the same value from the TRAIO pin ...
Page 162
R8C/22 Group, R8C/23 Group 14.1.4 Pulse Width Measurement Mode Pulse width measurement mode is mode to measure the pulse width of an external signal which inputs from the INT1/TRAIO pin (see Table 14.5 Pulse Width Measurement Mode Specifications). Figure 14.9 ...
Page 163
R8C/22 Group, R8C/23 Group Timer RA I/O Control Register Symbol TRAIOC Bit Symbol TEDGSEL TOPCR TOENA TIOSEL TIPF0 TIPF1 — (b7-b6) NOTE: 1. When the same value from the TRAIO ...
Page 164
R8C/22 Group, R8C/23 Group n = high-level: the contents of TRA register, low-level: the contents of TRAPRE register FFFFh n 0000h Set program 1 TSTART bit in TRACR register 0 1 Measurement pulse (TRAIO pin input) 0 ...
Page 165
R8C/22 Group, R8C/23 Group 14.1.5 Pulse Period Measurement Mode Pulse period measurement mode is mode to measure the pulse period of an external signal which inputs from the INT1/TRAIO pin (see Table 14.6 Pulse Period Measurement Mode Specifications). Figure 14.11 ...
Page 166
R8C/22 Group, R8C/23 Group Timer RA I/O Control Register Symbol TRAIOC Bit Symbol TEDGSEL TOPCR TOENA TIOSEL TIPF0 TIPF1 — (b7-b6) NOTE: 1. When the same value from the TRAIO ...
Page 167
R8C/22 Group, R8C/23 Group Underflow signal of timer RA prescaler Set program 1 TSTART bit in TRACR register 0 Starts counting 1 Measurement pulse (TRAIO pin input) 0 Contents of TRA Contents of read-out (1) buffer 1 ...
Page 168
R8C/22 Group, R8C/23 Group 14.1.6 Notes on Timer RA • Timer RA stops counting after reset. Set the value to timer RA and timer RA prescaler before the count starts. • Even if the prescaler and timer RA is read ...
Page 169
R8C/22 Group, R8C/23 Group 14.2 Timer RB Timer 8-bit timer with an 8-bit prescaler. The prescaler and timer consist of the reload register and counter. (Refer to Table 14.7 to 14.10 the Specification of Each Modes). Timer ...
Page 170
R8C/22 Group, R8C/23 Group Timer RB Control Register Symbol TRBCR Bit Symbol TSTART TCSTF TSTOP — (b7-b3) NOTES: 1. Refer to 14.2.5 Notes on Tim When the TSTOP ...
Page 171
R8C/22 Group, R8C/23 Group Timer RB I/O Control Register Symbol TRBIOC Bit Symbol TOPL TOCNT INOSTG INOSEG — (b7-b4) Timer RB Mode Register Symbol ...
Page 172
R8C/22 Group, R8C/23 Group Timer RB Prescaler Register b7 b0 Timer mode Programmable w aveform generation mode Programmable one-shot generation mode Programmable w ait one-shot generation mode NOTE: 1. When the TSTOP bit in the TRBCR register is set to ...
Page 173
R8C/22 Group, R8C/23 Group 14.2.1 Timer Mode Timer mode is mode to count a count source which is internally generated or timer RA underflow (see Table 14.7 Timer Mode Specifications). The TRBOCR and TRBSC registers are unused in timer mode. ...
Page 174
R8C/22 Group, R8C/23 Group 14.2.1.1 Timer Write Control during Count Operation Timer RB has a prescaler and a timer (which counts the prescaler underflows). The prescaler and timer each consist of a reload register and a counter. In timer mode, ...
Page 175
R8C/22 Group, R8C/23 Group When the TWRC bit is set to 0 (write to reload register and counter) Set 01h to the TRBPRE register and 25h to the TRBPR register by a program. Count source Reloads register of Previous value ...
Page 176
R8C/22 Group, R8C/23 Group 14.2.2 Programmable Waveform Generation Mode Programmable waveform generation mode is mode to invert the signal output from the TRBO pin each time the counter underflows, while the values in the TRBPR and TRBSC registers are counted ...
Page 177
R8C/22 Group, R8C/23 Group Timer RB I/O Control Register Symbol TRBIOC Bit Symbol TOPL TOCNT INOSTG INOSEG — (b7-b4) Figure 14.19 TRBIOC Register in Programmable Waveform Generation Mode Rev.2.00 Aug ...
Page 178
R8C/22 Group, R8C/23 Group 1 TSTART bit in TRBCR register 0 Count source Timer RB prescaler underflow signal Counter of timer bit in TRBIC register 0 1 TOPL bit in TRBIO register 0 1 TRBO pin output ...
Page 179
R8C/22 Group, R8C/23 Group 14.2.3 Programmable One-shot Generation Mode Programmable one-shot generation mode is mode to output the one-shot pulse from the TRBO pin by a program or an external trigger input (input to the INT0 pin) (see Table 14.9 ...
Page 180
R8C/22 Group, R8C/23 Group Timer RB I/O Control Register Symbol TRBIOC Bit Symbol TOPL TOCNT INOSTG INOSEG — (b7-b4) NOTE: 1. Refer to 14.2.3.1 One-shot Trigger Selection . Figure 14.21 TRBIOC ...
Page 181
R8C/22 Group, R8C/23 Group 1 TSTART bit in TRBCR register 0 Set program 1 TOSSTF bit in TRBOCR register 0 INT0 pin input Count source Timer RB prescaler underflow signal Counter of timer bit ...
Page 182
R8C/22 Group, R8C/23 Group 14.2.3.1 One-Shot Trigger Selection In programmable one-shot generation mode and programmable wait one-shot generation mode, operation starts when a one-shot trigger is generated while the TCSTF bit in the TRBCR register is set to 1 (count ...
Page 183
R8C/22 Group, R8C/23 Group 14.2.4 Programmable Wait One-shot Generation Mode Programmable wait one-shot generation mode is mode to output the one-shot pulse from the TRBO pin by a program or an external trigger input (input to the INT0 pin) (see ...
Page 184
R8C/22 Group, R8C/23 Group Table 14.10 Programmable Wait One-Shot Generation Mode Specifications Item Count Sources Count Operations Wait Time One-Shot Pulse Output Time (n+1)(p+1)/fi Count Start Conditions Count Stop Conditions Interrupt Request Generation Timing TRBO Pin Function INT0 Pin Functions ...
Page 185
R8C/22 Group, R8C/23 Group Timer RB I/O Control Register Symbol TRBIOC Bit Symbol TOPL TOCNT INOSTG INOSEG — (b7-b4) NOTE: 1. Refer to 14.2.3.1 One-shot Trigger Selection. Figure 14.23 TRBIOC Register ...
Page 186
R8C/22 Group, R8C/23 Group 1 TSTART bit in TRBCR register 0 1 TOSSTF bit in TRBOCR register 0 INT0 pin input Count source Timer RB prescaler underflow signal Counter of timer bit in TRBIC register 0 1 ...
Page 187
R8C/22 Group, R8C/23 Group 14.2.5 Notes on Timer RB • Timer RB stops counting after reset. Set the value to timer RB and timer RB prescaler before the count starts. • Even if the prescaler and timer RB is read ...
Page 188
R8C/22 Group, R8C/23 Group 14.2.5.2 Programmable waveform generation mode The following three workarounds should be performed in programmable waveform generation mode. (1) To write to registers TRBPRE and TRBPR during count operation (TCSTF bit is set to 1), note the ...
Page 189
R8C/22 Group, R8C/23 Group • Workaround example (b): As shown in Figure 14.26 detect the start of the primary period by the TRBO pin output level and write to registers TRBSC and TRBPR. These write operations must be completed by ...
Page 190
R8C/22 Group, R8C/23 Group 14.2.5.4 Programmable wait one-shot generation mode The following three workarounds should be performed in programmable wait one-shot generation mode. (1) To write to registers TRBPRE and TRBPR during count operation (TCSTF bit is set to 1), ...
Page 191
R8C/22 Group, R8C/23 Group 14.3 Timer RD Timer RD has 2 16-bit timers (channels 0 and 1). Each channel has 4 I/O pins. The operation clock of Timer fOCO40M. Table 14.11 lists the Timer RD Operation ...
Page 192
R8C/22 Group, R8C/23 Group Table 14.12 Pin Functions TRDIOA0/TRDCLK(P2_0) Register TRDOER1 TRDFCR Bit EA0 PWM3 STCLK CMD1, CMD0 IOA3 IOA2_IOA0 Setting 1 0 value Other than above X: can be 0 ...
Page 193
R8C/22 Group, R8C/23 Group Table 14.15 Pin Functions TRDIOD0(P2_3) Register TRDOER1 TRDFCR Bit ED0 PWM3 CMD1, CMD0 Setting value Other than above X: can change ...
Page 194
R8C/22 Group, R8C/23 Group Table 14.18 Pin Functions TRDIOC1(P2_6) Register TRDOER1 TRDFCR Bit EC1 PWM3 CMD1, CMD0 Setting value Other than above X: can change ...
Page 195
R8C/22 Group, R8C/23 Group Channel i TRDi register TRDGRAi register TRDGRBi register TRDGRCi register TRDGRDi register TRDDFi register TRDCRi register TRDIORAi register TRDIORCi register TRDSRi register TRDIERi register TRDPOCRi register TRDSTR register TRDMR register TRDPMR register TRDFCR register TRDOER1 register ...
Page 196
R8C/22 Group, R8C/23 Group 14.3.1 Count Source The count source selection can be used in all modes. However, in PWM3 mode, the external clock cannot be selected. Table 14.21 Count Source Selection Count Source f1, f2, f4, f8, f32 The ...
Page 197
R8C/22 Group, R8C/23 Group 14.3.2 Buffer Operation The TRDGRCi register can be used as the buffer register of the TRDGRAi register, and the TRDGRDi register can be used as the buffer register of the TRDGRBi register by the BFCi and ...
Page 198
R8C/22 Group, R8C/23 Group TRDGRCi register (buffer) TRDi register TRDGRAi register TRDGRCi register (buffer) TRDIOAi output The above applies to the following conditions: • BFCi bit in the TRDMR register is set to 1. (The ...
Page 199
R8C/22 Group, R8C/23 Group 14.3.3 Synchronous Operation The TRD1 register is synchronized with the TRD0 register. • Synchronous preset When the SYNC bit in the TRDMR register is set to 1 (synchronous operation), the data is written to both the ...
Page 200
R8C/22 Group, R8C/23 Group 14.3.4 Pulse Output Forced Cutoff In the output compare function, PWM mode, reset synchronous PWM mode, complementary PWM mode and PWM3 mode, the TRDIOji output pin can be forcibly set to the programmable I/O port by ...