2023-04-28 02:09 PM
I'm using BL-475E-IOTA2 board (STM32L475) which comes with MX25R6435F Flash chip. I'm trying to using Quad SPI to write and read to/from the flash chip.
With free running the code(release mode):
in stm32l4xx_hal_qspi.c, HAL_QSPI_Command() returns HAL_BUSY.
With single stepping through the code, with DMA or no DMA, it writes and reads the flash chip fine.
I tried QSPI clock prescaler of 1,2,3 but it didn't help. Sys clk and HCLK (to DMA) is 80MHz
I also tried adding a 1s delay before and after writing the write enable command to the flash, but it still failed the same way.
What could cause this problem?
Solved! Go to Solution.
2023-04-28 02:48 PM
>>What could cause this problem?
NOR Flash devices are relatively slow for Write and Erase cycles, it's a stateful process, and not one tuned to cramming down data.
The write buffer (page) is 256-bytes, writes will need to be decomposed into page aligned, and page sized (max) transactions. The memory will then need to come ready before other non-status commands can be sent.
Make sure the HAL DMA commands actually complete, the functions should return immediatly, and don't block, you'll need to do that via your own waiting/callback mechanics. I doubt DMA is going to be profoundly faster.
2023-04-28 02:48 PM
>>What could cause this problem?
NOR Flash devices are relatively slow for Write and Erase cycles, it's a stateful process, and not one tuned to cramming down data.
The write buffer (page) is 256-bytes, writes will need to be decomposed into page aligned, and page sized (max) transactions. The memory will then need to come ready before other non-status commands can be sent.
Make sure the HAL DMA commands actually complete, the functions should return immediatly, and don't block, you'll need to do that via your own waiting/callback mechanics. I doubt DMA is going to be profoundly faster.
2023-05-02 08:38 AM
Thank you! Yep you're right the write and some command operations are slow. After writing data to the flash chip and before calling HAL_QSPI_AutoPolling() to wait for the memory to be ready, I have to wait for QSPI_HandleTypeDef.State to be HAL_QSPI_STATE_READY first (ie when it finishes writing all data).