25. XSPI I/O manager (XSPIM)
25.1 XSPIM introduction
The XSPI I/O manager is a low-level interface, enabling an efficient XSPI pin assignment with a full I/O matrix (before alternate function map), and multiplex of single/dual/quad/octal/16-bit SPI interfaces over the same bus.
25.2 XSPIM main features
- • Supports up to two single/dual/quad/octal/16-bit SPI interfaces
- • Supports up to two ports for pin assignment
- • Supports high-speed interfaces
25.3 XSPIM implementation
Table 216 describes the XSPIM implementation.
Table 216. XSPIM implementation
| XSPI feature | Available on the devices |
|---|---|
| Supports up to two single/dual/quad interfaces | X |
| Fully I/O multiplexing capability | X |
| Supports time-multiplexed mode | X |
| Supports high-speed interface | X |
| Chip select selection if XSPI provides dual chip select | X |
| Supports 16-bit data interface and dual-octal mode | X |
25.4 XSPIM functional description
25.4.1 XSPIM block diagram
The block diagram of the XSPI I/O manager is shown in Figure 215.
Figure 215. XSPIM block diagram![Figure 215. XSPIM block diagram. Shows XSPI1 and XSPI2 connected to XSPI I/O manager. The manager connects via AHB interface to AHB bus, includes control register, arbiter, static muxing, time muxing, and I/O matrix with Port 1 and Port 2 routing to High speed interface (PHY), connecting to pins XSPIM_P1_CLK, XSPIM_P1_NCLK, XSPIM_P1_DQS0,1, XSPIM_P1_NCS1,2, XSPIM_P1_IO[15:0] and XSPIM_P2_CLK, XSPIM_P2_NCLK, XSPIM_P2_DQS0, XSPIM_P2_NCS1,2, XSPIM_P2_IO[7:0].](/RM0477-STM32H7Rx-7Sx/367cc61af18cc5739dc2a9e709f5fa0a_img.jpg)
25.4.2 XSPIM input/output pins
Table 217. XSPIM input/output pins| Pin name(1) | Signal type | Description |
|---|---|---|
| XSPIM_Px_NCLK | Output | XSPI inverted clock to support 1.8 V HyperBus protocol |
| XSPIM_Px_CLK | Output | XSPI clock |
| XSPIM_Px_IOn (n = 0 to 15) | Input/output | XSPI data pins |
| XSPIM_Px_NCS1,2 | Output | Chip select for the memory |
| XSPIM_Px_DQS0,1 | Input/output | Data strobe/write mask signals from/to the memory |
1. x = 1 to 2.
25.4.3 XSPIM matrix
The XSPI I/O manager matrix allows the user to set a premapping of functions:
- • XSPI1 mapped to Port 1, with XSPI2 mapped to Port 2 (direct mode)
- • XSPI1 mapped to Port 2, with XSPI2 mapped to Port 1 (swapped mode)
- • XSPI1 and XSPI2 both mapped to Port 1, with arbitration (multiplexed mode)
- • XSPI1 and XSPI2 both mapped to Port 2, with arbitration (multiplexed mode)
Note: There is no possibility to use mixed combinations of signals (like NCS of XSPI1 with data of XSPI2).
When several I/O pins have the same configuration and are enabled at the same time, the result can be unpredictable.
In the default out-of-reset configuration, all the XSPI1 and XSPI2 signals are mapped, respectively, on Port 1 and on Port 2.
The configuration can be changed only when all XSPIs are disabled.
25.4.4 XSPIM multiplexed mode
When this mode is set, the XSPIs are time-multiplexed over the same bus. They get the ownership of the bus (in turn) through a request/acknowledge protocol with REQ/ACK signals.
The time-multiplexing is enabled by setting the MUXEN bit in the configuration register XSPIM_CR.
The fairness counter (MAXTRAN) of each XSPI can be used to manage the maximum duration for which a given XSPI takes the bus: this feature ensures the maximum bus access latency for the other XSPI(s). When one XSPI releases the bus, a round-robin arbitration phase occurs: when another XSPI requests the bus, it gets it.
When the multiplexed mode is enabled, either the fairness counter or the refresh timeout counter of both XSPI interfaces must be activated.
Each XSPI delivers one NCS signal together with a CSSEL control signal. The CSSEL signal selects which of the two outputs (NCS1, NCS2) is active. In multiplexed modes the active CSSEL signal is the one of the XSPI owning the bus. The default value of XSPIM_CR.CSSEL is 0 for XSPI1 and 1 for XSPI2. Only XSPIMn_IOs, XSPIMn_DQS and XSPIMn_CLK / XSPIMn_NCLK are multiplexed.
When the multiplexed mode is used, only clock mode 0 is supported on the XSPIs.
Due to arbitration and bus sharing, the auto polling interval time of the XSPI, when used, can be increased.
Minimum switching duration
The minimum number of cycles needed to switch from an XSPI to another can be configured. This guarantees a latency between the falling edge of the REQ signal of the active XSPI (the active one releases the bus), and the rising edge of the ACK signal to the requesting XSPI (the bus is granted to the requesting one).
The duration is defined by the REQ2ACK_TIME field in the XSPIM_CR register.
25.5 Use cases description
The following table summarizes the use cases corresponding to IO manager modes.
Table 218. Use cases
| IO manager mode | MUXEN | Mode | Reference |
|---|---|---|---|
| Direct | 0 | 0 | Section 25.5.1 Section 25.5.2 |
| Swapped | 0 | 1 | Section 25.5.4 |
| Multiplexed to Port1 | 1 | 0 | Section 25.5.5 |
| Multiplexed to Port2 | 1 | 1 | Section 25.5.6 |
| Two XSPIs drive one external memory | 1 | 0 or 1, depending upon the port connected to the memory. | Section 25.5.7 |
| One XSPI drives two external memories | 0 | 0 with CS selection command from XSPI1 or 2. | Section 25.5.8 |
25.5.1 XSPIs direct octal mode
This is the baseline mode: each XSPI independently drives the corresponding port (XSPI1 on port 1 and XSPI2 on port 2) and high-speed interface. There is no multiplexing.
The configuration selection signal selects the signals used for each high-speed interface. These signals come from the XSPI_CR and XSPI_CALxxx register outputs.
Alternate function signals can be routed on NCS2 pins as they are not used for the XSPI bus. NCLK clocks are requested in case of 1.8 V HyperBus memory type.
This mode is selected by default through bits XSPIM_CR[1:0].
Figure 216. XSPI direct octal mode

The diagram illustrates the XSPI I/O manager architecture in direct octal mode. The XSPI I/O manager is a central block containing an AHB interface, a Control register, an Arbiter, and an I/O matrix. It is connected to two XSPI blocks (XSPI1 and XSPI2) via bus signals. XSPI1 provides signals: XSPI1 bus signals, ACK1, REQ1, CS1, and CSSEL1. XSPI2 provides signals: CS2, CSSEL2, REQ2, and ACK2. The Arbiter within the manager handles these signals, with static and dynamic muxing leading to the I/O matrix. The I/O matrix connects to two High speed interfaces (High speed interface 1 and High speed interface 2). These interfaces output signals to external Octal memories. High speed interface 1 connects to Octal memory 1 with signals: XSPIM_P1_CLK (clk), XSPIM_P1_NCLK (nclk), XSPIM_P1_DQS0 (Data strobe), XSPIM_P1_NCS1 (nCS), and XSPIM_P1_IO[7:0] (Data[7:0]). High speed interface 2 connects to Octal memory 2 with signals: XSPIM_P2_CLK (clk), XSPIM_P2_NCLK (nclk), XSPIM_P2_DQS0 (Data strobe), XSPIM_P2_NCS2 (nCS), and XSPIM_P2_IO[7:0] (Data[7:0]). Configuration signals from XSPI1 and XSPI2 are used for configuration signal selection. Alternate functions signals are also shown entering the high-speed interfaces.
25.5.2 XSPI direct 16-bit mode
This is the baseline mode, completely similar to XSPI octal direct mode, where each XSPI directly drives the corresponding port (XSPI1 connected to Port 1, XSPI2 connected to Port 2). Two DQS (1 per byte) are needed for each 16-bit port, when available.
Figure 217. XSPI direct 16-bit mode

This diagram illustrates the XSPI direct 16-bit mode architecture. The XSPI I/O manager block contains Control registers, an Arbiter, and an I/O matrix with ports P1 and P2. It is connected to the AHB bus and two external interfaces, XSPI1 and XSPI2. The I/O matrix includes Static and dynamic muxing and Port selection logic. Configuration signals selection and Configuration signals are also shown. The manager connects to two High speed interface blocks (High speed interface 1 and High speed interface 2) via Alternate functions signals. High speed interface 1 connects to 16-bit memory 1 with signals: XSPIM1_CLK (clk), XSPIM1_NCLK (nclk), XSPIM1_DQS0 (Data strobe), XSPIM1_DQS1 (Data strobe), XSPIM1_NCS1 (nCS), XSPIM1_NCS2, and XSPIM1_IO[15:0] (Data[15:0]). High speed interface 2 connects to Octal memory 2 with signals: XSPIM2_CLK (clk), XSPIM2_NCLK (nclk), XSPIM2_DQS0 (Data strobe), XSPIM2_NCS1 (nCS), XSPIM2_NCS2, and XSPIM2_IO[7:0] (Data[7:0]).
MS55954V3
25.5.3 XSPI dual-octal mode
This mode is equivalent to XSPI direct mode, but, for simplicity, only one XSPI interface is represented. Two external octal memories are accessed in parallel, similarly to the dual-quad mode implemented with octal interfaces.
Figure 218. XSPI dual-octal mode

This diagram illustrates the XSPI dual-octal mode architecture. The XSPI I/O manager block contains Control registers, an Arbiter, and an I/O matrix with ports P1 and P2. It is connected to the AHB bus and a single external interface, XSPI. The I/O matrix includes Static and dynamic muxing and Port selection logic. Configuration signals are also shown. The manager connects to a single High speed interface block via Alternate functions signals. This interface connects to two Octal memory blocks (Octal memory 1 and Octal memory 2) within a Multichip package (MCP). Octal memory 1 is connected via signals: XSPIM_P1_CLK (clk), XSPIM_P1_NCLK (nclk), XSPIM_P1_DQS0 (Data strobe), XSPIM_P1_NCS1 (nCS), XSPIM_P1_NCS2, and XSPIM_P1_IO[7:0] (Data[7:0]). Octal memory 2 is connected via signals: XSPIM_P1_DQS1 (Data strobe), XSPIM_P1_NCS1 (nCS), and XSPIM_P1_IO[15:8] (Data[7:0]).
25.5.4 XSPI swapped mode
This mode is similar to XSPI direct mode, but the ports are swapped, to help I/O mapping. The mode is selected by bits XSPIM_CR[1:0].
If XSPIM.CR[0] or XSPIM.CR[1] is toggled in application, XSPI DCR2 or XSPI.CCR must be written, so that the calibration of the high speed interface is launched according to the new XSPI using it.
Note: In swapped mode, the XSPI2 can be configured in 16-bit mode, and the XSPI1 can be configured in octal mode, to connect an external 16-bit memory on Port 1, and to connect in a concurrent way an octal external memory connected to Port 2 of the I/O manager.
Figure 219. XSPI swapped (octal) mode

The diagram illustrates the XSPI I/O manager in swapped (octal) mode. The XSPI I/O manager block contains an AHB interface connected to the AHB bus, a Control register, and an I/O matrix. Inside the I/O manager, there is an Arbiter that receives bus signals from XSPI1 (ACK1, REQ1, CS1, CSSEL1) and XSPI2 (REQ2, ACK2, CS2, CSSEL2). The Arbiter's output goes through Dynamic muxing and Static muxing to the I/O matrix. Configuration signal selection and configuration signals are also shown. The I/O matrix connects to two High speed interfaces. High speed interface 1 connects to Octal memory 1 via signals: XSPIM_P1_CLK (clk), XSPIM_P1_NCLK (nclk), XSPIM_P1_DQS0 (Data strobe), XSPIM_P1_DQS1, XSPIM_P1_NCS1 (nCS), XSPIM_P1_NCS2, XSPIM_P1_IO[7:0] (Data[7:0]), and XSPIM_P1_IO[15:8]. High speed interface 2 connects to Octal memory 2 via similar signals: XSPIM_P2_CLK (clk), XSPIM_P2_NCLK (nclk), XSPIM_P2_DQS0 (Data strobe), XSPIM_P2_NCS1 (nCS), XSPIM_P2_NCS2, XSPIM_P2_IO[7:0] (Data[7:0]). Alternate functions signals are also indicated.
MS55958V3
25.5.5 Two XSPIs multiplexed mode to Port 1 accessing two external memories
If only one output port is used to access two memories, alternate function signals can be routed to pins corresponding to the other port. This mode is selected by bits XSPIM_CR[1:0].
The arbiter in the IO manager selects XSPI1 or XSPI2 to own the octal-SPI bus according to the existing transfer requests and status of the two MAXTRAN fairness counters.
The external memories can be on separate chips, or embedded in a single multichip package. In this case, each memory requests a dedicated Chip select, selected according to the CSSEL control of the XSPI currently owning the bus.
The configuration signals of the high speed interface toggle when the corresponding XSPI is selected, because the timing characteristics of the two memories can be different.
Figure 220. XSPI multiplexed mode to Port 1

The diagram illustrates the XSPI I/O manager architecture for multiplexed mode to Port 1. The manager includes an AHB interface connected to an external AHB bus, a control register, and an arbiter. The arbiter manages access from XSPI1 and XSPI2 bus signals, which include signals like ACK1, REQ1, CS1, CSSEL1, CS2, CSSEL2, REQ2, and ACK2. The arbiter's output goes through dynamic muxing and static muxing to an I/O matrix. The I/O matrix connects to two high-speed interfaces. High-speed interface 1 provides signals: XSPIM_P1_CLK, XSPIM_P1_NCLK, XSPIM_P1_DQS0, XSPIM_P1_DQS1, XSPIM_P1_NCS1, XSPIM_P1_NCS2, XSPIM_P1_IO[7:0], and XSPIM_P1_IO[15:8]. High-speed interface 2 provides: XSPIM_P2_CLK, XSPIM_P2_NCLK, XSPIM_P2_DQS0, XSPIM_P2_NCS1, XSPIM_P2_NCS2, and XSPIM_P2_IO[7:0]. These interfaces connect to Octal memory 1 and Octal memory 2 within a Multichip package (MCP). Each memory has clk, nclk, Data strobe, nCS, and Data[7:0] pins. Configuration signals and alternate functions signals are also shown.
MS55959V3
25.5.6 Two XSPIs multiplexed mode to Port 2 accessing two external memories
This is similar to XSPI multiplexed mode to Port 1, but the target is Port 2. This mode is selected by bits XSPIM_CR[2:1].
Figure 221. XSPI multiplexed (octal and dual-octal) mode to Port 2

This diagram is similar to Figure 220, showing the XSPI I/O manager with its internal components (AHB interface, control register, arbiter, dynamic/static muxing, I/O matrix) and its connection to XSPI1 and XSPI2 bus signals. The key difference is in the high-speed interfaces. High-speed interface 1 connects to Port 1 of Octal memory 1, and High-speed interface 2 connects to Port 2 of Octal memory 2. The signals for Octal memory 1 are: clk, nclk, Data strobe, nCS, and Data[7:0]. The signals for Octal memory 2 are: clk, nclk, Data strobe, nCS, and Data[7:0]. The high-speed interface signals are: XSPIM_P1_CLK, XSPIM_P1_NCLK, XSPIM_P1_DQS0, XSPIM_P1_DQS1, XSPIM_P1_NCS1, XSPIM_P1_NCS2, XSPIM_P1_IO[15:0] for Port 1; and XSPIM_P2_CLK, XSPIM_P2_NCLK, XSPIM_P2_DQS0, XSPIM_P2_NCS1, XSPIM_P2_NCS2, XSPIM_P2_IO[7:0] for Port 2.
MS55961V4
Note: It is possible to connect a 16-bit memory on Port 1, whereas Port 2 uses multiplexing mode on two octal memories.
25.5.7 XSPI1 and XSPI2 drive a single external memory
This is similar to XSPIs multiplexed mode to Port 1, but in this case only one external memory is present. Both CSSEL controls must target the same NCS (NCS1 in Figure 222).
Figure 222. XSPI1 and XSPI2 drive a single external memory (octal mode)

The diagram illustrates the internal architecture of the XSPI I/O manager for driving a single external memory in octal mode.
- XSPI Interfaces: XSPI1 and XSPI2 blocks provide bus signals (REQ, ACK, CS, CSSEL) to the internal logic.
- XSPI I/O Manager: This central block contains:
- AHB interface: Connects to the external AHB bus.
- Control register: Manages the operation of the manager.
- Arbiter: Receives requests from XSPI1 and XSPI2 and directs them to the I/O matrix.
- Muxing: Includes static muxing and dynamic muxing to route signals.
- I/O matrix: Routes signals to the high-speed interfaces.
- High-speed Interfaces: Two interfaces (High speed interface 1 and 2) connect the I/O matrix to external signals.
- High speed interface 1: Outputs XSPIM_P1_CLK, XSPIM_P1_NCLK, XSPIM_P1_DQS0, XSPIM_P1_DQS1, XSPIM_P1_NCS1, XSPIM_P1_NCS2, and data bus XSPIM_P1_IO[7:0] and XSPIM_P1_IO[15:8].
- High speed interface 2: Outputs XSPIM_P2_CLK, XSPIM_P2_NCLK, XSPIM_P2_DQS0, XSPIM_P2_NCS1, XSPIM_P2_NCS2, and data bus XSPIM_P2_IO[7:0].
- Octal memory 1: The external memory block with pins for clk, nclk, Data strobe, nCS, and Data[7:0].
- Other signals: Alternate functions signals, Configuration signal selection, and Configuration signals are also shown.
Note: This use case is valid even when Port 2 is used instead of Port 1, and also possible with XSPI1 and XSPI2 interfacing a 16-bit memory (connecting XSPIM_P1_DQS1 to the memory).
25.5.8 A single XSPI drives two external memories
This is a subset of direct mode and corresponds to semi-dynamic switching. There are two target memories, but the arbiter is not used. The software must set the XSPI1 chip selector (bit 24 of the XSPI_CR register) each time the target memory changes.
The baseline use case boots on flash (memory1) and then switches to SRAM (memory2) for the rest of the application.
Figure 223. Single XSPI driving two external memories

The diagram illustrates the internal architecture of the XSPI I/O manager and its connection to external memories. The XSPI I/O manager is divided into two main sections: the AHB interface and the I/O matrix.
- AHB interface: Contains an AHB interface block and a Control register. It connects to the AHB bus.
- I/O matrix: Contains an Arbiter, Dynamic muxing, and Static muxing blocks. It receives XSPI1 bus signals (ACK1, REQ1, CS1, CSSEL1) and configuration signals. The Arbiter and Dynamic muxing handle dynamic signal routing, while the Static muxing handles static signal routing. The I/O matrix connects to two High speed interfaces (High speed interface 1 and High speed interface 2).
- High speed interfaces: These interfaces connect to a Multichip package (MCP) containing two Octal memories (Octal memory 1 and Octal memory 2). The signals connected are:
- XSPIM_P1_CLK, XSPIM_P1_NCLK, XSPIM_P1_DQS0 (for Octal memory 1)
- XSPIM_P1_NCS1, XSPIM_P1_NCS2 (for Octal memory 1 and 2)
- XSPIM_P1_IO[7:0], XSPIM_P1_IO[15:8] (for Octal memory 1 and 2)
- Configuration signal selection: A block that selects configuration signals for the I/O matrix.
- Alternate functions signals: A block that provides alternate function signals to the High speed interfaces.
The diagram is labeled with the reference number MS55965V3.
This use case shows a configuration using XSPI1 on Port 1. It is also valid if the instance is XSPI2 instead of XSPI1, but with MODE = 1. The use case is also valid when Port 2 is used instead of Port 1, by configuring MODE bit according to the instance (XSPI1 or XSPI2) driving the two external memories.
25.6 XSPIM registers
25.6.1 XSPIM control register (XSPIM_CR)
Address offset: 0x0000
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | REQ2ACK_TIME[7:0] | |||||||
| rw | rw | rw | rw | rw | rw | rw | rw | ||||||||
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CSSEL_OVR_O2 | CSSEL_OVR_O1 | CSSEL_OVR_EN | Res. | Res. | MODE | MUXEN |
| rw | rw | rw | rw | rw | |||||||||||
Bits 31:24 Reserved, must be kept at reset value.
Bits 23:16 REQ2ACK_TIME[7:0]: REQ to ACK time
In Multiplexed mode (MUXEN = 1), this field defines the time between two transactions.
The value is the number of XSPI clock cycles - 1
Bits 15:7 Reserved, must be kept at reset value.
Bit 6 CSSEL_OVR_O2: Chip select selector override setting for XSPI2
0: the chip select signal from XSPI2 is sent to NCS1
1: the chip select signal from XSPI2 is sent to NCS2
Bit 5 CSSEL_OVR_O1: Chip select selector override setting for XSPI1
0: the chip select signal from XSPI1 is sent to NCS1
1: the chip select signal from XSPI1 is sent to NCS2
Bit 4 CSSEL_OVR_EN: Chip select selector override enable
0: override not enabled
1: CSSEL_OVR_O1 and CSSEL_OVR_O2 bit values overwrite the CSSEL signal values coming from XSPI1 and XSPI2
Bits 3:2 Reserved, must be kept at reset value.
Bit 1 MODE: XSPI multiplexing mode
0: if MUXEN = 0 direct mode, if MUXEN = 1 arbitration mode to output Port 1
1: if MUXEN = 0 swapped mode, if MUXEN = 1 arbitration mode to output Port 2
Bit 0 MUXEN: Multiplexed mode enable
This bit enables the multiplexing of the two XSPIs.
0: No multiplexing, hence no arbitration
1: XSPI1 and XSPI2 are multiplexed over the same bus
25.6.2 XSPIM register map
Table 219. XSPIM register map and reset values
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x0000 | XSPIM_CR | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | REQ2ACK_TIME[7:0] | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | CSSEL_OVR_O2 | CSSEL_OVR_O1 | CSSEL_OVR_EN | Res. | Res. | MODE | MUXEN | |||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||||||||||
Refer to Section 2.3: Memory organization for the register boundary addresses.