Peripheral Simulation
For Infineon C509-L — 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 length, synchronous or
asynchronous).
-
S0CON (Serial Control Register 0) holds the control and
setup information for programming serial port 0.
-
S0BUF (Serial Interface Buffer Register 0) 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 (RI0) 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 (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 Generator Reload High Value) contains
the upper 2-bits of the 10-bit value that automatically reloads
into the 10-bit timer that generates the baudrate.
-
S0RELL (Baudrate Generator Reload Low Value) contains
the lower byte of the 10-bit value that automatically reloads into
the 10-bit timer that generates the baudrate.
-
SMOD (Double Baudrate) is set to double the baudrate in
all modes.
-
BD (Baudrate Generator Enable) is set to enable the
dedicated baudrate generator. If reset, the Timer 1 overflow rate
determines the baudrate.
-
Baudrate is the actual baudrate for the serial channel.
It can be derived from the oscillator frequency, or generated by
Timer 1.
SxIN VTREG
Data Type: unsigned int
The SxIN VTREG represents the serial input of the simulated
microcontroller. Values you assign to SxIN are input to the serial
channel 0, 1, 2, and so on. You may assign input using the command
window. For example,
S0IN='A'
causes the simulated microcontroller serial input 0 to receive the
ASCII character A. If you want to use the SxIN VRTEG to simulate
reception of multiple characters, you must be sure to delay for at
least one character time between successive assignments to SxIN. 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 SxIN 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 SxIN 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.
SxOUT VTREG
Data Type: unsigned int
The SxOUT VTREG represents the serial output from the simulated
serial port 0, 1, and so on. Whenever the simulated serial port
transmits a character, the value transmitted is automatically
assigned to SxOUT (which is read-only). You may read the value of
SxOUT to determine the character transmitted by your simulated
program. For example,
S0OUT
outputs the value of the last character transmitted by serial port
0. Note that you cannot assign values to the SxOUT VTREGs. You may
use the SxOUT 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);
}
}
SxTIME VTREG
Data Type: unsigned char
The SxTIME VTREG allows you to control the timing of the simulated
serial port 0, 1, and so on.
-
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 0 for FAST timing */
S0TIME = 1 /* Set Serial Port 0 for accurate timing */