STM32L4P5 ocotspi issues
Hello,
I have two issues with the octospi controllers of the STM32L4P5.
First issue.
I can’t get both controller to work simultaneously.
My target was to use one controller with a QSPI flash (W25Q512JVEIQ) and the second one with an APMemory QSPI PSRAM (APS6404L).
I started the project by getting the code to work (it was a port from an STM32L496 project) for the flash.
After some adjustments, the code works properly in quad spi mode.
Then I added the second controller and doing that brokes the project.
The second controller works, but the first one stopped working.
I run some checks with a logic analyzer and found that ther is no signals on the I/O lines.
CS# is HIGH and never goes low and there is no clock.
CS# and clock are properly generated for the second controller.
Second issue
I can’t get the memory mapped mode to work.
The mode is p^roperly enabled, I can read data from 0x90000000 without throwing a hard fault, but data is always 0.
I’m wondering if this could be related to the flash model.
It does not support QPI mode.
Is QPI mode required for memeory mapped mode to work ?
Here after is my code to enable memory mapped mode:
static void w25qxxx_Enable_memory_mapped(void)
{
OSPI_MemoryMappedTypeDef _cfg = {0};
OSPI_RegularCmdTypeDef _ospi_rd_command = {0};
OSPI_RegularCmdTypeDef _ospi_wr_command = {0};
HAL_StatusTypeDef _hal_status;
_cfg.TimeOutActivation = HAL_OSPI_TIMEOUT_COUNTER_DISABLE;
_ospi_rd_command.OperationType = HAL_OSPI_OPTYPE_READ_CFG;
_ospi_rd_command.FlashId = HAL_OSPI_FLASH_ID_1;
_ospi_rd_command.NbData = 1;
if (system_hardware_config->flash_read_mode == FLASH_RW_MODE_QUAD)
{
_ospi_rd_command.Instruction = W25Q_FAST_READ_QUAD_OUT_4B;
_ospi_rd_command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
_ospi_rd_command.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
_ospi_rd_command.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
_ospi_rd_command.DataMode = HAL_OSPI_DATA_4_LINES;
_ospi_rd_command.DummyCycles = 8;
}
else if (system_hardware_config->flash_read_mode == FLASH_RW_MODE_DUAL_SINGLE)
{
_ospi_rd_command.Instruction = W25Q_FAST_READ_DUAL_OUT_4B; // COMMAND
_ospi_rd_command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
_ospi_rd_command.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
_ospi_rd_command.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
_ospi_rd_command.DataMode = HAL_OSPI_DATA_2_LINES;
_ospi_rd_command.DummyCycles = 8;
}
else
{
_ospi_rd_command.Instruction = W25Q_FAST_READ_4B; // COMMAND
_ospi_rd_command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
_ospi_rd_command.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
_ospi_rd_command.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
_ospi_rd_command.DataMode = HAL_OSPI_DATA_1_LINE;
_ospi_rd_command.DummyCycles = 8;
}
_ospi_wr_command.OperationType = HAL_OSPI_OPTYPE_WRITE_CFG;
_ospi_wr_command.FlashId = HAL_OSPI_FLASH_ID_1;
_ospi_wr_command.NbData = 1;
if (system_hardware_config->flash_read_mode == FLASH_RW_MODE_QUAD)
{
_ospi_wr_command.Instruction = W25Q_PAGE_PROGRAM_QUAD_INP_4B; // COMMAND
_ospi_wr_command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
_ospi_wr_command.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
_ospi_wr_command.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
_ospi_wr_command.DataMode = HAL_OSPI_DATA_4_LINES;
}
else
{
_ospi_wr_command.Instruction = W25Q_PAGE_PROGRAM_4B; // COMMAND
_ospi_wr_command.InstructionMode = HAL_OSPI_INSTRUCTION_1_LINE;
_ospi_wr_command.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
_ospi_wr_command.AddressMode = HAL_OSPI_ADDRESS_1_LINE;
_ospi_wr_command.DataMode = HAL_OSPI_DATA_1_LINE;
}
_hal_status = HAL_OSPI_Command(&hospi1, &_ospi_rd_command, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
if (_hal_status != HAL_OK)
{
_hal_status = HAL_OSPI_GetError(&hospi1);
HAL_OSPI_Abort(&hospi1);
}
else
{
_hal_status = HAL_OSPI_Command(&hospi1, &_ospi_wr_command, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
if (_hal_status != HAL_OK)
{
_hal_status = HAL_OSPI_GetError(&hospi1);
HAL_OSPI_Abort(&hospi1);
}
else
{
_hal_status = HAL_OSPI_MemoryMapped(&hospi1, &_cfg);
if (_hal_status != HAL_OK)
{
_hal_status = HAL_OSPI_GetError(&hospi1);
HAL_OSPI_Abort(&hospi1);
}
}
}
}
The code was teste in QUAD configuration (FLASH_RW_MODE_QUAD)
Thanks in advance for your help.
