Keil Logo

Peripheral Simulation

For Silicon Laboratories, Inc. C8051F351 — 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

Oscillator Control

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 following control bits:
  • T3MH (Timer 3 High Byte Clock Select) is set to have Timer 3 high byte use the system clock. If reset, the clock defined in TMR3CN is used.
  • T3ML (Timer 3 Low Byte Clock Select) is set to have Timer 3 low byte use the system clock. If reset, the clock defined in TMR3CN is used.
  • T2MH (Timer 2 High Byte Clock Select) is set to have Timer 2 high byte use the system clock. If reset, the clock defined in TMR2CN is used.
  • T2ML (Timer 2 Low Byte Clock Select) is set to have Timer 2 low byte use the system clock. If reset, the clock defined in TMR2CN is used.
  • T1M (Timer 1 Clock Select) is set to have Timer 1 use the system clock. If reset, the clock defined by the prescaler is used.
  • T0M (Timer 0 Clock Select) is set to have Timer 0 use the system clock. If reset, the clock defined by the prescaler is used.
  • SCA (Prescale Bits) selects the Timer 0 or Timer 1 clock divisor.

Clock Source

  • CLKSEL (Clock Select Register) contains the following clock source select bits:
  • SEL1 (System Clock Source Select) is set to generate the system clock from the internal low-frequency oscillator and scale it using the OSCLD setting in OSCLCN.
  • SEL0 (System Clock Source Select) is set to generate the system clock from the external oscillator.

Internal Oscillator Control

  • OSCICL (Internal H-F Oscillator Calibration Register) controls the internal oscillator period.
  • 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.
  • CLKSL (System Clock Source Select Bit) is set to use the external clock as the system clock. If reset, the internal clock is used.
  • IFCN (Internal Oscillator Frequency Control Bits) selects the internal oscillator frequency (2, 4, 8 or 16 MHz).
  • CLKMUL (Clock Multiplier Control Register) contain the following clock multiplier control bits:
  • MULEN (Clock Multiplier Enable) is set to enable the clock multiplier.
  • MULSEL (Clock Multiplier Input Select) selects the clock supplied to the clock multiplier.

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.

Oscillators and 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.
  • AV is the analog power supply value in volts.
  • CPU Clock displays the calculated clock rate.

AV VTREG
Data Type: float

AV is the analog supply voltage. Typing the following command in the debugger's Command Window sets the analog voltage to 3.0 volts:

AV = 3.0

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

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.

Get more information about the
Peripheral Simulation Capabilities
of the µVision Debugger.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.