2025-02-12 04:22 AM - last edited on 2025-02-12 04:38 AM by Andrew Neil
Hi,
I am trying to read device id of the W25Q16JV Flash Memory (3V 16M-BIT SERIAL FLASH MEMORY WITH DUAL/QUAD SPI) using the STM32G474RBT4 Nucleo board via QSPI lines.
I hereby attach the ioc settings and the code used:
static void MX_QUADSPI1_Init(void)
{
/* QUADSPI1 parameter configuration*/
hqspi1.Instance = QUADSPI;
hqspi1.Init.ClockPrescaler = 1;
hqspi1.Init.FifoThreshold = 4;
hqspi1.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE;
hqspi1.Init.FlashSize = 20;
hqspi1.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;
hqspi1.Init.ClockMode = QSPI_CLOCK_MODE_0;
hqspi1.Init.FlashID = QSPI_FLASH_ID_1;
hqspi1.Init.DualFlash = QSPI_DUALFLASH_DISABLE;
if (HAL_QSPI_Init(&hqspi1) != HAL_OK)
{
Error_Handler();
}
}
Code to read Device ID:
HAL_StatusTypeDef QSPI_ReadID( uint8_t *id)
{
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.Instruction = READ_JEDEC_ID_CMD; // 0x9F
sCommand.AddressMode = QSPI_ADDRESS_NONE;
//sCommand.Address = 0x000000;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DataMode = QSPI_DATA_1_LINE;
sCommand.DummyCycles = 0;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.NbData = 3;
if (HAL_QSPI_Command(&hqspi1, &sCommand, HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return HAL_ERROR;
}
if (HAL_QSPI_Receive(&hqspi1, id, HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
{
return HAL_ERROR;
}
return HAL_OK;
}
The Flash memory is connected to 3.3V from external custom board. When I run the above function
there is no error and there is no response from the flash memory. The board to flash memory pin connections are correct.
The clock to the QSPI is SYSCLK (16MHz). The same ioc settings and code when used in STM32L412 nucleo board, I am
able to read the device ID. What might be the reason for getting the response using the STM32G474 board ?
If you further need any information, let me know.
Thanks.
2025-02-12 06:16 AM - edited 2025-02-12 06:17 AM
Hello @VSASI1;
Does the BUSY flag of the QUADSPI_SR register remain high?
I recommend you to take look at the STM32G474 errata sheet and precisely QUADSPI section for QUADSPI errata. And check if you have a case of limitation.
Could you please use </> button to paste your code?
I hope this help you.
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.