This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/CC3200SDK: Code Composer Studio™ forum

Part Number: CC3200SDK
Other Parts Discussed in Thread: CC3200

Tool/software: Code Composer Studio

hi 

I'm working with cc3200 and i'm trying to send data from "buffer1" to ""SPI-TX" using DMA with basic mode, and then receive Data from RX-SPI  to "buffer2" using DMA so i have some questions about this operation.

1-  what is the exactly meaning of the SPI flags : "SPI_INT_DMATX "    and   "SPI_INT_DMARX"

2- whats is difference between  those flags :   1)   "SPI_INT_DMATX"  and   "SPI_INT_TX_EMPTY" 

                                                                          2)  "SPI_INT_DMARX "  and  "SPI_INT_RX_FULL"

3- how i can generate interrupt when the all transfer is complete (all data are received in buffer2). or how i can know that the transfer is complete. 

best regards 

  • Hi,

    The SPI flags SPI_INT_DMATX and SPI_INT_DMARX are used when running the SPI peripheral in DMA mode. When you setup the SPI peripheral in DMA mode, you associate it with an RX and TX DMA channel that will manage the data in the SPI FIFOs. These DMA channels operate off of discrete DMA transfers that have a max transfer amount of 1024 words. When a DMA transfer is completed, you will need to reload the DMA transfer back into the DMA control table to continue passing data. This is where the SPI_INT_DMATX and SPI_INT_DMARX interrupts come in. Those interrupts inform the application that the TX and RX DMA transfers respectively have completed. From there, the interrupt handler can reload the transfers, signal to the main application that data is ready, or otherwise perform any needed processing.

    The difference between those DMA flags and the SPI_INT_TX_EMPTY/SPI_INT_RX_FULL flags is that the FIFO-related flags are mainly significant if you are manually reading/writing to the FIFOs. If you are using DMA, you should just go off of the SPI_INT_DMATX and SPI_INT_DMARX flags as the DMA peripheral will handle the FIFO for you.

    As for determining when transfer is complete, there are a couple options. The first is to set the SPI_XFERLEVEL->WCNT register with MAP_SPIWordCountSet() to set a number of SPI words to transfer. This will trigger the EOW interrupt once the target number of words have been transmitted. The main issue with this approach is that you can only instruct it to transfer 65534 words before it stops. If you want to transfer more data, or to have the SPI interface transmit continuously you cannot rely on this method.

    An alternate method that will require slightly more overhead is to simply increment some totalDataXfered variable in your SPI interrupt handler every time SPI_INT_DMATX occurs. Every time that interrupt fires, you know that you will have transferred a certain fixed amount of data (that you used to setup the DMA transfer in the first place). Thus, you can keep track of the total data transferred, and once you have hit your target amount disable the SPI interface and stop the transfer.

    A good reference for how to use SPI with DMA can be found in the SPI driver for the CC3220. The hardware SPI and DMA peripherals are the same between the CC3200 and the CC3220, and the driverlib is essentially the same too so you can use the same concepts and functionality in your CC3200 project. Pay particular attention to the spiHwiFxn() and configDMA(). I have attached them here for your convenience.

    /cfs-file/__key/communityserver-discussions-components-files/968/8688.SPICC32XXDMA.c

    /cfs-file/__key/communityserver-discussions-components-files/968/7183.SPICC32XXDMA.h

    Let me know if you need more clarification or if you have further questions on the DMA or SPI peripherals.

    Regards,

    Michael

  • hi M.Michael

    thank you for quick answer it was very interesting.
    I have another detail that i have know about SPI_INT_DMATX and SPI_INT_DMARX flags.
    You said : "Those interrupts inform the application that the TX and RX DMA transfers respectively have completed" .
    my question is : those flags indicate the transfer of 1 item is completed (so we need more transfer) or the transfer of all data is completed.
    In case of all transfer is completed : using this flag to indicate the transfer is complete is better in my opinion to use number of SPI word to transfer.
    In case of 1 item is transferred: we can use this flags to count the number of items transferred, and know when the transfer is complete according to the number of items transferred.

    best regards.
  • Hi,

    The SPI_INT_DMA* flags do not necessarily indicate that all data is completed for the SPI transfer, but they do indicate that all data is complete for that specific DMA transfer request. If you are only doing SPI transfers less than 1024 words in size, then a given SPI transfer will only need one DMA transfer and in that case SPI_INT_DMA* would indicate that the SPI transfer is complete. Below is an illustration of what I mean:

    SPI transfer 100 words:
    1. Setup SPI interface
    2. Load 100 word DMA transfer request into DMA peripheral
    3. Start transfer
    ...
    4. SPI_INT_DMATX received
    5. No more data to send, so stop interface

    SPI transfer 2000 words:
    1. Setup SPI interface
    2. Load 1024 word DMA transfer request into DMA peripheral
    3. Start transfer
    ...
    4. SPI_INT_DMATX received.
    5. Data remaining, load remaining words into DMA transfer request
    ...
    6. SPI_INT_DMATX received.
    7. No more data to send, so stop interface.

    Regards,
    Michael
  • hi M.Michael

    I would like to think you a lot, because this is exactly what i need

    best regards,
    Farah