Skip to main content
luisfynn1
Associate II
April 7, 2026
Solved

Correct HAL Library for HSPI to control QSPI Flash (MX25L51245G) on STM32U5G9

  • April 7, 2026
  • 1 reply
  • 119 views

Hi,

I am using the STM32U5G9 and trying to control a QSPI Flash (MX25L51245GXDI) using the HSPI peripheral.

I am confused about which official HAL library and functions I should use for this specific configuration. Since the hardware is named HSPI but the Flash is QSPI, it is unclear which driver is the intended one.

Could you please clarify which of the following should be used?

  • HAL_SPI_... (Standard SPI functions)

  • HAL_XSPI_... (Expanded SPI functions)

  • HAL_QSPI_... (Quad SPI functions)

  • HAL_OSPI_... (Octo-SPI functions)

There is no stm32u5xx_hal_hspi.c provided in the firmware package, and using HAL_QSPI_... or HAL_SPI_... functions with the HSPI1 instance results in type-casting errors and compilation failures.

Please provide the official recommendation on which HAL driver is mandatory for driving a 4-line Quad SPI Flash through the HSPI interface on the STM32U5G9 series.

Best regards,

Best answer by Saket_Om

Hello @luisfynn1 

To communicate with a Quad‑SPI Flash using the HSPI peripheral, you should use the XSPI HAL driver, which provides the firmware functions to manage the OctoSPI/HSPI (XSPI) interface.

The XSPI peripheral can be configured to run in Quad mode (4 I/O lines), which is the recommended configuration for driving an external Quad‑SPI Flash connected to HSPI1.

 
 
 

 

1 reply

Saket_OmBest answer
Technical Moderator
April 7, 2026

Hello @luisfynn1 

To communicate with a Quad‑SPI Flash using the HSPI peripheral, you should use the XSPI HAL driver, which provides the firmware functions to manage the OctoSPI/HSPI (XSPI) interface.

The XSPI peripheral can be configured to run in Quad mode (4 I/O lines), which is the recommended configuration for driving an external Quad‑SPI Flash connected to HSPI1.

 
 
 

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"