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/TMS320F28379D: SPI DMA RX setting

Part Number: TMS320F28379D

Tool/software: Code Composer Studio

Dear support

I use spi dma for working with FPGA.

SPI work good without DMA support, but with DMA we have some problems. In scope I see that FPGA send correct data, but in the "rdata" buffer I see the previous data.

  I have to read twice(call StartDMACH6()) and only after it get the correct data in "rdata" buffer.

C3 include RX data 0xAAAA that is correct after the 1st StartDMACH6() calling

.My SPI setting is:

    SpiaRegs.SPIFFRX.all=0x2040;             // RX FIFO enabled, clear FIFO int
    SpiaRegs.SPIFFRX.bit.RXFFIL = 3;  // Set RX FIFO level

    SpiaRegs.SPIFFTX.all=0xE040;             // FIFOs enabled, TX FIFO released,
    SpiaRegs.SPIFFTX.bit.TXFFIL = 3;  // Set TX FIFO level

My DMA setting is:

#pragma DATA_SECTION("ramgs0");    // map the TX data to memory
Uint16 sdata[4] = {0};     // Send data buffer

#pragma DATA_SECTION("ramgs1");    // map the RX data to memory
Uint16 rdata[4] = {0};

#define BURST               2
#define TRANSFER        0

 

void dma_init()
{
    //
    // Initialize DMA
    //
    DMAInitialize();

    DMASource = (volatile Uint16 *)sdata;
    DMADest = (volatile Uint16 *)rdata;

    //
    // configure DMACH5 for TX
    //
    DMACH5AddrConfig(&SpiaRegs.SPITXBUF,DMASource);
    DMACH5BurstConfig(BURST,1,0);         // Burst size, src step, dest step
    DMACH5TransferConfig(TRANSFER,1,0);   // transfer size, src step, dest step
    DMACH5ModeConfig(DMA_SPIATX,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
                     SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
                     CHINT_END,CHINT_ENABLE);

    //
    // configure DMA CH2 for RX
    //
    DMACH6AddrConfig(DMADest,&SpiaRegs.SPIRXBUF);
    DMACH6BurstConfig(BURST,0,1);
    DMACH6TransferConfig(TRANSFER,0,1);


    DMACH6ModeConfig(DMA_SPIARX,PERINT_ENABLE,ONESHOT_DISABLE,CONT_DISABLE,
                     SYNC_DISABLE,SYNC_SRC,OVRFLOW_DISABLE,SIXTEEN_BIT,
                     CHINT_END,CHINT_ENABLE);
}

  StartDMACH5();                       // Start SPI TX DMA channel

  StartDMACH6();                       // Start SPI RX DMA channel

it seems that I have problem with spi fifo setting.

could you pls help me to fix the problem

Thanks,Sabina

  • Sabina,

    Both SPI and DMA configurations look good. I don't see any reason why you need to execute StartDMACH6() twice.

    Is SPI sending data continuously? I'm wondering whether SPI throughput is higher than what DMA can handle.

    Regards,
    Manoj
  • Hi Manoj,

    The ReadSPI problem appears only after WritetoSPI by calling  StartDMACH5() function. after this function calling data is written properly, but RXFFST=0x0011.

    only after "dummy" read by calling StartDMACH6() I see that rx fifo is empty.RXFFST = 0.

    After "dummy" read I can read data by calling  StartDMACH6() and get correct values.

    So my Write sequence is:

     StartDMACH5(); //write command to write, address and data( CommandW, Address, DataW, checksum) 
     StartDMACH6(); //dummy read

    and Read sequence is:

    StartDMACH5(); //write Command to read and address( CommandR, Address, null, checksum)
    StartDMACH6(); //read data(null, null, DataR, checksum)

    Is it correct behaviors of SPI-DMA with dummy read?

    Thanks,Sabina 

  • Sabina,

    Your second post helped me the understand your issue better.

    Each time you transmit a word, you will receive a word (mind you, this receive value just reflects the content of SPISOMI. It may not be the value transmitted from FPGA). So, if you transmit 3 words, you need to either perform a dummy read of RXFIFO for 3 words (or) you reset the RXFIFO point if you don't wish to perform dummy read.

    Regards,
    Manoj