Peripheral Simulation
For Nuvoton W77E516 — Clock Divider and Timer Rate Control; 4 Clocks Per Machine Cycle
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.
Clock Control Dialog
The Clock Generation dialog displays and allows you to specify the
configuration for the MCU clock.
Control Register
-
CKCON contains the MOVX duration selection setting, as
well as the Watchdog Timer mode setting and Timer/Counter Clock
selection bits.
Timer Rate Control
-
T2M if set, the Timer 2 clock frequency equals the
system clock divided by 4. If reset, it equals the system clock
divided by 12.
-
T1M if set, the Timer 1 clock frequency equals the
system clock divided by 4. If reset, it equals the system clock
divided by 12.
-
T0M if set, the Timer 0 clock frequency equals the
system clock divided by 4. If reset, it equals the system clock
divided by 12.
Clock Divider
-
CD (Clock Divide Control) selects the number of
oscillator clocks required to generate one machine cycle.
-
4X (4X/2X Clock Multiplier) is set to multiply the clock
frequency by 4 resulting in 1 clock per machine cycle. If reset,
the clock frequency is multiplied by 2 resulting in 2 clocks per
machine cycle.
-
SWB (Switchback Enable) is set to allow a external or
serial port interrupt to force the Clock Divide Control (CD) to 4
clocks per cycle mode.
Oscillators & CPU Clock
-
XTAL Freq. specifies the crystal oscillator frequency in
Hz.
-
Ring Osc. specifies the ring oscillator frequency in
Hz.
-
CPU CLock displays the resulting system clock
frequency.
-
CTM (Crystal Multiplier Enable) is set to enable the
frequency multplier function (4X/2X).
-
CKRY (Crystal Oscillator Ready) is set when the crystal
oscillator completes its 65,536 cycle warm-up period.
-
RGMD (Ring Oscillator Mode) is set to indicate the clock
source is the Ring Oscillator. If reset, the clock source is an
external crystal or oscillator.
-
RGSL (Ring Oscillator Select) is set to use the Ring
Oscillator to start up from Stop mode. If reset, the software must
wait for the crystal warm-up period to complete.
External Memory Access
-
MOVX Duration[Cycles] selects the number of machine
cycles the the MOVX instruction will use. The RD and WR strobes are
lengthened by this interval to allow use of slower memory or
peripheral devices.
PORTx VTREG
Data Type: unsigned char
The PORTx VTREGs represent the I/O pins of the simulated
MCU for Port 0, Port 1, and so on. PORT0 represents Port 0, PORT1
represents Port 1, etc. You may read PORTx to determine the
state of the output pins of that port. For example, in the command
window, you may type,
PORT0
to obtain value corresponding to the set pins of Port 0. You may
also change the input values of port pins by changing the value of
the VTREG. For example,
PORT1=0xF0
sets the upper four port pins of Port 1 to a value of 1 and the
lower 4 port pins to a value of 0. You may use the bitwise operators
AND(&), OR(|) and XOR(^) to change individual bits of the PORTx
VTREGs. For example:
PORT1 |= 0x01; /* Set P1.0 Pin */
PORT3 &= ~0x02; /* Clr P3.1 Pin */
PORT1 ^= 0x80; /* Toggle P1.7 Pin */
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.