27. Extended-SPI I/O manager (OCTOSPIM)
27.1 Introduction
The Extended-SPI I/O manager is a low-level interface that enables an efficient OCTOSPI pin assignment with a full I/O matrix (before alternate function map), and multiplex of single/dual/quad/octal SPI interfaces over the same bus.
27.2 OCTOSPIM main features
- • Supports up to two single/dual/quad/octal SPI interfaces
- • Supports up to two ports for pin assignment
27.3 OCTOSPIM implementation
The following table describes the OCTOSPIM implementation.
Table 253. OCTOSPIM implementation
| OCTOSPI 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 | - |
| Chip select selection if OCTOSPI provides dual chip select | X |
| Supports 16-bit data interface and dual-octal mode | - |
27.4 OCTOSPIM functional description
27.4.1 OCTOSPIM block diagram
The block diagram of the OCTOSPI I/O manager is shown in Figure 197.
Figure 197. OCTOSPIM block diagram![OCTOSPIM block diagram showing the OCTOSPI I/O manager with AHB interface, control register, arbiter, static muxing, dynamic muxing, and I/O matrix connected to Port 1 and Port n. OCTOSPI1 and OCTOSPI2 bus signals connect to the arbiter and muxing logic, outputting signals OCTOSPIM_P1_CLK, OCTOSPIM_P1_NCLK, OCTOSPIM_P1_DQS, OCTOSPIM_P1_NCS1, OCTOSPIM_P1_NCS2, OCTOSPIM_P1_IO[7:0] and OCTOSPIM_Pn_*.](/RM0517-STM32H5E4-5F4-5E5-5F5/ee62178206c737fbdb90b1c8285f1356_img.jpg)
1. The number of ports (n) is 2.
27.4.2 OCTOSPIM input/output pins
Table 254. OCTOSPIM input/output pins| Pin name(1) | Signal type | Description |
|---|---|---|
| OCTOSPIM_Px_NCLK | Output | OCTOSPI inverted clock to support 1.8 V HyperBus protocol |
| OCTOSPIM_Px_CLK | OCTOSPI clock | |
| OCTOSPIM_Px_IOn (n = 0 to 7) | Input/output | OCTOSPI data pins |
| OCTOSPIM_Px_NCS1,2 | Output | Chip select for the memories |
| OCTOSPIM_Px_DQS | Input/output | Data strobe/write mask signal from/to the memory |
1. x = 1 to 2.
27.4.3 OCTOSPIM matrix
The OCTOSPI I/O manager matrix allows the user to set a premapping of functions:
- • OCTOSPI1 mapped to Port 1, with OCTOSPI2 mapped to Port 2 (direct mode)
- • OCTOSPI1 mapped to Port 2, with OCTOSPI2 mapped to Port 1 (swapped mode)
- • OCTOSPI1 and OCTOSPI2 both mapped to Port 1, with arbitration (multiplexed mode)
- • OCTOSPI1 and OCTOSPI2 both mapped to Port 2, with arbitration (multiplexed mode)
Note: There is no possibility to use mixed combinations of signals (like NCS of OCTOSPI1 with data of OCTOSPI2).
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, the OCTOSPI1 and OCTOSPI2 signals are mapped, respectively, on Port 1 and on Port 2.
The OCTOSPIM configuration can be changed only when all OCTOSPIs are disabled.
27.4.4 OCTOSPIM multiplexed mode
When this mode is set, the OCTOSPIs 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 of the configuration register OCTOSPIM_CR.
The fairness counter (MAXTRAN) of each OCTOSPI can be used to manage accurately the maximum duration for which a given OCTOSPI takes the bus: this feature ensures a maximum bus access latency for the other OCTOSPI(s). When the bus is released by one OCTOSPI, an arbitration phase occurs, which is round-robin: when another OCTOSPI requests the bus, it gets it.
When the multiplexed mode is enabled, either the fairness counter or the refresh timeout counter of both OCTOSPI interfaces must be activated.
Each OCTOSPI 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 OCTOSPI owning the bus. The default value of OCTOSPIM_CR.CSSEL is 0 for OCTOSPI1 and 1 for OCTOSPI2. Only OCTOSPIIn_IOs, OCTOSPIIn_DQS and OCTOSPIIn_CLK / OCTOSPIIn_NCLK are multiplexed.
When the multiplexed mode is used, only clock mode 0 is supported on the OCTOSPIs.
Due to arbitration and bus sharing, the auto polling interval time of the OCTOSPI, when used, may increase.
Minimum switching duration
The minimum number of cycles needed to switch from an OCTOSPI to another can be configured.
This internal timer guarantees a latency between the falling edge of the REQ signal of the active OCTOSPI (the active one releases the bus), and the rising edge of the ACK signal to the requesting OCTOSPI (the bus is granted to the requesting one).
The REQ2ACK_TIME field of the configuration register OCTOSPIM_CR defines the duration.
27.5 Use cases description
Table 255 summarizes the use cases corresponding to IO manager modes.
Table 255. Use cases
| IO manager mode | MUXEN | Mode | Reference |
|---|---|---|---|
| Direct | 0 | 0 | Section 27.5.1 |
| Swapped | 0 | 1 | Section 27.5.2 |
Table 255. Use cases (continued)
| IO manager mode | MUXEN | Mode | Reference |
|---|---|---|---|
| Multiplexed to Port1 | 1 | 0 | Section 27.5.3 |
| Multiplexed to Port2 | 1 | 1 | Section 27.5.4 |
| Two OCTOSPIs drive one external memory | 1 | 0 or 1, depending upon the port connected to the memory | Section 27.5.5 |
| One OCTOSPI drives two external memories | 0 | 0 with CS selection command from OCTOSPI1 or 2. | Section 27.5.6 |
27.5.1 Two OCTOSPIs direct mode
This is the baseline mode: each OCTOSPI drives independently the corresponding port. There is no multiplexing.
Alternate function signals can be routed on NCS2 pins (these signals are not used for the OCTOSPI bus), nclk clocks are requested in case of 1.8 V HyperBus memory type.
This mode is selected by default through bits OCTOSPIM_CR[1:0].
Figure 198. OCTOSPI direct mode

The diagram illustrates the OCTOSPI direct mode architecture. The OCTOSPI I/O manager is the central component, containing an AHB interface, a Control register, and a PnCR register. It features an Arbiter that receives signals from two OCTOSPI blocks (OCTOSPI1 and OCTOSPI2). OCTOSPI1 provides signals: OCTOSPI1 bus signals, ACK1, REQ1, CS1, and CSSEL1. OCTOSPI2 provides: OCTOSPI2 bus signals, REQ2, ACK2, CS2, and CSSEL2. The Arbiter's output goes through Dynamic muxing to an I/O matrix. The I/O matrix has two ports: Port 1 and Port 2. Port 1 is connected to Octal memory 1 via static muxing, with signals: OCTOSPIM_P1_CLK (clk), OCTOSPIM_P1_NCLK (nclk), OCTOSPIM_P1_DQS (Data strobe), OCTOSPIM_P1_NCS1 (nCS), OCTOSPIM_P1_NCS2, and OCTOSPIM_P1_IO[7:0] (Data[7:0]). Port 2 is connected to Octal memory 2 with similar signals: OCTOSPIM_P2_CLK (clk), OCTOSPIM_P2_NCLK (nclk), OCTOSPIM_P2_DQS (Data strobe), OCTOSPIM_P2_NCS1 (nCS), OCTOSPIM_P2_NCS2, and OCTOSPIM_P2_IO[7:0] (Data[7:0]).
27.5.2 OCTOSPI swapped mode
This mode is similar to OCTOSPI direct mode but the ports are swapped, for example to help I/O mapping. The mode is selected by bits OCTOSPIM_CR[1:0].
Figure 199. OCTOSPI swapped mode

The diagram illustrates the OCTOSPI swapped mode architecture. The OCTOSPI I/O manager is the central component, containing an AHB interface, a Control register, and a P1CR register. It interfaces with two OCTOSPI blocks (OCTOSPI1 and OCTOSPI2) via bus signals. OCTOSPI1 provides signals: OCTOSPI1 bus signals, ACK1, REQ1, CS1, and CSSEL1. OCTOSPI2 provides signals: OCTOSPI2 bus signals, REQ2, ACK2, CS2, and CSSEL2. These signals are processed by an Arbiter and then pass through Dynamic and Static muxing stages. The I/O matrix contains Port 1 and Port 2. Port 1 is connected to external Octal SPI memory 1 via signals: OCTOSPIM_P1_CLK (clk), OCTOSPIM_P1_NCLK (nclk), OCTOSPIM_P1_DQS (Data strobe), OCTOSPIM_P1_NCS1 (nCS), and OCTOSPIM_P1_IO[7:0] (Data[7:0]). Port 2 is connected to external Octal SPI memory 2 via signals: OCTOSPIM_P2_CLK (clk), OCTOSPIM_P2_NCLK (nclk), OCTOSPIM_P2_DQS (Data strobe), OCTOSPIM_P2_NCS2 (nCS), and OCTOSPIM_P2_IO[7:0] (Data[7:0]).
27.5.3 Two OCTOSPIs 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 OCTOSPIM_CR[1:0].
The arbiter in IO manager selects OCTOSPI1 or OCTOSPI2 to own the Octal-SPI bus according to existing transfer requests and status of the two MAXTRAN fairness counters.
The external memories can be two 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 OCTOSPI currently owning the bus.
Figure 200. OCTOSPI multiplexed mode to Port 1
![Block diagram of OCTOSPI multiplexed mode to Port 1. The diagram shows the OCTOSPI I/O manager block containing an AHB interface, control register, P1CR, PnCR, arbiter, dynamic muxing, static muxing, and an I/O matrix with Port 1 and Port 2. OCTOSPI1 and OCTOSPI2 blocks provide bus signals (ACK1, REQ1, CS1, CSSEL1, CS2, CSSEL2, REQ2, ACK2) to the arbiter. The I/O matrix connects to external signals: OCTOSPIM_P1_CLK, OCTOSPIM_P1_NCLK, OCTOSPIM_P1_DQS, OCTOSPIM_P1_NCS1, OCTOSPIM_P1_NCS2, and OCTOSPIM_P1_IO[7:0] for Port 1; and OCTOSPIM_P2_CLK, OCTOSPIM_P2_NCLK, OCTOSPIM_P2_DQS, OCTOSPIM_P2_NCS1, OCTOSPIM_P2_NCS2, and OCTOSPIM_P2_IO[7:0] for Port 2. These signals interface with a Multichip package (MCP) containing Octal memory 1 and Octal memory 2, each with clk, nclk, Data strobe, nCS, and Data[7:0] pins.](/RM0517-STM32H5E4-5F4-5E5-5F5/5c533826bda78697f5e4f82574d8bd33_img.jpg)
27.5.4 Two OCTOSPIs multiplexed mode to Port 2 accessing two external memories
This is similar to OCTOSPI multiplexed mode to Port 1, but target is Port 2. This mode is selected by bits OCTOSPIM_CR[2:1].
Figure 201. OCTOSPI multiplexed mode to Port 2

27.5.5 OCTOSPI1 and OCTOSPI2 drive a single external memory
This is similar to OCTOSPIs 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 202).
Figure 202. OCTOSPI1 and OCTOSPI2 drive a single external memory

Diagram details: Shows OCTOSPI I/O manager connected to AHB via AHB interface and Control register (P1CR, PnCR). OCTOSPI1 provides bus signals, ACK1, REQ1, CS1, CSSEL1. OCTOSPI2 provides bus signals, ACK2, REQ2, CS2, CSSEL2. REQ and CSSEL signals enter the Arbiter. Static and Dynamic muxing route signals to the I/O matrix (Port 1 and Port 2). Port 1 outputs OCTOSPIM_P1_CLK, OCTOSPIM_P1_NCLK, OCTOSPIM_P1_DQS, OCTOSPIM_P1_NCS1, OCTOSPIM_P1_NCS2, OCTOSPIM_P1_IO[7:0] to external Octal memory 1 (clk, nclk, Data strobe, nCS, Data[7:0]).
This use case is valid even when Port 2 is used instead of Port 1.
27.5.6 A single OCTOSPI 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 has to set the OCTOSPI1 chip select selector (bit 24 of OCTOSPI_CR register) each time the target memory changes.
Baseline use case boots on flash (memory1) and then switches to SRAM (memory2) for the rest of the application.
Figure 203. Single OCTOSPI driving two external memories
![Block diagram of a single OCTOSPI driving two external memories. The diagram shows an OCTOSPI1 block connected to an OCTOSPI I/O manager. Inside the manager, an AHB interface connects to an AHB bus. A control register and P1CR/PnCR registers are also present. The OCTOSPI1 bus signals (ACK1, REQ1, CS1, CSSEL1) are processed by an arbiter and dynamic muxing, then pass through static muxing to an I/O matrix. Port 1 of the I/O matrix connects to external signals: OCTOSPIM_P1_CLK, OCTOSPIM_P1_NCLK, OCTOSPIM_P1_DQS, OCTOSPIM_P1_NCS1, OCTOSPIM_P1_NCS2, and OCTOSPIM_P1_IO[7:0]. These signals are connected to two Octal memories (memory 1 and memory 2) within a Multichip package (MCP). Each memory has clk, nclk, Data strobe, nCS, and Data[7:0] pins.](/RM0517-STM32H5E4-5F4-5E5-5F5/6a9ae1c150efbd249590edf0d045852b_img.jpg)
This use case is valid even when OCTOSPI2 is used instead of OCTOSPI1.
27.6 OCTOSPIM registers
27.6.1 OCTOSPIM control register (OCTOSPIM_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 OCTOSPI clock cycles - 1
Bits 15:7 Reserved, must be kept at reset value.
Bit 6 CSSEL_OVR_O2: Chip select selector override setting for OCTOSPI2
0: the chip select signal from OCTOSPI2 is sent to NCS1
1: the chip select signal from OCTOSPI2 is sent to NCS2
Bit 5 CSSEL_OVR_O1: Chip select selector override setting for OCTOSPI1
0: the chip select signal from OCTOSPI1 is sent to NCS1
1: the chip select signal from OCTOSPI1 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 OCTOSPI1 and OCTOSPI2
Bits 3:2 Reserved, must be kept at reset value.
Bit 1 MODE: OCTOSPIM 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 OCTOSPIs.
0: No multiplexing, hence no arbitration
1: OCTOSPI1 and OCTOSPI2 are multiplexed over the same bus.
27.6.2 OCTOSPIM register map
Table 256. OCTOSPIM 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 | OCTOSPIM_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 on page 140 for the register boundary addresses.