Peripheral Simulation
For Cadence Design Systems Inc. R8051XC2-BF — Serial UART 0
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.
Serial Channel-0 Dialog
The Serial Channel 0 dialog displays and allows you to edit the
configuration of the Serial Interface.
-
Mode displays and allows you to change the serial
interface mode of operation (data bit length and baud rate).
-
S0CON (Serial Control Register) holds the control and
setup information for programming serial port 0.
-
S0BUF (Serial Interface Buffer Register) contains the
transmit data to be sent or received data.
-
SM20 (Enable Serial Port 0 Multiprocessor Communication
In Modes 2 and 3) is set to suppress a receiver interrupt (RI_0) if
the received 9th data bit is 0.
-
TB80 (Serial Port 0 Transmitter Bit 9) is the 9th data
bit to be transmitted for serial modes 2 and 3.
-
REN0 (Serial Port 0 Receiver Enable) is set to enable
serial data input.
-
RB80 (Serial Port 0 Receiver Bit 9) is set for serial
modes 2 and 3 when a 9th bit is received. In serial mode 1, this is
the stop bit.
IRQ
-
TI0 (Transmitter Interrupt Flag) is set by hardware for
each character frame transmitted. TI0 is cleared by software.
-
RI0 (Receiver Interrupt Flag) is set by hardware for
each character frame received. RI0 is cleared by software.
BaudRate
- S0RELH (Baudrate Reload High)
- S0RELL (Baudrate Reload Low)
-
SMOD (Double Baudrate) is set to double the baudrate in
all modes.
-
BD (Baudrate Generator Enable) is set to use the
dedicated prescaler for baudrate generation. If reset, Timer 1
overflows are used.
-
Baudrate is the actual baudrate for the serial
channel.
SIN VTREG
Data Type: unsigned int
The SIN VTREG represents the serial input of the simulated
microcontroller. Values you assign to SIN are input to the serial
channel. You may assign input using the command window. For
example,
SIN='A'
causes the simulated microcontroller serial input to receive the
ASCII character A. If you want to use the SIN VRTEG to simulate
reception of multiple characters, you must be sure to delay for
atleast one character time between successive assignments to SIN.
This may be done using a signal function. For example:
signal void send_cat (void) {
swatch(0.01); /* Wait 1/100 seconds */
SIN='C'; /* Send a C */
swatch(0.01);
SIN='A';
swatch(0.01);
SIN='T';
}
You may use the SIN VTREG to input more than 8 bits of data. For
example,
SIN=0x0123
inputs a 9-bit value. This is useful if you use 9-bit serial I/O.
In addition to the SIN 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.
SOUT VTREG
Data Type: unsigned int
The SOUT VTREG represents the serial output from the simulated
microcontroller. Whenever the simulated serial port transmits a
character, the value transmitted is automatically assigned to SOUT
(which is read-only). You may read the value of SOUT to determine the
character transmitted by your simulated program. For example,
SOUT
outputs the value of the last character transmitted. You may use
the SOUT VTREG in a script to process transmitted data. For
example,
signal void sout_sig (void) {
while (1)
{
wwatch(SOUT); /* wait for something in SOUT */
printf ("Transmitted a %2.2X\n", (unsigned) SOUT);
}
}