3 Replies Latest reply on Mar 10, 2020 12:22 AM by ApurvaS_36

    In S70FL01GS Read/Write Problem When Data lying in b/w Sectors??

    MdNa_4387646

      ApurvaS_36

      When Data Lying b/w Sectors?

      When we Write 8 bytes Data {01 01 01 01 01 01 01 01}  on Address :- 0x0003FFFC & then Read 8 bytes data on Address :- 0x0003FFFC  {01 01 01 01 FF FF FF FF}??

      When Data Lying b/w 32kb Block?

      When we Write 8 bytes Data {01 01 01 01 01 01 01 01}  on Address :- 0x00007FFC & then Read 8 bytes data on Address :- 0x00007FFC   {01 01 01 01 FF FF FF FF}??

       

      Please response me as soon as possible.

      Thank you.

        • 1. Re: In S70FL01GS Read/Write Problem When Data lying in b/w Sectors??
          ApurvaS_36

          Hi Md Nasir,

           

          Thank you for contacting Cypress Semiconductor.

           

          I would like to inform you that 0x0003FFFF is the last address of the first sector. Hence, if you start programming from 0x0003FFFC location and try to program 8 bytes of data, four bytes of data get programmed from 0x0003FFFC to 0x0003FFFF location and the address wraps and goes back to the starting address of that particular page. You can find the explanation for this written on page 96 of the datasheet

          The same explanation holds true for programming between 32kb block as well, as the address gets wrapped around page boundaries.

          The data that you are reading seems to be correct since while reading address does not get wrapped and hence you are able to read the first four bytes of the next page. You can read the first four bytes of the corresponding page where you are performing the program operation to confirm that the other four bytes of data are programmed to those locations.

          Let me know if you have any more queries.

           

          Best Regards,

          Apurva

          • 2. Re: In S70FL01GS Read/Write Problem When Data lying in b/w Sectors??
            MdNa_4387646

            How Can i handle address wrapping in b/w sectors ??

             

            #define PHY_EXTFLASH_PAGE_SIZE      0x08

            #define WAIT_TIME          osDelay(10)                 //Delay

             

            /*! \fn void vWriteToChip_0 (u32 i_u32StartAddr, u8Ptr o_u8PtrBuf)

                  \brief Function to write data into Chip_0.

                  \param i_u32StartAddr - Starting address.

                  \param o_u8PtrBuf- Buffer for storing data.

             

             

                  \return none

            */

             

             

            void vWriteToChip_0(u32 i_u32StartAddr, u8Ptr o_u8PtrBuf)

            {

            u32 lu32Count=0;

             

            Print_0("vWriteToChip_0........\r\n");

             

            Flash1_Select(); u8FlashSPI_SendByte(0x06); Flash1_DeSelect();//Write Enable

            Flash1_Select();

            u8FlashSPI_SendByte(0x12);//Page program

            WriteAddr32(i_u32StartAddr);

             

            for(lu32Count=0; lu32Count < (u32)PHY_EXTFLASH_PAGE_SIZE; lu32Count++)

            {

            u8FlashSPI_SendByte(*o_u8PtrBuf);

            o_u8PtrBuf++;

            }

            Flash1_DeSelect();

            WAIT_TIME;

            }

            //---------------------------------------------------------------------------------------------------------------

            /*! \fn void vWriteToChip_1 (u32 i_u32StartAddr, u8Ptr o_u8PtrBuf)

                  \brief Function to write data into Chip_1.

                  \param i_u32StartAddr - Starting address.

                  \param o_u8PtrBuf- Buffer for storing data.

             

             

                  \return none

            */

            void vWriteToChip_1(u32 i_u32StartAddr, u8Ptr o_u8PtrBuf)

            {

            u16 lu16Count=0;

            Print_0("vWriteToChip_1........\r\n");

            Flash2_Select();  u8FlashSPI_SendByte(0x06);  Flash2_DeSelect();//Write Enable

            Flash2_Select();

            u8FlashSPI_SendByte(0x12);//Page program

            WriteAddr32(i_u32StartAddr);

            for(lu16Count=0; lu16Count<(u32)PHY_EXTFLASH_PAGE_SIZE; lu16Count++)

            {

            u8FlashSPI_SendByte(*o_u8PtrBuf);

            o_u8PtrBuf++;

            }

            Flash2_DeSelect();

            WAIT_TIME;

            }

             

            How can i handle address wrapping in writing operation?

            I already handle logically when data lying between both chip.

            But how can i handle data b/w sectors?

            Can i write data between two sectors??

            • 3. Re: In S70FL01GS Read/Write Problem When Data lying in b/w Sectors??
              ApurvaS_36

              Hi Md Nasir,

               

              Apologies for the delay in my response.

               

              • If you are writing a huge chunk of data (data size greater than 512 bytes) you will have to do it in multiple write operations since the maximum size of the buffer is 512 bytes, which means at a time the maximum amount of data that can be programmed to a flash is 512 bytes. In this case you can start programming from the starting address of a page. The starting address of a page will either be 0x00000000 or some multiple of 512 minus 1. For the next programming cycle, calculate the starting address of the page by adding 512 to the starting address of the previous page.
              • If you are programming less than 512 bytes of data, make sure you start programming from the starting address of the page in which you are programming in order to avoid any address wrapping. You can calculate the starting address of the page as explained in the previous point.
              • In case you want to perform program operation starting from the middle of a page, you should calculate the space left in that particular page (last address of the page minus starting address for programming) and program only those many byte in that particular program operation. Poll the WIP and wait for the programming cycle to complete. Program the rest of the data from the starting address of the next page. In case your data is huge and might spill over till the next pages, you will have to further break it down to more number of program operations.

               

              Can i write data between two sectors??

              >> A sector is a collection of multiple pages. As you might know, page size for your device is 512 bytes and sector size is 256KB. Meaning, one sector will have 512 pages (256KB / 512 bytes = 512 pages). Hence, the ending address of a sector will also be the ending address of the last page in that sector. Therefore, if you try to program data between two sectors, the address will get wrapped to the starting address of the last page in that sector. This condition should be kept in mind while programming data between two sectors.

               

              >> Please note that there is no such limitations with reading operation. You can read the entire flash array in a single read operation.

               

              You will have to assess your application and use either of the above cases depending upon your application.

               

              Best Regards,

              Apurva

              1 of 1 people found this helpful