CLOCK CIRCUITS

S3C9228/P9228

 

 

SWITCHING THE CPU CLOCK

Data loadings 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 system 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, or 16.

For example, you are using the default system 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 OSCCON.0 to "1", take a delay, and OSCCON.3 to "1" sequently. 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 system 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 OR

OSCCON,#01H

; Switches to the sub clock

CALL

DLY16

;

Delay 16ms

OR

OSCCON,#08H

;

Stop the main clock oscillation

RET

 

 

 

2. This example shows how to change from sub clock to main clock:

SUB2MA

AND

OSCCON,#0F7H

; Start the main clock oscillation

 

CALL

DLY16

; Delay 16 ms

 

AND

OSCCON,#0FEH

; Switch to the main clock

 

RET

 

 

DLY16

LD

R0,#20H

 

DEL

NOP

 

 

 

DEC

R0

 

 

JR

NZ,DEL

 

 

RET

 

 

7-6

Page 152
Image 152
Samsung S3C9228/P9228, 8-Bit CMOS Microcontroller Switching the CPU Clock, +PROGRAMMING TIP Switching the CPU clock