Application Note
R01AN5984EJ0100 Rev.1.00 Page 1 of 30
May.31.22
RL78/G1M, RL78/G1N
Software Development Using Code Generation tools of RL78/G10
Introduction
This application note shows how to develop RL78G1M orRL78/G1N programs using RL78/G10 code
generation.
Code generation tools refer to the RL78 code generation plug-in (CG) when using the C compiler CC-RL or
"AP4 for RL78 (AP4)" when using IAR's C compiler.
Target Device
RL78/G1M, RL78G1N
RL78/G1M, /G1N Software Development Using CS+ Code Generation of RL78/G10
R01AN5984EJ0100 Rev.1.00 Page 2 of 30
May.31.22
Contents
1. Specifications .......................................................................................................................... 3
1.1 Specification Outline ................................................................................................................................ 3
1.2 Development Procedure Overview .......................................................................................................... 3
2. Development Procedure Details .............................................................................................. 4
2.1 Create RL78/G1M or RL78/G1N Project ................................................................................................. 4
2.2 Create a G10 Project and generate CG output ....................................................................................... 4
2.3 Modify Functions to be Used ................................................................................................................... 5
2.3.1 Port Configuration Function ................................................................................................................... 5
2.3.2 Clock Generator .................................................................................................................................... 6
2.3.3 Timer array unit ..................................................................................................................................... 7
2.3.4 12-Bit Interval Timer .............................................................................................................................. 8
2.3.5 Clock Output/Buzzer Output Control Circuit .......................................................................................... 8
2.3.6 Watchdog Timer .................................................................................................................................... 9
2.3.7 A/D converter ......................................................................................................................................... 9
2.3.8 Serial Array Unit .................................................................................................................................. 11
2.3.9 Real-Time Output Control (G1M Only) ................................................................................................ 13
2.3.10 Interrupt Functions (INTPx) ................................................................................................................. 14
2.3.11 Key Interrupt Function ......................................................................................................................... 17
2.4 Modify Initial Setting Functions .............................................................................................................. 18
2.5 Create the main function ....................................................................................................................... 19
2.6 Option Byte Setting................................................................................................................................ 19
2.7 Precautions When Creating User Programs ......................................................................................... 19
3. Application Development Example ........................................................................................ 20
3.1 Conditions for Operation Confirmation .................................................................................................. 20
3.2 Hardware Conf ig ur ati on Ex amp le ......................................................................................................... 21
3.3 List of Pins Used .................................................................................................................................... 21
3.4 Software Description ............................................................................................................................. 22
3.4.1 Option Bytes ........................................................................................................................................ 22
3.4.2 Flowchart ............................................................................................................................................. 22
3.5 Developm ent Pr oced ur e ........................................................................................................................ 25
3.5.1 Developing the initial setting functions (r_cg_systeminit.c) ................................................................. 25
3.5.2 Developing System Functions ............................................................................................................. 26
3.5.3 Developing the main Function (r_cg_main.c) ...................................................................................... 28
3.5.4 Build ..................................................................................................................................................... 29
4. Sample codes ........................................................................................................................ 30
5. Reference .............................................................................................................................. 30
Revision His tory ............................................................................................................................ 30