Skip to main content
Epamuk
Associate III
April 24, 2026
Solved

Two OSPI usage in STM32U599

  • April 24, 2026
  • 2 replies
  • 90 views

Hello, 

Is it possible to use two OSPI with below configuration.  I can make this configuration in cubeMx but whiel debugging ospi1 is not working after ospi2 initialize. 

 

Epamuk_1-1777024547409.pngEpamuk_2-1777024564617.pngEpamuk_3-1777024580076.png

Epamuk_4-1777024592601.png

Epamuk_5-1777024603515.png

 

Best answer by Epamuk

Hello, my code was like (cubeMX created that)

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_HIGH;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

I added only  sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH; to OSPI1 init like below

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 and it works fine .  

Thanks

2 replies

KDJEM.1
Technical Moderator
April 24, 2026

Hello @Epamuk ;

 

First of all thank you for sharing this behavior in the community.

Could you please look at this issue Solved: OCTOSPI: HAL_OSPIM_Config() - STMicroelectronics Community. I think you are experiencing the same issue.

 

To solve the issue could you please try to modify these code lines in octospi.c file

 

 

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }
 

 

 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_HIGH;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

by

 

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 sOspiManagerCfg.DQSPort = 1;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 

 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 sOspiManagerCfg.DQSPort = 2;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

Please let me know if the issue is solved or not?

Thank you.

Kaouthar

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.
Epamuk
EpamukAuthorBest answer
Associate III
April 24, 2026

Hello, my code was like (cubeMX created that)

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 

 sOspiManagerCfg.ClkPort = 2;
 sOspiManagerCfg.NCSPort = 2;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_HIGH;
 if (HAL_OSPIM_Config(&hospi2, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

I added only  sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH; to OSPI1 init like below

 sOspiManagerCfg.ClkPort = 1;
 sOspiManagerCfg.NCSPort = 1;
 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;
 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
 {
 Error_Handler();
 }

 and it works fine .  

Thanks

KDJEM.1
Technical Moderator
April 24, 2026

Hello @Epamuk ,

 

Glad to know that the issue is solved.

This issue is already reported internally to STM32CubeMX for more investigation and fixing.

Internal ticket number: 203289 (This is an internal tracking number and is not accessible or usable by customers

 

Please click on  Accept as Solution on the reply which solved your issue.

 

Thank you.

Kaouthar

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.