Professional Documents
Culture Documents
14. Oscillators
C8051F34x devices include a programmable internal high-frequency oscillator, a programmable internal
low-frequency oscillator (C8051F340/1/2/3/4/5/8/9/A/B/C/D), an external oscillator drive circuit, and a 4x
Clock Multiplier. The internal high-frequency and low-frequency oscillators can be enabled/disabled and
adjusted using the special function registers, as shown in Figure 14.1. The system clock (SYSCLK) can be
derived from either of the internal oscillators, the external oscillator circuit, or the 4x Clock Multiplier divided
by 2. The USB clock (USBCLK) can be derived from the internal oscillator, external oscillator, or 4x Clock
Multiplier. Oscillator electrical specifications are given in Table 14.1.
SUSPEND
OSCLRDY
USBCLK2
USBCLK1
USBCLK0
OSCLEN
OSCLD1
OSCLD0
OSCLF3
OSCLF2
OSCLF1
OSCLF0
IOSCEN
CLKSL2
CLKSL1
CLKSL0
IFRDY
IFCN1
IFCN0
Option 2
VDD Option 3
XTAL2
EN
Programmable High- IOSC
n
XTAL2 Frequency Oscillator
OSCLF3-0
EN n
Programmable Low-
Frequency Oscillator
(C8051F340/1/2/3/4/5/8/9/ SYSCLK
Option 1 A/B/C/D)
XTAL1
Input EXOSC
10M: OSC
Circuit
XTAL2 IOSC
XTLVLD
EXOSC x2 x2
Option 4
XTAL2 IOSC / 2
EXOSC / 2 Clock Multiplier
EXOSC
USBCLK
XOSCMD2
XOSCMD1
XOSCMD0
MULSEL1
MULSEL0
EXOSC / 2
MULRDY
MULINIT
XTLVLD
MULEN
XFCN2
XFCN1
XFCN0
EXOSC / 3
EXOSC / 4
OSCXCN CLKMUL
USBCLK2-0
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- - - OSCCAL Variable
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address:
0xB3
Note: The contents of this register are undefined when Clock Recovery is enabled. See Section
16.4. USB Clock Configuration on page 166 for details on Clock Recovery.
Important Note on External Oscillator Usage: Port pins must be configured when using the external
oscillator circuit. When the external oscillator drive circuit is enabled in crystal/resonator mode, Port pins
P0.6 and P0.7 (C8051F340/1/4/5/8) or P0.2 and P0.3 (C8051F342/3/6/7/9/A/B) are used as XTAL1 and
XTAL2 respectively. When the external oscillator drive circuit is enabled in capacitor, RC, or CMOS clock
mode, Port pin P0.7 (C8051F340/1/4/5/8) or P0.3 (C8051F342/3/6/7/9/A/B) is used as XTAL2. The Port I/
O Crossbar should be configured to skip the Port pins used by the oscillator circuit; see Section
15.1. Priority Crossbar Decoder on page 144 for Crossbar configuration. Additionally, when using the
external oscillator circuit in crystal/resonator, capacitor, or RC mode, the associated Port pins should be
configured as analog inputs. In CMOS clock mode, the associated pin should be configured as a digital
input. See Section 15.2. Port I/O Initialization on page 147 for details on Port input mode selection.
When the crystal oscillator is first enabled, the oscillator amplitude detection circuit requires a settling time
to achieve proper bias. Introducing a delay of 1 ms between enabling the oscillator and checking the
XTLVLD bit will prevent a premature switch to the external oscillator as the system clock. Switching to the
external oscillator before the crystal oscillator has stabilized can result in unpredictable behavior. The rec-
ommended procedure is:
Important Note on External Crystals: Crystal oscillator circuits are quite sensitive to PCB layout. The
crystal should be placed as close as possible to the XTAL pins on the device. The traces should be as
short as possible and shielded with ground plane from any other traces which could introduce noise or
interference.
3 3
1.23 10 1.23 10
f = ------------------------ = -------------------------- = 0.1 MHz = 100 kHz
RC > 246 u 50 @
Referring to the table in SFR Definition 14.4, the required XFCN setting is 010b. Programming XFCN to a
higher setting in RC mode will improve frequency accuracy at an increased external oscillator supply cur-
rent.
14.3.4. External Capacitor Example
If a capacitor is used as an external oscillator for the MCU, the circuit should be configured as shown in
Figure 14.1, Option 3. The capacitor should be no greater than 100 pF; however for very small capacitors,
the total capacitance may be dominated by parasitic capacitance in the PCB layout. To determine the
required External Oscillator Frequency Control value (XFCN) in the OSCXCN Register, select the capaci-
tor to be used and find the frequency of oscillation from the equations below. Assume VDD = 3.0 V and C =
50 pF:
KF KF
f = ------------------------- = --------------------------------
C u VDD 50 x 3 MHz
KF
f = ----------------------
150 MHz
If a frequency of roughly 150 kHz is desired, select the K Factor from the table in SFR Definition 14.4 as
KF = 22:
22
f = --------- = 0.146 MHz, or 146 kHz
150
Therefore, the XFCN value to use in this example is 011b.
The 4x Clock Multiplier is configured via the CLKMUL register. The procedure for configuring and enabling
the 4x Clock Multiplier is as follows:
Important Note: When using an external oscillator as the input to the 4x Clock Multiplier, the exter-
nal source must be enabled and stable before the Multiplier is initialized. See Section 14.5 for
details on selecting an external oscillator source.
Some example USB clock configurations for Full and Low Speed mode are given below:
Internal Oscillator
Clock Signal Input Source Selection Register Bit Settings
USB Clock Clock Multiplier USBCLK = 000b
Clock Multiplier Input Internal Oscillator* MULSEL = 00b
Internal Oscillator Divide by 1 IFCN = 11b
External Oscillator
Clock Signal Input Source Selection Register Bit Settings
USB Clock Clock Multiplier USBCLK = 000b
Clock Multiplier Input External Oscillator MULSEL = 01b
Crystal Oscillator Mode XOSCMD = 110b
External Oscillator
12 MHz Crystal XFCN = 111b
*Note: Clock Recovery must be enabled for this configuration.
Internal Oscillator
Clock Signal Input Source Selection Register Bit Settings
USB Clock Internal Oscillator / 2 USBCLK = 001b
Internal Oscillator Divide by 1 IFCN = 11b
External Oscillator
Clock Signal Input Source Selection Register Bit Settings
Internal Oscillator
Clock Signal Input Source Selection Register Bit Settings
USB Clock External Oscillator / 4 USBCLK = 101b
Crystal Oscillator Mode XOSCMD = 110b
External Oscillator
24 MHz Crystal XFCN = 111b
R/W R/W R/W R/W R/W R/W R/W R/W Reset Value
- USBCLK - CLKSL 00000000
Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 SFR Address
0xA9