RL78/G13 Clock Generator (Clock Switching) CC-RL
R01AN2831EJ0100 Rev. 1.00 Page 25 of 51
May 28, 2015
5.8.4 CPU Clock Setup
Figure 5.5 shows the flowchart for setting up the CPU clock.
Figure 5.5 CPU Clock Setup
Remarks: CPU clock setup (R_CGC_Create()) determines whether stabilization of subsystem clock oscillation is
completed within a waiting period (about 1 second). This period is specified with constant
CGC_SUBWAITTIME in r_cg_cgc.h.
Caution: For details on the procedure for setting up the CPU clock (R_CGC_Create ()), refer to the section entitled
"Flowcharts" in RL78/G13 Initialization Application Note (R01AN2575E).
R_CGC_Create
return
Set up high-speed system
clock/subsystem clock
CMC register
51H:
X1 oscillation mode of high-speed system clock
XT1 oscillation mode of subsystem clock
Low power consumption oscillation mode of XT1 oscillator
X1 oscillator (fx): 10 MHz < fx 20 MHz
fx: X1 clock oscillation frequency
Set stop of X1 oscillator
CSC register
MSTOP 1
Set up XT1 oscillato
Wait for XT1 oscillator to
get stabilized
Set up operating speed mode
Select CPU/peripheral hardware
clock (f
CLK
) as f
Main
Select HOCO as main system
clock (f
MAIN
)
Set up HOCO
CKC register
MCM0 0
CSC register
XTSTOP 0
Wait for 1 s
OSMC register
00H:
Enable subsystem clock to be supplied to peripheral functions.
Select subsystem clock as real-time clock and interval timer
operation clock.
CKC register
CSS 0
CSC register
XIOSTOP 0