Peripheral Simulation
For Silicon Laboratories, Inc. C8051F122 — Clock and Timer Rate Control
Simulation support for this peripheral or feature is comprised of:
- Dialog boxes which display and allow you to change peripheral configuration.
- VTREGs (Virtual Target Registers) which support I/O with the peripheral.
These simulation capabilities are described below.
Oscillator Control Dialog
The Oscillator Control Dialog controls the oscillator and timer
rate control for this controller. With this dialog, you control the
internal and external clocking to change clock and timer speeds.
Control Register
- CKCON contains the Timer Rate Control bits.
Clock Source
-
CLKSEL (Clock Select) contains the clock divisor
and clock source select control bits.
-
CLKDIV (Clock Divisor) selects the system clock
(SYSCLK) divisor (2, 4, or 8) for clock output.
-
CLKSL (Clock Select) determines the source input
(internal or external oscillator, or PLL) for the system clock
(SYSCLK).
Internal Oscillator Control
-
OSCICL (Internal Oscillator Calibration
Register) calibrates the internal oscillator. The value in
this register determines the internal oscillator base
frequency.
-
OSCICN (Internal Oscillator Control Register) controls
the internal oscillator and contains the following bits:
-
IOSCEN (Internal Oscillator Enable Bit) is set to enable
the internal oscillator.
-
IFRDY (Internal Oscillator Frequency Ready Flag) is set
when the internal oscillator frequency is running at the speed
specified by the IFCN bits.
-
IFCN (Internal Oscillator Frequency Control Bits)
divides the internal oscillator frequency by 8, 4, 2, or
1.
External Oscillator Control
-
OSCXCN (External Oscillator Control Register) controls
the external oscillator and contains the following bits:
-
XTLVLD (Crystal Oscillator Valid Flag) is set when the
crystal oscillator is running and stable.
-
XOSCMD (External Oscillator Mode Bits) control the
system clock divisor and the oscillator mode (RC/C).
-
XFCN (External Oscillator Frequency Control Bits)
selects the external oscillator frequency.
PLL
-
PLL0CN (PLL Control Register) controls the external
oscillator and contains the following bits:
-
PLLCK (PLL Lock Flag) indicates the PLL frequency is
locked.
-
PLLEN (PLL Enable) enable the PLL. The PLLPWR
bit must also be set.
-
PLLSRC (PLL Reference Clock Source Select) when set,
selects the external oscillator as a clock source, If rest, the
internal oscillator is used.
-
PLLPWR (PLL Power Enable) enables power (bias
generator) for the PLL.
-
PLL0DIV (PLL Pre-divider Register) contains the value to
be divided into the PLL reference clock.
-
PLL0MUL (PLL Multiplier) contains the
multiplication factor for the divided PLL reference clock.
-
PLL0FLT (PLL Filter Register) contains the
following control settings:
-
PLLICO (PLL Current-Controlled
Oscillator Control) selects the desired output frequency range
for the PLL.
-
PLLLP (PLL Loop Filter Control) selects the divided PLL
reference clock range.
Oscillators & CPU Clock
- XTAL Freq. contains the crystal frequency.
-
ROSC(kOhms) in RC circuit mode, contains the pull-up
resistor value in kOhms.
-
COSC(pF) in RC or C mode, contains the capacitance value
in picofarads.
-
VDD is the digital power supply value in
volts.
- CPU Clock displays the calculated clock rate.
CLOCK VTREG
Data Type: unsigned long
The CLOCK VTREG contains the speed of the microcontroller
instruction clock (in Hertz). This is effectively the number of
1-cycle instructions that the simulated microcontroller can execute
each second. This number is derived by dividing the oscillator
frequency (specified by the XTAL VTREG) by a fixed number (12 on
standard 8051 devices). The CLOCK VTREG can only be read. It cannot
be written. It is changed by changing the value of the XTAL VTREG or
by changing the clock divisor (which is not available on all
devices). Typing the CLOCK command in the debugger's Command Window
displays the current clock setting (in Hertz) in the Output
Window.
CLOCK
0x001E8480
The value 0x001E8480 is 2000000 (decimal) or 2 mHz.
COSC VTREG
Data Type: unsigned long
COSC is the capacitor value (in picofarads) for either RC or C
oscillator modes. Typing the following command in the debugger's
Command Window sets the capacitor value to 50 picofarads:
COSC = 50
Typing the COSC command in the debugger's Command Window displays
the current capacitor value setting (in hexidecimal) in the Output
Window:
COSC
0x00000032
ROSC VTREG
Data Type: float
ROSC is the pull-up resistor value (in kOhms) used when RC
Oscillator mode is selected. Typing the following command in the
debugger's Command Window sets the resistor value to 10k ohms:
ROSC = 10
Typing the ROSC command in the debugger's Command Window displays
the current resistor value setting (in decimal) in the Output
Window:
ROSC
10
VDD VTREG
Data Type: float
VDD is the digital supply voltage.
XTAL VTREG
Data Type: unsigned long
The XTAL VTREG contains the frequency of the oscillator (in Hertz)
used to drive the microcontroller. The value is automatically set
from the value specified in Project Options - Options for Target.
However, you may change the value of XTAL using the command window.
For example:
XTAL=12000000
You may also output the current value of XTAL using the
following:
XTAL
XTAL may be used in calculations to synchronize external scripts
with the simulated microcontroller.