Associate II
May 8, 2023
Solved
STM32H7B3 OctoSPI Flash. Octal_Polling_WEL() has a problem
- May 8, 2023
- 8 replies
- 7286 views
Hi everyone, this is my first time posting a question.
I use the MX25UM51245G OctoSPI Flash memory of the STM32H7B3LI Discovery Board. Use stm32cubeIDE. I have referred to STM32L4 Octo-SPI Application note and STM32H7 Octo-SPI Application note.
But I still have a problem at the place of Octal_Polling_WEL(), the error occurs at
If (HAL_OSPI_Receive(&hospi1, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)the return reg value is 0x00.
void MX25LM51245G_OctalPollingWEL(void)
{//This function Configures Software polling to wait until WEL=1
OSPI_RegularCmdTypeDef s_command = {0};
OSPI_AutoPollingTypeDef s_config = {0};
// Configure automatic polling mode to wait for memory ready
s_command.OperationType = HAL_OSPI_OPTYPE_COMMON_CFG;
s_command.FlashId = HAL_OSPI_FLASH_ID_1;
s_command.InstructionMode = HAL_OSPI_INSTRUCTION_8_LINES;
s_command.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_ENABLE;
//s_command.InstructionDtrMode = HAL_OSPI_INSTRUCTION_DTR_DISABLE;
s_command.InstructionSize = HAL_OSPI_INSTRUCTION_16_BITS;
s_command.Instruction = MX25LM51245G_OCTA_READ_STATUS_REG_CMD;
s_command.AddressMode = HAL_OSPI_ADDRESS_8_LINES;
s_command.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_ENABLE;
//s_command.AddressDtrMode = HAL_OSPI_ADDRESS_DTR_DISABLE;
s_command.AddressSize = HAL_OSPI_ADDRESS_32_BITS;
s_command.Address = 0;
s_command.AlternateBytesMode = HAL_OSPI_ALTERNATE_BYTES_NONE;
s_command.DataMode = HAL_OSPI_DATA_8_LINES;
s_command.DataDtrMode = HAL_OSPI_DATA_DTR_ENABLE;
//s_command.DataDtrMode = HAL_OSPI_DATA_DTR_DISABLE;
s_command.DummyCycles = DUMMY_CYCLES_REG_OCTAL;
s_command.NbData = 2;
//s_command.NbData = 1;
s_command.DQSMode = HAL_OSPI_DQS_DISABLE;
s_command.SIOOMode = HAL_OSPI_SIOO_INST_EVERY_CMD;
s_config.Match = 2;//Set the match to 0x02 to check if the WEL bit is Set
s_config.Mask = MX25LM51245G_SR_WEL;//Set the mask to 0x02 to mask all Status REG bits except WEL
s_config.MatchMode = HAL_OSPI_MATCH_MODE_AND;
s_config.Interval = MX25LM51245G_AUTOPOLLING_INTERVAL_TIME;
s_config.AutomaticStop = HAL_OSPI_AUTOMATIC_STOP_ENABLE;
uint8_t reg[2];
do
{
if (HAL_OSPI_Command(&hospi1, &s_command,
HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
Error_Handler();
if (HAL_OSPI_Receive(&hospi1, reg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
Error_Handler();
//use to SPI mode. not use OPI mode, it will cause to the error
//if (HAL_OSPI_AutoPolling(&hospi1, &s_config, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)
//return -1;
}while((reg[0] & WRITE_ENABLE_MASK_VALUE) != WRITE_ENABLE_MATCH_VALUE);
}Please tell me if anyone has encountered this problem and can help solve it, thank you.
