Usage Notes
MC68HC908GT16 MC68HC908GT8 MC68HC08GT16 Data Sheet, Rev. 5.0
Freescale Semiconductor
89
7.4.1 Switching Clock Sources
Switching from one clock source to another requires both clock sources to be enabled and stable.
A simple flow requires:
Enable desired clock source
Wait for it to become stable
Switch clocks
Disable previous clock source
The key point to remember in this flow is that the clock source cannot be switched (CS cannot be written)
unless the desired clock is on and stable. A short assembly code example of how to employ this flow is
shown in
Figure 7-9
.
;* Clock Switching Code Example
;* This code switches from internal to external clock
;* Clock monitor and interrupts are not enabled
;* ICG Clock Switch
SwitchItoE:
bset ECGON,ICGCR ; turn on external oscillator
brclr ECGS,ICGCR,* ; wait until external clock engaged
bset CS,ICGCR ; select external clock for bus
bclr ICGON,ICGCR ; turn off internal clock (if desired)
Figure 7-9. Code Example for Switching Clock Sources
7.4.2 Enabling the Clock Monitor
Many applications require the clock monitor to determine if one of the clock sources has become inactive,
so the other can be used to recover from a potentially dangerous situation. Using the clock monitor
requires both clocks to be active (ECGON and ICGON both set). To enable the clock monitor, both clocks
also must be stable (ECGS and ICGS both set). This is to prevent the use of the clock monitor when a
clock is first turned on and potentially unstable.
Enabling the clock monitor and clock monitor interrupts requires a flow similar to this:
Enable the alternate clock source
Wait for both clock sources to be stable
Switch to the desired clock source if necessary
Enable the clock monitor
Enable clock monitor interrupts
These events must happen in sequence. A short assembly code example of how to employ this flow is
shown in
Figure 7-10
.