Keil Logo

Peripheral Simulation

For Dallas Semiconductor DS80C411 — Serial UART 2 (Enhanced Interface with T3 as 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.

Serial Channel 2 Dialog

Serial Channel 2

The Serial Channel 2 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).
  • SCON2 (Serial Control Register) holds the control and setup information for programming serial port 1.
  • SBUF2 (Serial Interface Buffer Register) contains the transmit data to be sent or received data.
  • SADDR2 (Slave Address) when the MCU is a master, this selects a slave device for communication with another serial device.
  • SADEN2 (Slave Address Mask) determines which bits of the slave address are used for communication with another serial device.
  • SM2_2 (Enable Serial Port 2 Multiprocessor Communication In Modes 2 and 3) is set to suppress a receiver interrupt (RI_2) if the received 9th data bit is 0.
  • TB8_2 (Serial Port 2 Transmitter Bit 9) is the 9th data bit to be transmitted for serial modes 2 and 3.
  • RB8_2 (Serial Port 2 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.
  • SMOD0 (Framing Error Mode) is set to enable framing error detection for serial channels 0, 1 and 2.
  • FE_2 (Framing Error Detected) is set when an invalid stop bit (framing error) is detected. This bit must be reset by software.
  • REN_2 (Receiver Enable) is set to enable serial data input.
BaudRate
  • SMOD_2 (Double Baudrate) is set to double the baudrate in mode 2.
  • Transmit & Receive Baudrate is the actual baudrate for the serial channel. It can be derived from the oscillator frequency, or generated by Timer 3.
IRQ
  • TI_2 (Transmitter Interrupt Flag) is set by hardware for each character frame transmitted. TI_2 is cleared by software.
  • RI_2 (Receiver Interrupt Flag) is set by hardware for each character frame received. RI_2 is cleared by software.

S2IN VTREG
Data Type: unsigned int

The S2IN VTREG represents the serial input of the simulated microcontroller. Values you assign to S2IN are input to the serial channel. You may assign input using the command window. For example,

S2IN='A'

causes the simulated microcontroller serial input to receive the ASCII character A. If you want to use the S2IN VRTEG to simulate reception of multiple characters, you must be sure to delay for atleast one character time between successive assignments to S2IN. This may be done using a signal function. For example:

signal void send_cat (void) {
swatch(0.01);  /* Wait 1/100 seconds */
S2IN='C';       /* Send a C */
swatch(0.01);
S2IN='A';
swatch(0.01);
S2IN='T';
}

You may use the S2IN VTREG to input more than 8 bits of data. For example,

S2IN=0x0123

inputs a 9-bit value. This is useful if you use 9-bit serial I/O. In addition to the S2IN 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.

S2OUT VTREG
Data Type: unsigned int

The S2OUT VTREG represents the serial output from the simulated microcontroller. Whenever the simulated serial port transmits a character, the value transmitted is automatically assigned to S2OUT (which is read-only). You may read the value of S2OUT to determine the character transmitted by your simulated program. For example,

S2OUT

outputs the value of the last character transmitted. You may use the S2OUT VTREG in a script to process transmitted data. For example,

signal void s2out_sig (void) {
while (1)
  {
  wwatch(S2OUT);     /* wait for something in S2OUT */
  printf ("Transmitted a %2.2X\n", (unsigned) S2OUT);
  }
}

S2TIME VTREG
Data Type: unsigned char

The S2TIME 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:

S2TIME = 0   /* Set Serial Port for FAST timing */
S2TIME = 1   /* Set Serial Port for accurate timing */
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.