cancel
Showing results for 
Search instead for 
Did you mean: 

HAL _QSPI_ERROR_TIMEOUT in NOR flash memory

AA.27
Associate II

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

1 REPLY 1

Don't confuse the QSPI peripherals timeout expectations with those of the memory.

If you ignore errors from the HAL you're likely to compound then.

If you timeout of some of the HAL functions the exit path will not clear the peripheral. If you leave it in a busy state, usually means you need to Abort the transaction.

ST has AutoPolling functions which query the BUSY/READY state of the MEMORY, and typically use STATUS REGISTER ONE, the MICRON's prefer a different register. At least some of the HAL implementations exit leaving the QSPI still active, auto-polling and memory-mapped being examples. You need to Abort to recover control.

The ERASE and WRITE functions can take several milli-seconds, seconds, or minutes depending on the size and speed of the device.

The WRITE PAGE typically can only deal with up to 256-byte pages, on page address boundaries. If you write is larger, or spans page boundaries, you'll need to decompose it into smaller pieces.

https://www.pjrc.com/teensy/W25Q128FV.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..