4 Replies Latest reply on May 8, 2019 2:22 AM by SudheeshK_26

    Regarding Chip erase and read and write register in S25FL128L

    vignesh.v_4156156

      Hi,

         Im trying to do a chip erase / bulk erase using C7 command . After which im trying to write and read register single register using write any register.

      I ve attached the code snippet also for the same.its getting stuck in the  chip erase point where the status returned a status of 0x3. kindly help with the issue and tell me whether the code approach is right.

       

      uint8_t spi_flash_read_status_register (void)

      {

      uint8_t status, dummy_var;

       

       

      ALLOW_TRANSFER;

      PUSH(RDSR); // read status register command - 05

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var); // discard one RxFIFO item

       

       

      PUSH_ENQ(dummy_byte); // status register is returned during this

          WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

          POP(status); // read useful data

       

       

          return (status);

      }

       

      void spi_flash_chip_erase(void)

      {

      uint8_t status, dummy_var;

       

       

          ALLOW_TRANSFER;  // if previous command has set EOQ

      PUSH_ENQ(WREN); // write enable command

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var); // discard one RxFIFO item

       

      ALLOW_TRANSFER; // if previous command has set EOQ

      PUSH_ENQ(CE); // Chip erase command - C7

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var); // discard one RxFIFO item

      do

      {

      status = spi_flash_read_status_register();

      }

      while (status & WIP); // wait here until chip erase is done.

      }

       

      void read _register(uint32_t address, uint8_t* p_data)

      {

      static uint8_t dummy_var;

      uint8_t addr0, addr1, addr2 addr3;

      addr0 = (uint8_t) (address & 0x000000FF);

      addr1 = (uint8_t) ((address & 0x0000FF00) >> 8);

      addr2 = (uint8_t) ((address & 0x00FF0000) >> 16);

      addr3 = (uint8_t) ((address & 0xFF000000) >> 24);

       

      ALLOW_TRANSFER; // if previous command has set EOQ

       

      PUSH(READ_DATA);  // read data bytes command

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr3); // most-significant byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr2); // middle high byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr1); // middle byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr0); // least-significant byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH_ENQ(dummy_byte); // dummy bytes for generating CLK to slave

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(*p_data_bytes);  // read useful data

      }

       

      void write_register(uint32_t address, uint8_t* p_data)

      {

      static uint8_t dummy_var;

      uint8_t addr0, addr1, addr2,addr3;

       

      addr0 = (uint8_t) (address & 0x000000FF);

      addr1 = (uint8_t) ((address & 0x0000FF00) >> 8);

      addr2 = (uint8_t) ((address & 0x00FF0000) >> 16);

      addr3 = (uint8_t) ((address & 0xFF000000) >> 24);

       

      PUSH_ENQ(WREN);   // write enable command (must be done before every write !!!)

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

      ALLOW_TRANSFER; // from this point all following write to PUSHR will be sent

       

      PUSH(WRITE_DATA);  // read data bytes command  - 0X65H

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr3); // most-significant byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr2); // middle high byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr1); // middle byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH(addr0); // least-significant byte of address

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      POP(dummy_var);

       

      PUSH_ENQ(*p_data); // write data into the register

      WAIT_UNTIL_RxFIFO_IS_NOT_EMPTY;

      }

       

      Regards,

      Vignesh

        • 1. Re: Regarding Chip erase and read and write register in S25FL128L
          SudheeshK_26

          Hi,

           

          I would like to get know some more details about this issue.

           

          1. Can you provide SPI waveform (SCK, SO, SI and SS signals) for chip erase operation?

          2. Does the value of status register change to 0x00 if you wait more time after chip erase operation reading status register? Or, the value of status register does not change at all?

          3. How many devices did you test? Are you observing this issue with all of the devices that you tested?

           

          Thanks and Regards,

          Sudheesh

          • 2. Re: Regarding Chip erase and read and write register in S25FL128L
            vignesh.v_4156156

            Hi,

               I have not captured any waveform i'll get you once i do it.

            I had waited for sometime and then later halted my application to find the status it showed 3.

            What i shall do is i'll wait more time and shall print the status and check.

             

            By the way two questions

            1. how much max time it shall take approximately to complete the erase for chip.

            2. Is the code approach fine for the erase status register and read and write any register.

             

            Thanks In Advance,

            Vignesh

            • 3. Re: Regarding Chip erase and read and write register in S25FL128L
              vignesh.v_4156156

              Hi,

                  I got the device ID correctly and followed by which bulk erase is also working fine. it took some time may be a more than a minute roughly.

              Im able to do page program and read the data using read command.

               

              There are 2 issues im facing.

              1. The write to any register and read any register is not working for writing one register im using page program command and giving the length as 1 which works. can u guide me . ive provided the code above for the same.

              1. Do i need to do a sector erase or erase the page before writing in data into page.Why means when i write a page and try to rewrite it without erase i'm not getting desired results.

              say from address 200000 - 200010 im writing data its working when i write with page and read using read command.

              when i write to sme address other data without erase chip its not working . when i erase and then write diff daa on the same address its working.

               

              Regards,

              Vignesh.

              • 4. Re: Regarding Chip erase and read and write register in S25FL128L
                SudheeshK_26

                Hi,

                 

                1. I checked your code. As per the comments you are sending command 0x65 (RDAR) in write_register() function. Is this a typo? You have to use WRAR command here (0x71h). Please double check this.

                PUSH(WRITE_DATA);  // read data bytes command  - 0X65H

                 

                2. Yes, you have to erase memory cells, if you want to re-write data.

                 

                Thanks and Regards,

                Sudheesh

                1 of 1 people found this helpful