cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H745I-DISCO, problem porting QSPI_MemoryMappedDual example on a brand new CubeMX project with default initialization of the board.

simosilva
Senior

Started with the example that can be found on STM32H7 Github at https://github.com/STMicroelectronics/STM32CubeH7/tree/v1.9.0/Projects/STM32H745I-DISCO/Examples/QSPI/QSPI_MemoryMappedDual , I tried to port it into a brand new project generated with CubeMX for the target board STM32H745I-DISCO.

First said, it would be nice if examples include also the CubeMX project file with "default settings for peripherals", this will really speed-up the prototyping phase, with benefit for developers and so for STM itself.

Back to the problem, I tried change clock and peripheral settings to match the configuration found in the esample file, nothing worked for me for now, I will certainly dig more to find a working solution, but would be nice if you can provide a working CubeMX-generated example for that (and maybe also others) memory.

Thank you, let's stay in touch.

1 ACCEPTED SOLUTION

Accepted Solutions
simosilva
Senior

Hello @Imen DAHMEN​ and thanks for your message.

I managed the issue and now is working, clock and peripheral settings were wrong, the message i wanted to pass is that would be really better for both STM and developers to have example code all based on the same basic system configuration (one with all the Discovery board peripheral initialized, and then using only the related one of the example), this will speed up the development and don't waste STM Employee time with questions like mine :p

So please just mention this internally to STM!

Have a good day, stay safe!

Bye!

View solution in original post

6 REPLIES 6
Imen.D
ST Employee

Hello @simosilva​ and welcome to the STM32 Community,

If possible to share your configuration or your code.

It maybe there is an issue when you port the example.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
simosilva
Senior

Hello @Imen DAHMEN​ and thanks for your message.

I managed the issue and now is working, clock and peripheral settings were wrong, the message i wanted to pass is that would be really better for both STM and developers to have example code all based on the same basic system configuration (one with all the Discovery board peripheral initialized, and then using only the related one of the example), this will speed up the development and don't waste STM Employee time with questions like mine :p

So please just mention this internally to STM!

Have a good day, stay safe!

Bye!

Imen.D
ST Employee

Hi @simosilva​ ,

I'm glad to know the issue has been solved 😀 .

Thanks for your feedback, I have raised it internally to our development team to to be reviewed.

Thank you once again for your contribution.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
simosilva
Senior

Hi,

mumble mumble, i was wrong the code do not run.

Coming back on the project some week later, Error handler and no QSPI operations.. referring to your code from your github, copied and pasted in mine example CubeMX generated, the code is stuck into QSPI_EnterFourBytesAddress(&QSPIHandle); (line 132) which is the very first QSPI command.

Checking the Pin config of the brand new CubeMX STM32H745I-DISCO i found some issues and changed them, but was not resolutive for me.

SystemClock_Config

in esample code there are following lines, that i cannot force in any way into CubeMX, so i must add them every time I generate the code by hand

RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;

Same for RCC_OscInitStruct.PLL.PLLR = 4; that is blocked to 4 into cubeMX that i have to set to 2 according to your example and i cannot change in the clock tree into CubeMX.

Same for if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK), cannot be set to 4 in CubeMX, changed by hand.

I/O Compensation Cell also added by hand into an USER CODE begin-end section.

Changing these values, SystemClock_Config and RCC matches the example one seem the same to your example.

QSPI Initialization

QSPI pins activating it on M7 came with wrong pin assignment, BK2_IO2 and BK2_IO3 are by default set respectively to (P9)-PE9 and (N9)-PE10 but in your example code are set on (A10)-PG9 and (D8)-PG14, others seem the same checking them by hand.

This need to be changed, discovery boards myst have working default peripheral intialization if I'm not hacking or adding things on the board! :face_with_steam_from_nose:

Then i also added

HAL_NVIC_SetPriority(QUADSPI_IRQn, 0x0F, 0);
HAL_NVIC_EnableIRQ(QUADSPI_IRQn);

To enable IRQs, but code still exit in Error handler with timeout exception after 5 secs..

I just use the hqspi instance generated from CubeMX instead of the QSPIHandle in your example code, changing it inside the main loop QSPIHandle->hqspi in every call.

What I'm missing here?

Thanks

simosilva
Senior

Found the mistake!

CubeMX code generated for QSPI do not change modifying CubeMX settings.

Changing Chip select for Dual bank, NO REFLECTION ON THE GENERATED CODE, even deleting the previous quadspi.c file by hand.

The CubeMX generated chip select GPIO_InitStruct for BK1 is:

GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_QUADSPI;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

This is WRONG! The port must be GPIOG!

Then, also selecting "Enable Chip Select 1 for both banks", the init for the BK2_NCS still remain in quadspi.c:

GPIO_InitStruct.Pin = GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_QUADSPI;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

ERROR! This section must NOT be generated if only the CS1 is used for both banks!

Other errors to be changed into CubeMX gneration process are the ones listed in the above message, pins for QUADSPI_BK2_IO2 and QUADSPI_BK2_IO3 wrong assignments.

@Imen DAHMEN​ Please tag all the related colleagues to fix the CubeMX bugs asap.

For those who came here for QSPI related problems, here some tips to include in your code to make the QSPI work correctly:

  • enable I/O compensation cell
  • Enable I and D cache
  • Set all the QUADSPI GPIO pins "Maximum output speed" to Very High into CubeMX>Pinout&Configuration>GPIO>QUADSPI section
  • Set the QUADSPI_nCS to PULLUP and leave all the other QUADSPI_BK#_IO# to no-pull-up-and-no-pull-down
  • Enable QSPI global interrupt from CubeMX>Pinout&Configuration>Connectivity>QUADSPI>NVIC Settings>QUADSPI global interrupt> check the enabled square
  • to select a specific QSPI Flash Bank, you must add hqspi.Init.FlashID = QSPI_FLASH_ID_2; (like in the ST example) or QSPI_FLASH_ID_1

Hi @simosilva​ ,

Thanks for sharing update on your issue and bringing this to my attention. 

I really appreciate your feedback and sharing tips 🙂 This will be useful for other Community users.

Hello CubeMx team (​  @Houda GHABRI​ , @Khouloud OTHMAN​ , @Khouloud ZEMMELI​ )

Can you please review the reported QSPI issues related to CubeMX tool ?

Thanks,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen