HAL _QSPI_ERROR_TIMEOUT in NOR flash memory
Hello,
currently i am working on stm32f4113 and nor flash(w25q128) using QuadSPI 1st time i erase the 1st block i get no error but 2nd time i erase any block i get HAL_QSPI_ERROR_TIMEOUT.
i get error in this function QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_TC, SET, tickstart, Timeout); this function TC flag ( Transfer complete) is not reset.
if(hqspi->State == HAL_QSPI_STATE_READY)
{
hqspi->ErrorCode = HAL_QSPI_ERROR_NONE;
/* Update QSPI state */
hqspi->State = HAL_QSPI_STATE_BUSY;
/* Wait till BUSY flag reset */
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_BUSY, RESET, tickstart, Timeout);
if (status == HAL_OK)
{
/* Call the configuration function */
QSPI_Config(hqspi, cmd, QSPI_FUNCTIONAL_MODE_INDIRECT_WRITE);
if (cmd->DataMode == QSPI_DATA_NONE)
{
/* When there is no data phase, the transfer start as soon as the configuration is done
so wait until TC flag is set to go back in idle state */
status = QSPI_WaitFlagStateUntilTimeout(hqspi, QSPI_FLAG_TC, SET, tickstart, Timeout);
if (status == HAL_OK)
{
__HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TC);
/* Update QSPI state */
hqspi->State = HAL_QSPI_STATE_READY;
}
}
this is my code
W25Q_eraseBlock(0,64);
W25Q_writeEnable(1);
uint8_t counter=0;
uint8_t write;
uint32_t address =0x200;
printf("sector : 1\r\n");
for(int i=0;address<=0x300;i++)
{
uint32_t spi_ret = W25Q_programRaw(&counter,sizeof(counter),address);
printf("write : counter :%d addr:%ld addr :0x%lx\r\n",counter,address,address);
counter++;
HAL_Delay(20);
W25Q_readRaw(&write,sizeof(write),address);
printf("read : counter :%d addr:%ld addr :0x%lx\r\n",write,address,address);
address++;
}
printf("moving to 32th block\r\n");
int res = W25Q_EraseBlock(8,64);
/*Here i get error */
how to slove this issue
