Peripheral Simulation
For NXP (founded by Philips) P89C669 — Serial UART 0 (Enhanced Interface with S0STAT and special BRG)
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.
Parallel Port 4 Dialog
This dialog displays the SFR and pins of Port 4.
-
P4: This is the P4 SFR. The HEX value and value of each
bit is displayed and may be changed from this dialog.
-
Pins: These are the states of the pins on the simulated
MCU. When used as outputs, these have the same value as the P4 SFR.
When used as inputs (P4.x is 1) you may set the level of the input
pin to high (1) or low (0).
Serial Channel #0 Dialog
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 */
S0IN VTREG
Data Type: unsigned int
The S0IN VTREG represents the serial input of the simulated
microcontroller. Values you assign to S0IN are input to the serial
channel. You may assign input using the command window. For
example,
S0IN='A'
causes the simulated microcontroller serial input to receive the
ASCII character A. If you want to use the S0IN VRTEG to simulate
reception of multiple characters, you must be sure to delay for
atleast one character time between successive assignments to S0IN.
This may be done using a signal function. For example:
signal void send_cat (void) {
swatch(0.01); /* Wait 1/100 seconds */
S0IN='C'; /* Send a C */
swatch(0.01);
S0IN='A';
swatch(0.01);
S0IN='T';
}
You may use the S0IN VTREG to input more than 8 bits of data. For
example,
S0IN=0x0123
inputs a 9-bit value. This is useful if you use 9-bit serial I/O.
In addition to the S0IN VRTEG, the serial window allows you to input
serial characters by simply typing. Serial characters that are
transmitted byt the simulated microcontroller appear in the serial
window.
S0OUT VTREG
Data Type: unsigned int
The S0OUT VTREG represents the serial output from the simulated
microcontroller. Whenever the simulated serial port transmits a
character, the value transmitted is automatically assigned to S0OUT
(which is read-only). You may read the value of S0OUT to determine
the character transmitted by your simulated program. For example,
S0OUT
outputs the value of the last character transmitted. You may use
the S0OUT VTREG in a script to process transmitted data. For
example,
signal void s0out_sig (void) {
while (1)
{
wwatch(S0OUT); /* wait for something in S0OUT */
printf ("Transmitted a %2.2X\n", (unsigned) S0OUT);
}
}
S0TIME VTREG
Data Type: unsigned char
The S0TIME VTREG allows you to control the timing of the simulated
serial port.
-
A value of 1 (which is the default) indicates that the serial
port timing is identical to the target hardware. Use this value
when you want to see the effects of baud rate on the serial port
I/O.
-
A value of 0 indicates that all serial input and output occur
instantaneously. Use this value when you don't care about any baud
rate effects or when you want serial output to be fast.
For example:
S0TIME = 0 /* Set Serial Port for FAST timing */
S0TIME = 1 /* Set Serial Port for accurate timing */