7 Replies Latest reply on Jun 30, 2019 11:51 PM by HemanthR_06

    fx3 spi read and write

    gean_3054931

      Hello,

      I am performing read and write operations on spi flash with the cypress given example code.

      (C:\Program Files\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbspidmamode).

      I have made settings as following in venodr device mode.

       

      for spi write,

       

      bytes to tranfer ( wLength ): 4096

      bmRequestType =  outendpoint 0x40

      bRequest      = 0xC2

      wValue        = 0x0000

      wIndex        = 0x1000 (4096)

       

      I am getting control out transfer completed in the control center along with sent test data

      is it mean spi write is happening successfuly?

       

      for spi read,

       

      bytes to tranfer ( wLength ): 4096

      bmRequestType =  inendpoint 0xc0

      bRequest      = 0xC3

      wValue        = 0x0000

      wIndex        = 0x1000 (4096)

       

      I am getting control in transfer completed in the control center.

      but 4096 bytes are zeros.

      spi is not reading actual sent test data.

      why this is happeing?

       

      thank you.

        • 1. Re: fx3 spi read and write
          HemanthR_06

          Hi,

           

          Before performing WRITE to FLASH, it has to erased.

          So, referring to cyfxusbspidmamode example, you need to send vendor command 0xC4 with wValue=1, Lower byte of wIndex = Sector Number.

           

          When you are doing write, why are you giving wIndex as 0x1000? Is it because you need to write to 0x1000 page address. If yes, then okay. I wanted to let you know that the wIndex here is not related to number of bytes you transfer.

           

          Regards,

          Hemanth

          • 2. Re: fx3 spi read and write
            gean_3054931

            Hello hemanth,

            thanks for the reply.

            In C:\Program Files\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbspidmamode readme.txt file,They have given as below for spi write and read,

             

            wIndex        = SPI flash page address (Each page is assumed to be of 256 bytes and the byte address is

                                  computed by multiplying wIndex by 256)

             

            if wIndex  is not = 0x1000 ,what will be the value for windex for spi write and read and also for spi flash erase.

            please let me know.

             

            thank you.

            • 3. Re: fx3 spi read and write
              HemanthR_06

              Hi,

               

              If you are reading/writing from/to the Page 0 of Flash then, you can put wIndex as Zero, If it is from Page 1 then wIndex = 1 and so on.

              If you want to perform Erase, then wValue = 1 and wIndex should be the sector number that you want to erase.

               

              Regards,

              Hemanth

              • 4. Re: fx3 spi read and write
                gean_3054931

                Hello,

                S25FL127SABMFI101 flash from cypress has 16kbytes.each page is containing 256bytes totally 63 pages from 0 to 63 pages.

                for the last page 63,wIndex = 0x0040.

                but for higher values for wIndex ,i am able to read and write to spi flash with control center.how ?

                 

                thank you

                • 5. Re: fx3 spi read and write
                  QiXi_1252501

                  你好!

                  我有一个问题请教。

                   

                  具体如下:

                   

                  我设计了一个CYUSB3014的实验板,连接电脑后controlcenter可以显示BootLoader

                  ,烧写代码到RAM中,显示烧写成功,但是并没有重枚举。也就是说电脑没有任何反应,包括识别USB设备,或者装驱动之类的。

                  另外我烧写到ROM(24LC1025)中,显示烧写成功,然后跳线选择ROM启动,也同样没反应,这是什么原因呢?

                  烧写的软件,包括烧写ROM的软件也按照技术手册用elf文件转换ok了,是经过其他电路验证没有问题的。

                  我不清楚问题出在什么地方,该如何解决。

                  • 6. Re: fx3 spi read and write
                    HemanthR_06

                    Hi,

                     

                    The size of the Flash S25FL127SABMFI101 is 16MB and not 16KB. Please check.

                     

                    Regards,

                    Hemanth

                    1 of 1 people found this helpful
                    • 7. Re: fx3 spi read and write
                      HemanthR_06

                      Hi,

                       

                      To isolate the problem, please load the following standard program to RAM and see if it is re-enumerating:

                      C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxbulksrcsink

                       

                      You have to load .img file to FX3 and not .elf

                       

                      If it is not re-enumerating you might have to look into the schematics. You can refer to AN70707 and also FX3 Super speed explorer kit schematic as reference

                       

                      Regards,

                      Hemanth