
RL78/G13 Clock Generator (Clock Switching) CC-RL
R01AN2831EJ0100 Rev. 1.00 Page 2 of 51
May 28, 2015
Contents
1. Specifications......................................................................................................................................4
2. Operation Check Conditions.................................................................................................................6
3. Related Application Note......................................................................................................................6
4. Description of the Hardware.................................................................................................................7
4.1 Hardware Configuration Example .........................................................................................................7
4.2 List of Pins to be Used .........................................................................................................................8
5. Software Description............................................................................................................................9
5.1 Operation Overview.............................................................................................................................9
5.2 File Configuration..............................................................................................................................10
5.3 List of Option Byte Settings................................................................................................................11
5.4 List of Constants................................................................................................................................12
5.5 List of Variables................................................................................................................................13
5.6 List of Functions................................................................................................................................13
5.7 Function Specifications ......................................................................................................................14
5.8 Flowcharts ........................................................................................................................................21
5.8.1 Initialization Function..............................................................................................................................22
5.8.2 System Function......................................................................................................................................23
5.8.3 I/O Port Setup..........................................................................................................................................24
5.8.4 CPU Clock Setup.....................................................................................................................................25
5.8.5 Timer Array Unit 0 (TAU0) Setup..........................................................................................................29
5.8.6 Setting up 12-bit Interval Timer ..............................................................................................................30
5.8.7 Setting up External Interrupt Input..........................................................................................................31
5.8.8 Main Processing ......................................................................................................................................32
5.8.9 Setting to Start INTP0 External Interrupt Processing..............................................................................33
5.8.10 Setting to Start Operation of Channel 0 of TAU0 ...................................................................................34
5.8.11 Switching Clock ......................................................................................................................................35
5.8.12 Switching from HOCO Clock to X1 Oscillation Clock...........................................................................36
5.8.13 Switching from X1 Oscillation Clock to XT1 Oscillation Clock ............................................................37
5.8.14 Switching from XT1 Oscillation Clock to HOCO Clock ........................................................................38
5.8.15 Getting Clock Status................................................................................................................................39
5.8.16 Getting X1 Oscillation Clock Status........................................................................................................40
5.8.17 Getting XT1 Oscillation Clock Status .....................................................................................................41
5.8.18 Getting HOCO Clock Status....................................................................................................................42
5.8.19 Stopping Clock........................................................................................................................................43
5.8.20 Getting Parameters of Channel 0 of TAU0..............................................................................................44
5.8.21 Restarting Channel 0 of TAU0................................................................................................................45
5.8.22 Changing Interval of Channel 0 of TAU0 ...............................................................................................46
5.8.23 Setting to Stop Channel 0 of TAU0.........................................................................................................47
5.8.24 Processing of Interval Timer Interrupt of Channel 0 of TAU0................................................................48
5.8.25 Processing of INTP0 External Interrupt ..................................................................................................49
5.8.26 Waiting in Units of 1 ms..........................................................................................................................50
6. Sample Code.....................................................................................................................................51