Hard Fault while accessing external flash memory configured in memory mapped mode
Hi,
I have been working on implementing external flash driver integration with TouchGFX on STM32G474-eval board, in memory mapped mode.
I have configured the QSPI in Bank 1 with Single/Dual lines. I have attached an image of my CubeMx configuration.
I am getting hard fault while accessing any memory area of external flash. But, while in debug mode, I am able to access the memory address, for example: 0x90000000.
Below are my QSPI initialisation sequence :
uint8_t CSP_QUADSPI_Init(void) {
if(CSP_QSPI_Erase_Chip() != HAL_OK)
{
return HAL_ERROR;
}
if (QSPI_AutoPollingMemReady(HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
if (QSPI_WriteEnable() != HAL_OK) {
return HAL_ERROR;
}
if (QSPI_Configuration() != HAL_OK) {
return HAL_ERROR;
}
if (QSPI_AutoPollingMemReady(HAL_QSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
uint8_t CSP_QSPI_EnableMemoryMappedMode(void) {
QSPI_CommandTypeDef sCommand;
QSPI_MemoryMappedTypeDef sMemMappedCfg;
/* Enable Memory-Mapped mode-------------------------------------------------- */
sCommand.InstructionMode = QSPI_INSTRUCTION_1_LINE;
sCommand.AddressSize = QSPI_ADDRESS_32_BITS;
sCommand.AlternateByteMode = QSPI_ALTERNATE_BYTES_NONE;
sCommand.DdrMode = QSPI_DDR_MODE_DISABLE;
sCommand.DdrHoldHalfCycle = QSPI_DDR_HHC_ANALOG_DELAY;
sCommand.SIOOMode = QSPI_SIOO_INST_EVERY_CMD;
sCommand.AddressMode = QSPI_ADDRESS_1_LINE;
sCommand.DataMode = QSPI_DATA_1_LINE;
sCommand.NbData = 0;
sCommand.Address = 0;
sCommand.Instruction = 0x0BU;
sCommand.DummyCycles = 4;
sMemMappedCfg.TimeOutActivation = QSPI_TIMEOUT_COUNTER_DISABLE;
if (HAL_QSPI_MemoryMapped(&hqspi1, &sCommand, &sMemMappedCfg) != HAL_OK) {
return HAL_ERROR;
}
return HAL_OK;
}
