4 Replies Latest reply on May 2, 2017 7:46 AM by e.pratt_1639216

    SPI-FLASH DMA(PSOC4)

    chongchong.ding_2073086

      hi,bro:

         

          I got some troubles with PSOC4 ble kit,and need some help.

         

      Q : Cause of the low speed of write flash directly with "spi serial communication block", we have decide to use the DMA component,but i am puzzle with the struct "cydma_init_struct".

         

      the "addressIncrement" field witch comment as:    /* Specifies whether the source and/or destination address will be
          * incremented after the transfer of each single data element.*/

         

      i donn't know how to configure with it where i actually need the source address increased but does not the destination address.

         

      what's more ,could you post me the detail of this struct ,or the sample driver of 'S25FL128' will much more better.

         

                                                                                                                                                           thanks a lot!

        • 1. Re: SPI-FLASH DMA(PSOC4)
          user_1377889

          Welcome in the forum.

             

          "Q : Cause of the low speed of write flash directly with "spi serial communication block" This might be a language problem, so can you please tell us a bit more what you exactly mean. Writing to flash using DMA is not possible and the question is why you want to write to flash at all:

             

           

             

          Bob

          • 2. Re: SPI-FLASH DMA(PSOC4)
            user_78878863

            Sorry, my crystal ball is currently in repair, but I can make an assumption: you want to write to a SPI Flash memory chip (S25FL128). We would need to look at your code to determine why you think SPI communication is slow. You can be quite efficient when sending data via SPI, when using the FIFO (basically as fast as you can write a look checking a flag and putting a byte into memory).

               

            When you want to use DMA: the source address needs to be incremented so you transfer the complate buffer. Start at the beginning of your buffer, and set the transfer count to the size of your buffer (e.g. 256 bytes). The destination address is the FIFO register of the SPI master. Read the documentation of the DMA component, it explains all the needed API calls.

               

            Using google for 'psoc spi dma' I find two app notes regarding SPI master and DMA. Altough they are for PSoC3/5, the principle should be clear.

            • 3. Re: SPI-FLASH DMA(PSOC4)
              chongchong.ding_2073086

              hi:

                 

              you are right,that's what i want to do.when i try to eraseall the flash ,but failed.please see the code below:

                 

               

                 

              cystatus EMI_EraseAll(void)
              {
                  EMI_SPIM_SpiUartClearRxBuffer();
                  EMI_SPIM_SpiUartClearTxBuffer();
                  uint8 cmd[2]={NOR_FLASH_INSTRUCTION_WRITE_ENABLE,NOR_FLASH_INSTRUCTION_BULK_ERASE};
                  EMI_SPIM_SpiUartPutArray(cmd,2);
                  while(EMI_SPIM_SpiUartGetTxBufferSize()!=0) 
                  {
                  }
                  EMI_SPIM_SpiUartClearRxBuffer();
                  EMI_SPIM_SpiUartClearTxBuffer();
                  while(EMI_IsBusy())
                  {
                      ;
                  }
                  return (CYRET_SUCCESS);
              }

              • 4. Re: SPI-FLASH DMA(PSOC4)
                e.pratt_1639216

                It could be you are getting stuck in one of the two loops?

                   

                Also, you can check the RX buffer and see if any return data is received.