请教w25q64fv spi flash 驱动代码问题

2019-08-08 12:12发布

本帖最后由 某某网友 于 2017-10-31 12:34 编辑

使用stm32f103驱动w25q64fv(不是bv),在等待芯片写入完毕的代码段出现死循环,请问是什么问题?源码如下

#define WIP_FlagMask                    0x01  /* Write In Progress (WIP) flag */
#define Dummy_Byte                      0xFF
……
void SPI_FLASH_WaitForWriteEnd(void)
{
  u8 FLASH_Status = 0;

  /* Select the FLASH: Chip Select low */
  SPI_FLASH_CS_LOW();

  /* Send "Read Status Register" instruction */
  SPI_FLASH_SendByte(W25X_ReadStatusReg);
  /* 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 */
    FLASH_Status = SPI_FLASH_SendByte(Dummy_Byte);
        printf("%c",FLASH_Status);
  }
  while ((FLASH_Status&WIP_FlagMask) == SET); /* Write in progress */
//do while进入死循环,串口打印输出FLASH_Status的HEX值为FF
  /* Deselect the FLASH: Chip Select high */
        printf("write end! ");
  SPI_FLASH_CS_HIGH();
}




是代码的问题还是芯片问题???

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。