Keil Logo

Peripheral Simulation

For NXP (founded by Philips) P89LPC917 — Serial UART (Enhanced Interface)

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 Dialog

Serial Channel

The Serial Channel 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).
  • SCON (Serial Control Register) holds the control and setup information for programming the serial port.
  • SM2 (Enable Serial Port Multiprocessor Communication In Modes 2 and 3) is set to suppress a receiver interrupt (RI) if the received 9th data bit is 0.
  • REN (Receiver Enable) is set to enable serial data input.
  • SADDR (Slave Address) when the MCU is a master, this selects a slave device for communication with another serial device.
  • SADEN (Slave Address Mask) determines which bits of the slave address are used for communication with another serial device.
  • SMOD0 (Framing Error Location) is set to define bit 7 of SCON as the Framing Error (FE) status. When reset, bit 7 of SCON is SM0.
  • INTLO (Transmit Interrupt Position) is set to issue a TX interrupt at the end of the stop bit. If reset, the TX interrupt is issued at the beginning of the stop bit.
  • CIDIS (Combined Interrupt Disable) is set to receive separate interrupts for RX and TX. If reset, RX and TX interrupt are combined as in a conventional 80C51 UART.
  • DBMOD (Double Buffering Mode) is set to enable double buffering.
  • DBISEL (Double Buffering Transmit Interrupt Select) is set to transmit and extra interrupt to indicate the end of data transmission. This is used only with double buffering.

Data

  • SBUF (Serial Interface Buffer Register) contains the transmit data to be sent or received data.
  • TB8 (Serial Port Transmitter Bit 9) is the 9th data bit to be transmitted for serial modes 2 and 3.
  • RB8 (Serial Port 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.

Status

  • SSTAT (Status Mode Select) is set to enable framing error, receiver overrun and transmitter collision detection.
  • FE (Framing Error Detected) is set when an invalid stop bit (framing error) is detected. This bit must be reset by software.
  • BR (Break Detect Flag) is set when a break (11 consecutive low bits) is detected.
  • OE (Overrun Error) is set is another character is received before the previous character was read from the buffer.
  • STINT (Status Interrupt Enable) is set to allow FE, OE or BR to trigger an interrupt.

Baudrate

  • BRGR1 (Baud Rate Generator Rate High Byte) contains the MSB of the baud rate generator divisor.
  • BRGR0 (Baud Rate Generator Rate Low Byte) contains the LSB of the baud rate generator divisor.
  • SMOD (Double Baudrate) is set to double the baudrate.
  • SBRGS (Select Baud Rate Generator) is set to use the baud rate generator as a source for UART baud rates.
  • BRGEN (Baud Rate Generator Enable) is set enable the baud rate generator.
  • Transmit & Receive Baudrate is the actual baudrate for the serial channel.

IRQ

  • TI (Transmitter Interrupt Flag) is set by hardware for each character frame transmitted. TI is cleared by software.
  • RI (Receiver Interrupt Flag) is set by hardware for each character frame received. RI is cleared by software.

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);
  }
}

STIME VTREG
Data Type: unsigned char

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

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