after enable external flash mapped, couldn't write to external flash.
I made a board with ST32H7B0ZBT6, and add a external flash with W25Q128JVS。I found after I enable mapped function, I couldn't write data to external flash any more.
the code with enable mapped func as below:
uint8_t W25Qxx_OSPI_Init(void)
{
OSPI_RegularCmdTypeDef s_command;
uint16_t w25qxx_id;
uint8_t value = W25QxJV_FSR_QE;
if (W25Qxx_OSPI_ResetMemory() != OSPI_OK)
{
return OSPI_NOT_SUPPORTED;
}
if (W25Qxx_OSPI_WriteEnable() != OSPI_OK)
{
return OSPI_ERROR;
}
s_command.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
s_command.FlashId = HAL_OSPI_FLASH_ID_1;
s_command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
s_command.Instruction = WRITE_STATUS_REG2_CMD;
s_command.AddressMode = HAL_OSPI_ADDRESS_NONE;
s_command.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
s_command.DataMode = HAL_OSPI_DATA_1_LINE;
s_command.DummyCycles = 0;
s_command.NbData = 1;
s_command.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
s_command.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
s_command.InstructionSize = HAL_OSPI_INSTRUCTION_8_BITS;
s_command.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
s_command.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
s_command.DQSMode = HAL_OSPI_DQS_DISABLE;
if (HAL_OSPI_Command(&hospi1, &s_command, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK)
{
return OSPI_ERROR;
}
#if 0
OSPI_MemoryMappedTypeDef cfg;
cfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;
if (OSPI_OK != HAL_OSPI_MemoryMapped(&hospi1, &cfg))
{
return OSPI_ERROR;
}
#endif
if (HAL_OSPI_Transmit(&hospi1, &value, HAL_OSPI_TIMEOUT_DEFAULT_VALUE)
!= HAL_OK)
{
return OSPI_ERROR;
}
if (W25Qxx_OSPI_AutoPollingMemReady(W25QxJV_SUBSECTOR_ERASE_MAX_TIME) != OSPI_OK)
{
return OSPI_ERROR;
}
w25qxx_id=W25Qxx_OSPI_FLASH_ReadDeviceID();
if ( w25qxx_id != W25Qxx_ID)
return OSPI_ERROR;
#if (W25Q256 == W25Qxx_ID)
if (W25Qxx_OSPI_Addr_Mode_Init() != OSPI_OK)
{
return OSPI_ERROR;
}
#endif
return OSPI_OK;
}
If I enable these code:
#if 0
OSPI_MemoryMappedTypeDef cfg;
cfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;
if (OSPI_OK != HAL_OSPI_MemoryMapped(&hospi1, &cfg))
{
return OSPI_ERROR;
}
#endif
I will not able to write data to external flash with spi interface. Is there something was wrong?
