AnsweredAssumed Answered

STM32F4: WIP Bit Never zeros out in function: sFLASH_WaitForWriteEnd

Question asked by roofie01 on Oct 12, 2015
Latest reply on Oct 13, 2015 by Clive One
Hi,

The Micron M25P128 flash seems to be writing and reading OK. As clive1 suggested, the SPI flash functionality is written in the Std Peripheral examples, so I am using that.

When I execute the call to: sFLASH_EraseSector, this function calls:
 sFLASH_WaitForWriteEnd

which waits for the read status register's WIP bit to go low. Well, it never happens. It just sits there.....and spins.

How long should a call to sFLASH_EraseSector take?
The function sFLASH_WaitForWriteEnd  is pasted below.

Thanks,
Gary
*****************************************************************

void sFLASH_WaitForWriteEnd(void)
{
  uint8_t flashstatus = 0;

  /*!< Select the FLASH: Chip Select low */
  sFLASH_CS_LOW();

  /*!< Send "Read Status Register" instruction */
  sFLASH_SendByte(sFLASH_CMD_RDSR);

  /*!< Loop as long as the memory is busy with a write cycle */
  do
  {
    /*!< Send a dummy byte to generate the clock needed by the FLASH
    and put the value of the status register in FLASH_Status variable */
    flashstatus = sFLASH_SendByte(sFLASH_DUMMY_BYTE);

  }
  while ((flashstatus & sFLASH_WIP_FLAG) == SET); /* Write in progress */

  /*!< Deselect the FLASH: Chip Select high */
  sFLASH_CS_HIGH();
}

Outcomes