Skip to main content
Associate
October 15, 2024
Solved

STM32H5 XSPI Not Setting TC Flag

  • October 15, 2024
  • 2 replies
  • 1171 views

Hello,

I am using the STM32H563RGT6. I am using the OCTOSPI peripheral to connect a quad spi connection a flash chip. I can successfully read the status registers on the flash chip, send the write enable command, write an erase command to address 0x0, read status register 1 and wait for BUSY flag to clear, then send the write enable command again. However, when I go to erase the next block at addr 0x10000, and the HAL_XSPI_FLAG_TC never gets set in the HAL_XSPI_Command function.

All of the write commands to this point use the following regular command settings:

XSPI_RegularCmdTypeDef sCommand = { 0 };
sCommand.OperationType = HAL_XSPI_OPTYPE_COMMON_CFG;
sCommand.IOSelect = HAL_XSPI_SELECT_IO_3_0;
sCommand.Instruction = cmd;
sCommand.InstructionMode = HAL_XSPI_INSTRUCTION_1_LINE;
sCommand.InstructionWidth = HAL_XSPI_INSTRUCTION_8_BITS;
sCommand.InstructionDTRMode = HAL_XSPI_INSTRUCTION_DTR_DISABLE;
sCommand.Address = addr;
sCommand.AddressMode = HAL_XSPI_ADDRESS_1_LINE;
sCommand.AddressWidth = HAL_XSPI_ADDRESS_24_BITS;
sCommand.DataMode = HAL_XSPI_DATA_NONE;
sCommand.DataLength = 0;
sCommand.DummyCycles = num_dummy_cycles;
sCommand.DQSMode = HAL_XSPI_DQS_DISABLE;
sCommand.SIOOMode = HAL_XSPI_SIOO_INST_ONLY_FIRST_CMD;

 The command that returns a HAL_TIMEOUT (set to 5s for testing), is configured with Instruction mode, 24 bit address, and no data mode. I don't understand why the TC register flag never gets set and I have no idea what else to try.

Any advice on what to try next?

Thanks,
Chad

This topic has been closed for replies.
Best answer by chadcoonsGB

Hello Kaouthar,

I solved the issue. There was no description in the Memory Size field for the OctoSPI Parameters, I left this as the default value during hardware bringup. Updating that field to match my flash chip fixed the issue.

I spent way too much time missing this detail due to the lack of documentation and unclear error response. It doesn't make sense to me why the driver wouldn't return a more succinct error code (something like invalid parameter to indicate the address being outside of the configured memory bounds) or really just an error instead of never setting the TC flag and waiting for a timeout. 

I also think a description of the field in CubeMX would have helped me solve this issue more quickly.

Thanks,

Chad

2 replies

KDJEM.1
ST Technical Moderator
October 22, 2024

Hello @chadcoonsGB and welcome to the Community;

 

Could you please give more details about the memory and the mode (memory mapped mode or indirect mode)you used?

May this example OSPI_NOR_MemoryMapped can help you.

 

Thank you.

Kaouthar

 

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.
chadcoonsGBAuthorBest answer
Associate
October 22, 2024

Hello Kaouthar,

I solved the issue. There was no description in the Memory Size field for the OctoSPI Parameters, I left this as the default value during hardware bringup. Updating that field to match my flash chip fixed the issue.

I spent way too much time missing this detail due to the lack of documentation and unclear error response. It doesn't make sense to me why the driver wouldn't return a more succinct error code (something like invalid parameter to indicate the address being outside of the configured memory bounds) or really just an error instead of never setting the TC flag and waiting for a timeout. 

I also think a description of the field in CubeMX would have helped me solve this issue more quickly.

Thanks,

Chad