Switching the cpu clock, Programming tip ⎯ switching the cpu clock – Samsung S3C8275X User Manual
Page 228
S3C8275X/F8275X/C8278X/F8278X/C8274X/F8274X
CLOCK
CIRCUIT
7-7
SWITCHING THE CPU CLOCK
Data loading in the oscillator control register, OSCCON, determine whether a main or a sub clock is selected as
the CPU clock, and also how this frequency is to be divided by setting CLKCON. This makes it possible to switch
dynamically between main and sub clocks and to modify operating frequencies.
OSCCON.0 select the main clock (fx) or the sub clock (fxt) for the CPU clock. OSCCON.3 start or stop main clock
oscillation, and OSCCON.2 start or stop sub clock oscillation. CLKCON.4
−.3 control the frequency divider circuit,
and divide the selected fxx clock by 1, 2, 8, 16.
For example, 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.4-
.3 to "11", OSCCON.0 to “1”, and OSCCON.3 to “1” 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 OSCCON.3 to “0” to
enable main clock oscillation. Then, after a certain number of machine cycles has elapsed, select the main clock
by setting OSCCON.0 to “0”.
)
PROGRAMMING TIP
⎯ Switching the CPU clock
1. This example shows how to change from the main clock to the sub clock:
MA2SUB
LD
OSCCON,#01H
;
Switches to the sub clock
; Stop the main clock oscillation
RET
2. This example shows how to change from sub clock to main clock:
SUB2MA
AND
OSCCON,#07H
; Start the main clock oscillation
CALL
DLY16
; Delay 16 ms
AND
OSCCON,#06H
; Switch to the main clock
RET
DLY16 SRP
#0C0H
LD
R0,#20H
DEL
NOP
DJNZ R0,DEL
RET