cancel
Showing results for 
Search instead for 
Did you mean: 

W25Q80DV QSPI with STM32F412VET3 - Strange things I don't understand.

Lq
Visitor

Hi everyone.

So I have W25Q80DV QSPI with STM32F412VET, I would like to use it to store some data. As per datasheet for W25Q80DV its flash is 8mbit and so I have the following initialization code : 

hqspi.Instance = QUADSPI;

hqspi.Init.ClockPrescaler = 2;

hqspi.Init.FifoThreshold = 1;

hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;

hqspi.Init.FlashSize = 19;

hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;

hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;

hqspi.Init.FlashID = QSPI_FLASH_ID_2;

hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;

HAL_StatusTypeDef status = HAL_QSPI_Init(&hqspi);


According to the datasheet, FlashSize should be 19, since the flash size is 8mbit. But with flashsize being 19, the write operations (particlarly when I call HAL_Transmit) times out.
If I set the FlashSize to 31, it works as expected which I find odd.

Additionally my code for writing :


static
HAL_StatusTypeDef QSPI_PageProgram(uint32_t addr, uint8_t *txBuf) {
QSPI_CommandTypeDef s_command = {0};

s_command.InstructionMode = QSPI_INSTRUCTION_1_LINE;

s_command.Instruction = PAGE_PROGRAM_CMD;

s_command.AddressMode = QSPI_ADDRESS_1_LINE;

s_command.AddressSize = QSPI_ADDRESS_24_BITS; // 24-Bit-Adresse

s_command.Address = addr;

s_command.DataMode = QSPI_DATA_1_LINE;

s_command.DummyCycles = 0;

s_command.NbData = 4;

s_command.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;




HAL_StatusTypeDef status = HAL_QSPI_Command(&hqspi, &s_command, HAL_QSPI_TIMEOUT_DEFAULT_VALUE);

if (status != HAL_OK) {

return status;

}




status = HAL_QSPI_Transmit(&hqspi, txBuf, HAL_QSPI_TIMEOUT_DEFAULT_VALUE); //TIMEOUT here with flashsize = 19




return status;

}



One more question : Since I am new to embedded stuff I don't fully understand how the external flash memory actually works. If I would like to use the QSPI I assume I need to flash it somehow using CubeProgrammer, probably by using an external loader. Because when I debug using the IDE, it works as expected (despite difficulty to debug - I guess I need to enable memory mapping mode).

but it is not clear to me how to do this, there are some external loaders available in CubeProgrammer but not for my board

Thanks!

 

0 REPLIES 0