7 Replies Latest reply on Jan 8, 2019 10:16 PM by ViC_3886151

    Write data to flash and read the same data

    ViC_3886151

      Hello everyone.

       

      I'm interfacing S25FL127S Serial NOR flash with PSoC 5LP. I managed to read the device ID successfully. But, even after enabling write, I cannot write the data to the flash and read the same data from the flash. Please help.

       

      Thanks in advance.

       

      Regards

      Vinay

        • 1. Re: Write data to flash and read the same data
          SudheeshK_26

          Hello Vinay,

           

          1. Could you please let us know the command sequence that you followed to program data into the flash?

          2. Did you verify that the WEL bit in status register is set after WREN command?

          3. What is the value in status register after program operation? Are P_ERR or E_ERR bits are set?

          4. Are  you using single SPI or QUAD interface to access our device?

           

          Thanks and Regards,

          Sudheesh

          • 2. Re: Write data to flash and read the same data
            ViC_3886151

            Hello Sudheesh,

             

            Thanks for the reply. I first read the values from SR & CR to which both returned 00. I used slld_WRENCmd() to enable write. After write enable, reading SR & CR both returned FF which means WEL i.e., SR[1] = 1. Both P_ERR & E_ERR are set in SR after WREN. Also, after WREN, CR[1] = 1 which means the SPI is QUAD. So, I used QUAD commands to access the flash.

             

            Later on, I used slld_QPPOp to write and slld_QuadIOReadCmd to read the data. But the flash is returning only FF even though i read the data from the same location. So, I guess there is some problem writing the data to the flash.

             

            Regards,

            Vinay

            • 3. Re: Write data to flash and read the same data
              SudheeshK_26

              Hi Vinay,

               

              Are you making CS# pin HIGH after each operation? Please make sure you follow below sequence

              1. CS#-> HIGH (Initial state)

              2. CS# -> LOW

              3. WREN command

              4. CS# -> HIGH

              5. CS#-> LOW

              6. Read SR

              7. CS# -> HIGH

              8. CS#-> LOW

              9. Read CR

              10. CS# -> HIGH

               

              After WREN command vale of SR will be 0x02 and value of CR will be unchanged.

               

              Thanks and Regards,

              Sudheesh

              • 4. Re: Write data to flash and read the same data
                ViC_3886151

                Hello Sudheesh,

                 

                I am making CS low before sending command & high after sending the command. Here is the code.

                 

                    CS_Flash_Write(0);

                    slld_WRENCmd();

                    UART_PutString("\nWrite enabled");

                    CS_Flash_Write(1);

                   

                    while(1)

                    {

                        CS_Flash_Write(0);

                        slld_RDSRCmd(&SRval);

                        if(!(SRval & 0x01))

                        {

                            UART_PutString("\nBreak");

                            break;

                        }

                        CS_Flash_Write(1);

                    }

                 

                Thanks & Regards,

                Vinay

                • 5. Re: Write data to flash and read the same data
                  ViC_3886151

                  Hello Sudheesh,

                   

                  I also tried sector erase using slld_SE_4BOp for which the device status is returning 0x03 [which is the value for dev_erase_error].

                  How do I get past the error? Please help.

                   

                  Thanks & Regards,

                  Vinay

                  • 6. Re: Write data to flash and read the same data
                    SudheeshK_26

                    Hi Vinay,

                     

                    Sorry for the delay.

                     

                    Status register value = 0x03 means, both WEL and WIP bits are set. WIP bit = 1 means, the devices is busy. Since, you read status register after erase operation, WIP=1 means the erase algorithm is running internally. You have to keep reading status register until WIP bit becomes 0 before doing any new operation. WEL bit will also become 0 once the internal erase algorithm is finished.

                     

                    For better understanding, could you please attach waveform for WREN, program, read and erase operations?

                     

                    Thanks and Regards,

                    Sudheesh

                    • 7. Re: Write data to flash and read the same data
                      ViC_3886151

                      Hello Sudheesh,

                       

                      Previously, the frequency of the SPI master component was 2MHz. After searching online through multiple websites, I found that SPI had issues for frequency greater than 1MHz. So, I reduced the frequency to 1MHz & SPI worked perfectly.

                       

                      Thanks & Regards,

                      Vinay