Documentation Home Page RT-XSG Toolbox Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

SPI Slave Interface

Page Content

Block

Mask

Description

The SPI Slave Interface block is a synchronous serial data link that operates in synchronous full duplex mode. It is ideal for interfacing with various peripheral devices. The block is user customizable.

Parameters

Clock Phase (CPHA), TX Polarity (CPOL), RX Polarity

The clock phase and polarity can be modified for SPI data transfers. To remain flexible enough to work with many implementations of the I/O logic, the SPI Interface can toggle its serial clock phase and polarity.

The parameters that control these are CPHA (for Clock PHAse), and TX Polarity (CPOL for Clock POLarity).

  • The CPOL parameter defines the base state of the clock at the beginning of each packet, high or low.

  • The CPHA parameter defines when data is loaded into the slave device's output register to be sampled by the host.

  • If CPHA = "0", data is valid on the first SCK edge (rising or falling) after Slave Select has asserted. If CPHA = "1", data is valid on the second SCK edge (rising or falling) after Slave Select has asserted.



The figure above shows the timing diagram for an SPI data transfer when the clock phase, CPHA, is set to "0". The waveform is shown for both positive and negative clock polarities of SCK.

The SCK signal remains inactive for the first half of the first SCK cycle (SCK Cycle 1). In this transfer format, the falling edge of Slave Select indicates the beginning of a data transfer. Therefore, the Slave Select line must be negated and reasserted between each successive serial data transfer.

The figure above shows the timing diagram for an SPI transfer when the clock phase, CPHA, is set to "1". The waveform is shown for both positive and negative clock polarities of SCK.

The first SCK cycle begins with an edge on the SCK line from its inactive to its active level. The first edge of SCK indicates the start of the data transfer in this format.

In accordance with these rules, the parameters TX and RX Polarity should be set according to this table to set the SPI block in the desired SPI mode:

Note: Clock Phase (CPHA), TX Polarity (CPOL) and RX Polarity parameters can be set dynamically through the Block input port if the user selects the option "As an input port".


Slave Select Polarity

This parameter sets the polarity of the Slave Select signals. If the user selects the option "As an input port", the polarity can be dynamically through the Block input port.

Data Width RX (1-128)

This parameter sets the width of the data to be received. If the user selects the option "As an input port", the width can be dynamically through the Block input port.

Data Width TX (1-128)

This parameter sets the width of the data to be transmitted. If the user selects the option "As an input port", the width can be dynamically through the Block input port.

Inputs

CPHA

This signal permits setting the clock phase to select one of two fundamentally different transfer formats.

This port is made available only if the developer selects the option "As an input port" in the mask parameters.

TX_POL

This signal permits the selection of the polarity of the transmitting data (transmit). It usually corresponds to the Clock Polarity (CPOL).

This port is made available only if the developer selects the option "As an input port" in the mask parameters.

RX_POL

This signal permits the selection of the polarity of the receiving data (latch).

This port is made available only if the developer selects the option "As an input port" in the mask parameters.

SS_POL

This signal permits the selection of the polarity of the Slave Select signal.

This port is made available only if the developer selects the option "As an input port" in the mask parameters.

Data_Width [RX or TX]

This signal permits the setting of the width of the data.

This port is made available only if the developer selects the option "As an input port" in the mask parameters.

Datain

Port representing the data to be transmitted serially by the Block. The SPI block can accept up to 28 DWORDs in one calculation step, but care should be taken to avoid overflowing the SPI internal FIFOs by monitoring the status flags.

Packets sent to the block should conform to the following formatting:

The first DWORD should have these fields:

  • Bit 31:28 Allow selecting the slave number to which data will be transmitted to when configured as master. This field is not used when configured as a slave.

  • Bit 27:0 Allow specifying the amount of data that will be sent to the SPI block. Each bit represents one piece of data.

The following DWORDs are the SPI data to be sent by starting with the least significant group. For example, sending data1="EF00GH00" and data2="ABCD0000" will result with the message "ABCD0000EF00GH00", so the SPI stream will start with "1010" and not "1110".

S_SCK

Slave SPI clock

This port is made available only if the Block is configured as Slave or Master/Slave

S_MOSI

Slave input data port

This port is made available only if the Block is configured as Slave or Master/Slave

S_SS

Slave "Slave Select" input port

This port is made available only if the Block is configured as Slave or Master/Slave

SpiEna

SPI Enable input

This active high input enables the normal operation of the SPI. During Configuration (e.g. Changing Frequency), this input must be in the low state

rst_RAM_addr

Reset RAM's addresses. An internal DualPort RAM is present within our SPI logic and its addresses can be reset through this active-high input. This inport should be toggled when a whole SPI frame is received or when one is incomplete.

txTrig

Trigger transmission. This active high input is intended to enable the transmission of the MISO signal. It can be seen as the SS signal for the Slave to outputs its serial data.

Outputs

Dataout

This signal holds the receiving data

Timestamp

This signal holds the timestamp of the receiving data

Status

This port holds the status of the SPI interface Block

Prior to RT-XSG v3.4.0

  • Bit 6:0 Represent the amount of Data in the Transmitting FIFO

  • Bit 13:7 Represent the amount of Data in the Receiving FIFO

  • Bit 14 Indicate that the Transmitting FIFO is full

  • Bit 15 Indicate that the Receiving FIFO is full

Starting with RT-XSG v3.4.0

  • Bit 5:0 Represent the amount of Data in the Transmitting FIFO

  • Bit 6 Indicate that the Transmitting FIFO is full

  • Bit 14:7 Actual amount of bits left to be transmitted

  • Bit 22:15 Actual amount of bits left to be received

S_MISO

Slave SPI Serial data out

Characteristics and Limitations

SPI x1 supported only:

  • no bidirectional lines;

  • limited to 1 bit of data by clock.

Direct Feedthrough

N/A

Discrete sample time

N/A

XHP support

N/A

Work offline

YES

 

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | opal-rt.com | +1 514-935-2323
Follow OPAL-RT: LinkedIn | Facebook | YouTube | X/Twitter