
8. Clock Generation Circuits
8.1.3
On-Chip Oscillator Clock
On-chip oscillator generates the 1-MHz on-chip oscillator clock. The on-chip oscillator clock becomes the
clock source for the CPU clock and peripheral function clock.
The on-chip oscillator clock stops after reset. When the CM21 bit in the CM2 register is set to 1 (on-chip
oscillator clock), the on-chip oscillator starts oscillating and becomes the clock source for the CPU clock and
peripheral function clock, in place of the main clock.
Table 8.2 lists bit settings for on-chip oscillator start condition.
: Can be set to either 0 or 1
8.1.3.1
Oscillation Stop Detect Function
When the main clock is terminated running by an external factor, the on-chip oscillator automatically starts
oscillating.
When the CM 20 bit in the CM2 register is set to 1 (oscillation stop detect function enabled), an oscillation stop
detection interrupt request is generated as soon as the main clock stops. Simultaneously, the on-chip oscillator
starts oscillating. The on-chip oscillator clock takes the place of the main clock as the CPU clock and peripheral
function clock. Associated bits in the CM2 register are changed as follows:
CM21 bit is set to 1 (on-chip oscillator clock becomes the CPU clock)
CM22 bit is set to 1 (loss of main clock is detected)
CM23 bit is set to 1 (main clock stops)
The oscillation stop detection interrupt shares a vector with the watchdog timer interrupt. When these interrupts
are used simultaneously, verify the CM22 bit within an interrupt routine to determine if an oscillation stop
detection interrupt request has been generated. When the main clock resumes running after a loss of the main
clock is detected, the main clock can be selected as the CPU clock and peripheral function clock by program.
Figure 8.12 shows the procedure to switch the clock source from the on-chip oscillator clock to the main clock.
In low-speed mode, when the main clock is stopped while the CM20 bit is set to 1, an oscillation stop detection
interrupt request is generated, and the on-chip oscillator starts oscillating. The sub clock remains as the CPU
clock. The on-chip oscillator clock becomes the peripheral function clock.
When the peripheral function clock stops running, the oscillation stop detect function is also disabled. To enter
wait mode while using the oscillation stop detect function, set the CM02 bit in the CM0 register to 0 (peripheral
clock does not stop in wait mode).
The oscillation stop detect function is a function for cases where the main clock is stopped by an external factor.
Set the CM20 bit to 0 (oscillation stop detect function disabled) when the main clock is terminated by program,
i.e., entering stop mode or setting the CM05 bit in the CM0 register to 1 (main clock oscillation stop).
When the main clock frequency is 2 MHz or lower, the oscillation stop detect function is not available. In this
case, set the CM20 bit to 0.
Table 8.2
Bit Settings for On-Chip Oscillator Start Condition
CM2 register
PM2 register
Applications
CM21 bit
PM22 bit
PM27 to PM26
1
Clock source for the CPU clock and peripheral function clock
1
Count source for the watchdog timer
Does not stop in stop mode
10b
Count source for f2n