cancel
Showing results for 
Search instead for 
Did you mean: 

BSP QSPI vs CubeMx Initialization Difference

DWill.4
Associate II

l have initialized the Micron MT25TL01G QSPI chip with the BSP_QSPI_Init() function. I am able to read, write, and erase data to the QSPI using the underlying MT25TL01G functions beneath the BSP. Whenever l remove the BSP initialization l don't receive an output from MT25TL01G_ReadDTR().

This may sound silly, but doesn't CubeMx initialize the QSPI Chip with HAL_QSPI_Init?

Could this be an QSPI_MspInit() vs HAL_QSPI_MspInit() configuration issue?

Parameters:

 /* QUADSPI parameter configuration*/

 hqspi.Instance = QUADSPI;

 hqspi.Init.ClockPrescaler = 2;

 hqspi.Init.FifoThreshold = 4;

 hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE;

 hqspi.Init.FlashSize = 25;

 hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_2_CYCLE;

 hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;

 hqspi.Init.FlashID = QSPI_FLASH_ID_1;

 hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;

 if (HAL_QSPI_Init(&hqspi) != HAL_OK)

 {

  Error_Handler();

 }

 /* USER CODE BEGIN QUADSPI_Init 2 */

 BSP_QSPI_Init_t init;

 init.InterfaceMode = MT25TL01G_QPI_MODE;

 init.TransferRate = MT25TL01G_DTR_TRANSFER;

 init.DualFlashMode = MT25TL01G_DUALFLASH_DISABLE;

 if (BSP_QSPI_Init(0, &init) != BSP_ERROR_NONE)

 {

    Error_Handler();

 }

 /* USER CODE END QUADSPI_Init 2 */

1 ACCEPTED SOLUTION

Accepted Solutions
Andreas Bolsch
Lead II

By inspecting the source code of HAL_QSPI_Init you will see that this function initializes only the QSPI interface (within the STM32), not the flash chip. Most SPI flash chips power up in SPI mode (single line), 3-byte address, STR. As you apparently intend to use QPI, 4-address, DTR, the flash chip must be configured accordingly. Number of dummy cycles is another point. How this is done depends heavily on the flash model, so ...

Some flash devices allow non-volatile configuration, but this must be done once, too. Hence no way to omit the configuration step.

View solution in original post

1 REPLY 1
Andreas Bolsch
Lead II

By inspecting the source code of HAL_QSPI_Init you will see that this function initializes only the QSPI interface (within the STM32), not the flash chip. Most SPI flash chips power up in SPI mode (single line), 3-byte address, STR. As you apparently intend to use QPI, 4-address, DTR, the flash chip must be configured accordingly. Number of dummy cycles is another point. How this is done depends heavily on the flash model, so ...

Some flash devices allow non-volatile configuration, but this must be done once, too. Hence no way to omit the configuration step.