Keil Logo

Peripheral Simulation

For NXP (founded by Philips) LPC2292 — SPI Interface 1

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 Peripheral Interface 1 Dialog

Serial Peripheral Interface 1

The Serial Peripheral Interface 1 Dialog allows you to view and edit the Serial Peripheral Interface (SPI) simulator configuration. Simulation of this interface is controlled by the following groups:

Control Register Group

  • SPCR (Serial Peripheral Control Register) contains the following bits that control the functions of the SPI:
  • SPIE (SPI Interrupt Enable) is set to generate an interrupt when either the SPI Transfer Complete (SPIF) or Mode Fault (MODF) bits set.
  • LSBF (LSB First) is set to transfer SPI data starting with bit 0. If reset, SPI starts data transfers with bit 7.
  • MSTR (Master Mode) is set to configure the SPI as a Master. If reset, the SPI operates in Slave mode.
  • CPOL (Clock Polarity) is set when the serial clock (SCK) is active low. If reset, SCK is active high.
  • CPHA (Clock Phase) is set to sample data on the second clock edge. If CPHA is reset, data sampling starts on the first clock edge, and Slave Select (SSEL) signal determines the start and end of the data transfer cycle.

Status Register Group

  • SPSR (SPI Status Register) monitors the SPI status. It contains the following read-only bits:
  • SPIF (Data Transfer Complete) is set when the SPI completes a data transfer operation. This bit clears after this register and the data register (SPDR) are read.
  • WCOL (Write Collision) is set when data is written to the SPI data register while a SPI data transfer is in progress.
  • ROVR (Read Overrun) is set when the SPI receives data before it's read buffer is empty.
  • MODF (Mode Fault) is set when the Slave Select (SSEL) goes active and the SPI is configured as a master.
  • ABRT (Slave Abort) is set when the Slave Select (SSEL) signal goes inactive before a data transfer completes.

Clock Counter Group

  • SPCCR (SPI Clock Counter Register) controls the SPI clock rate when the SPI is configured as a master. This value is the number of PCLK cycles that make up 1 SPI clock.
  • Master Clock is the SPI clock value (SCK) based on the SPCCR setting.

Data Register Group

  • SPDR (SPI Data Register) contains the either the data to be transmitted or the data received. In Master mode, writing to this register starts data transfer.

Slave Select Group

  • SSEL# Pin (Slave Select) is the signal level at the slave select pin.

Interrupt Register Group

  • SPINT (SPI Interrupt Register) contains the SPI interrupt flag setting.
  • SPI Interrupt (SPI Interrupt Flag) is set by the SPI interface to generate and SPI interrupt.

SPIx_IN VTREG
Data Type: unsigned char

The SPIx_IN VTREG (where x indicates the SPI port 0, 1, 2, and so on) contains a byte which is received via the MCU SPI (Serial Peripheral Interface) port on the next SPI transfer. You may use this VTREG in a simulation script. For example:

signal void spi_func (void) {
while (1) {
  wwatch (SPI0_OUT);
  printf ("SPI0_OUT: %2.2X\n", (unsigned) SPI0_OUT);
  SPI0_IN = SPI0_OUT + 1;
  }
}

This signal function returns the SPI byte send plus 1 on the next SPI transfer.

SPIx_OUT VTREG
Data Type: unsigned char

The SPIx_OUT VTREG (where x indicates the SPI port 0, 1, 2, and so on) contains a byte output via the MCU SPI (Serial Peripheral Interface) port. When your simulated program sends a byte via SPI, the SPIx_OUT VTREG is set with the value output. You may monitor this VTREG in a simulation script. For example:

signal void spi_watcher (void) {
while (1) {
  wwatch (SPI1_OUT);
  printf ("SPI1_OUT: %2.2X\n", (unsigned) SPI1_OUT);
  }
}
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.