cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H733: Commissioning of Flash ends in error. Wrong CubeMX configuration?

Moe
Associate II

Hello everyone,

I am trying to connect the Quad-SPI Flash "SST26VF064B" to my MCU STM32H733ZGT6. I followed the tutorial provided by ST on YouTube (The Video calls "MOOC - External QSPI loader how to"). When I use the function HAL_OSPI_AutoPolling(), I get "HAL_ERROR" as return value, which leads into Error_Handler().  The code that causes me the error looks like this:

 

void OSPI_AutoPollingMemReady(void)
{
   OSPI_RegularCmdTypeDef sCommand;
   OSPI_AutoPollingTypeDef sConfig;
   uint32_t temp = 0;

   /* ------ Configure automatic polling mode to wait for memory ready ------ */
   sCommand.Instruction = READ_STATUS_REG_CMD;
   sCommand.InstructionMode = HAL_OSPI_INSTRUCTION_4_LINES;
   sCommand.AddressMode = HAL_OSPI_ADDRESS_NONE;
   sCommand.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
   sCommand.DataMode = HAL_OSPI_DATA_4_LINES;
   sCommand.DummyCycles = 1;
   sCommand.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;

   if (HAL_OSPI_Command(&hospi1, &sCommand, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
   {
       Error_Handler();
   }

   sConfig.Match = 0x00;
   sConfig.Mask = 0x01;
   sConfig.MatchMode = HAL_OSPI_MATCH_MODE_AND;
   sConfig.Interval = 0x10;
   sConfig.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;

   HAL_Delay(1);

   if (HAL_OSPI_AutoPolling(&hospi1, &sConfig, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
   {
      Error_Handler();
   }
}

 

The "HAL_ERROR" return value is caused by the following location in the file "stm32h7xx_hal_ospi.c":

 

/* Check the state */
if ((hospi->State == HAL_OSPI_STATE_CMD_CFG) && (cfg->AutomaticStop == HAL_OSPI_AUTOMATIC_STOP_ENABLE))
{
   ...
}

 

If I start debugging and go into function HAL_OSPI_AutoPolling(), then I noticed that hospi->State != HAL_OSPI_STATE_CMD_CFG (hospi->State should have the value 4 but instead it has the value 20)

1st Question: Am I using the sCommand and sConfig structures correctly? What could be the cause for the HAL_ERROR return value?

2nd Question: When configuring CubeMX I noticed that I have to specify the memory type. The flash I use is from the manufacturer "Microchip". This is not listed in CubeMX. Which memory type should I select (see picture below)?

Moe_0-1693904033667.png

Unfortunately I can't upload my IOC file because I get an error message from the ST website which says "The attachment's flashstm32h733.ioc content type (application/octet-stream) does not match its file extension and has been removed". Unfortunately I don't know what could be the reason for this.

Thanks for support and best regards! 

4 REPLIES 4
KDJEM.1
ST Employee

Hello @Moe ,

When using the QSPI mode, if the memory supported the Octo-SPI interface, any memory type can be chosen. The functionality of the QSPI is not affected by the memory type used. This behavior is mentioned in AN5050 and precisely in OCTOSPI configuration and parameter settings Section " 2. The memory type has no impact in Quad-SPI mode".

I recommend when configure the OCTOSPI interface to get inspired from the OCTOSPI application examples shared in AN5050. I hope this help you!

If the issue isn't solved, could you please share your project with .7z format?

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.

Hello @KDJEM.1

first of all thank you for your answer. Attached you will find my IOC file in 7z. format

I will also read the AN5050 again carefully. Do you know maybe how the value at "hospi1->State == 2" comes about?

KDJEM.1
ST Employee

Hello @Moe ,

The Device Size configured in STM32Cube MX indicates the size of the OSPI memory in bytes and expressed in 2^n.  For this memory type the Device Size should be 23.

Could you please check the OCTOSPI clock frequency, for that I advise you to refer to Table 76. OCTOSPI characteristics in SDR mode and Table 77. OCTOSPI characteristics in DTR mode (no DQS) in the datasheet .

Note that the OCTOSPI clock frequency depends from the VDD and CLOAD.

I hope this help you to solve the issue.

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.

Hello @KDJEM.1 ,

thank you for your response. 


I have now reduced the OCTOSPI frequency to 20 MHz and also adjusted the device size, unfortunately the problem is still there. however, I have found something else curious: 

In my firmware I use the HAL_OSPI_Command command several times and every time I execute it I could measure activity on the SPI bus with the oscilloscope. In the program snippet I posted (see my first post), I use the HAL_OSPI_Command there too butI notice that no SPI activity can be measured. What could be the reason for this? Is there any register of the OCTOSPI which I should look at?