4 Replies Latest reply on Jul 13, 2020 2:27 AM by RashiV_61

    How to use DMA transfer to read data from SPI flash to RAM

    xixu_4093676

      Hi,

       

      Currently, We are using CyU3PSpiReceiveWords ( uint8_t *data,  uint32_t byteCount)  function to read spi flash data,

      the read speed is a little slowly, We want to get the read speed more faster,

      Is It support to use  DMA  mode to read data from SPI flash?

      I just see the function   

      extern CyU3PReturnStatus_t

      CyU3PSpiSetBlockXfer (

              uint32_t txSize,                /**< Number of words to be transmitted (not bytes) */

              uint32_t rxSize                 /**< Number of words to be received  (not bytes) */

              );

      The function only have the read size param, My question is how to set ram address to save spi data?

      Are there one sample to use the function?

       

      Thanks,

      Martin.xu

        • 1. Re: How to use DMA transfer to read data from SPI flash to RAM
          RashiV_61

          Hello,

           

          The function only have the read size param, My question is how to set ram address to save spi data?

          >> Please let me know if you are using a second stage boot loader for reading at from SPI flash to FX3 RAM? 

           

          Please refer to FX3BootAppGcc (second stage boot loader) firmware of the SDK which writes to FX3 RAM from SPI Flash in DMA mode

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

           

          Regards,

          Rashi

          • 2. Re: How to use DMA transfer to read data from SPI flash to RAM
            xixu_4093676

            Hello,

             

            The function only have the read size param, My question is how to set ram address to save spi data?

            >> Please let me know if you are using a second stage boot loader for reading at from SPI flash to FX3 RAM? 

            No ,We are not using  second stage boot loader, We are using the function in normal application.

            • 4. Re: How to use DMA transfer to read data from SPI flash to RAM
              RashiV_61

              Hello,

               

              Apologies for the delayed response.

               

              As per my understanding of your application, a piece of data will be read from the SPI flash and written to the FX3 RAM location. And this will not be done from the second stage bootloader but from the application firmware. Is my understanding right?

               

              As mentioned in my previous response you can refer to FX3BootAppGcc (second stage bootloader) for the implementation of the same.

              For the RAM address, you can refer to Figure 3.2 of the FX3 TRM (in the SDK) which mentions the different regions of the system memory. assuming that the data read from SPI flash is to be written in the code area. The code Area starts from the address 0x40003000. The default code area size is 180 KB i.e. from 0x40003000 to 0x40030000.

               

               

              In the Fx3BootAppGCC firmware, CyFx3BootSpiDmaXferData API is used to write, the data read from SPI Flash to FX3's RAM. The second parameter passed to this API is the address of the FX3 RAM to which the data is to be written.

              status = CyFx3BootSpiDmaXferData (CyTrue, downloadAddress, SPI_DMA_XFER_SIZE, 100);

               

              Note: Please confirm/check that the address at which the firmware code /data (current /running firmware) is written in the  RAM is not overwritten by the data which is read from SPI flash.

               

              Regards,

              Rashi