9 Replies Latest reply on May 21, 2019 2:31 AM by BacemD_61

    S25FL25S device Parameter 4-KB Sector Erase (P4E-20H) is not working

    maac_3997091

      Hi,

       

      I'm using device S25FL25S device Parameter 4-KB Sector Erase (P4E-20H) is not working. 

       

      20H- command is erasing the sector only once. If we are erasing same the sector again its not erasing what we have wrote locations.

       

      So, its not writing new data in same sector.  my code;

       

         Write_Chip_Addr = addr;

         Erase_Chip_Addr = addr % 4096;

         if(Erase_Chip_Addr == 0)

         {

         S25FL164K_EraseSector(Write_Chip_Addr);

         }

        err = S25FL164K_Read(Write_Chip_Addr, sectorBuff, FLASH_MEM_SECTOR_SIZE);

          err = S25FL164K_Write(Write_Chip_Addr, data, len);

         err = S25FL164K_Read(Write_Chip_Addr, &RxBuff[Idx], len);

       

      Erase section:

      do

      {

      setWriteEnable();

      err = readStatusReg(flashRxBuff);

      retryCount--;

      }while(!(flashRxBuff[0] & WEL_BIT) && retryCount);

       

         //erase

         index= 0;

         flashTxBuff[index++] = 0xDC;//FLASH_SE;

         //4 byte addr

         //flashTxBuff[index++] = (uint8_t)(address>>24);

         flashTxBuff[index++] = (uint8_t)(address>>16);

         flashTxBuff[index++] = (uint8_t)(address>>8);

         flashTxBuff[index++] = (uint8_t)(address>>0);

       

       

         err = sendMessage(flashTxBuff, index, flashRxBuff, 0);

       

      Note: Sector erase is working properly (Sector Erase - D8h)