SPI-FLASH DMA(PSOC4)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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!

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

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.

0 Likes
Anonymous
Not applicable

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);
}

0 Likes
Anonymous
Not applicable

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.

0 Likes