
S3C821A/P821A
CLOCK CIRCUITS
7-5
SWITCHING THE CPU CLOCK
Data loadings in the system clock control register, CLKCON, determine whether a main or a sub clock is selected
as the CPU clock, the system clock for peripheral hardware, and also how this frequency is to be divided. This
makes it possible to switch dynamically between main and sub clocks and to modify operating frequencies.
CLKCON.2–.0 select the main clock (fx) or a sub clock (fxt). CLKCON.6–.5 start or stop main clock oscillation.
CLKCON.4–.3 control the frequency divider circuit, and divide the selected fx clock by 1, 2, 8, or 16, or fxt clock
by 1.
Let's say that, you are using the default CPU clock (normal operating mode and a main clock of fx/16) and you
want to switch from the fx clock to a sub clock and to stop the main clock. To do this, you need to set
CLKCON.2–.0 to "101B" and CLKCON.6–.5 to "10B" simultaneously. This switches the clock from fx to fxt and
stops main clock oscillation.
The following steps must be taken to switch from a sub clock to the main clock: first, set CLKCON.6–.5 to any
value except "10B" to enable main system clock oscillation. Then, after a certain number of machine cycles has
elapsed, select the main clock by setting CLKCON.2–.0 to any value except "101B". You must remember that
the selected clock (fxx) for the basic timer, timer counter 0/1, watch timer, and A/D converter is the main clock
during the interval time. Refer to "Figure 7-6. System Clock Circuit Diagram."
+
+ PROGRAMMING TIP — Switching the CPU Clock
1. This example shows how to change from the main clock to the sub clock:
MA2SUB
LD
CLKCON,#5DH
; Switches to the sub clock
; Stop the main clock oscillation
RET
2. This example shows how to change from the sub clock to the main clock:
SUB2MA
AND
CLKCON,#9FH
; Start the main clock oscillation
CALL
DLY20
; Delay 20 ms
AND
CLKCON,#98H
; Switch to the main clock
RET
DLY20
SRP
#0C0H
LD
R0,#1BH
DEL
NOP
DJNZ
R0,DEL
RET