Configure DMA for SSP transfer

29 Jan 2011

Hello to all, I'm trying to configure the DMA to send data to the SSP1 (mbed SPI pins: 5, 6, 7).
I modified the code from this topic[1] in this way:

    #define DMA_CHANNEL_ENABLE      1
    #define DMA_TRANSFER_TYPE_M2P   (1UL << 11)   
    #define DMA_CHANNEL_TCIE        (1UL << 31)
    #define DMA_CHANNEL_SRC_INC     (1UL << 26)
    #define DMA_MASK_IE             (1UL << 14)
    #define DMA_MASK_ITC            (1UL << 15)

    /* Enable The transmit FIFO for the DMA */
    LPC_SSP1->DMACR|=2;
    
    /* Power up the GPDMA. */
    LPC_SC->PCONP |= (1UL << 29);
    LPC_GPDMA->DMACConfig = 1;
    LPC_GPDMA->DMACIntTCClear = 0x1;
    NVIC_EnableIRQ(DMA_IRQn);
       
    /* Prep Channel0 to send 1024 byte to the SSP. */
    LPC_GPDMACH0->DMACCSrcAddr  = (uint32_t)buffer;
    LPC_GPDMACH0->DMACCDestAddr = (uint32_t)&LPC_SSP1->DR;
    LPC_GPDMACH0->DMACCLLI      = 0;
    LPC_GPDMACH0->DMACCControl  = DMA_CHANNEL_TCIE | DMA_CHANNEL_SRC_INC | 1024;

    /* Fire GPDMA Channel0 */
    LPC_GPDMACH0->DMACCConfig = DMA_CHANNEL_ENABLE | 
                                DMA_TRANSFER_TYPE_M2P |
                                DMA_MASK_IE |
                                DMA_MASK_ITC;

extern "C" void DMA_IRQHandler(void) __irq {
    if (LPC_GPDMA->DMACIntStat & 1) {
        if (LPC_GPDMA->DMACIntTCStat & 1) {
            myled3 = 1;    
            LPC_GPDMA->DMACIntTCClear = 1;
        }
        if (LPC_GPDMA->DMACIntErrStat & 1) {
            myled4 = 1;
            LPC_GPDMA->DMACIntErrClr = 1;
        }
    }
}


But the DMA transfer never start!
Where am I doing wrong?

[1] http://mbed.org/forum/mbed/topic/1138/?page=1#comment-5543

29 Jan 2011

Take a look at MODDMA library I released.

29 Jan 2011

Hello Andy, I try your lib too, but with the same result!

Do I need to make a write to the SPI to start the DMA transfer? It seems as if missing the start!

TIA

Andy K wrote:

Take a look at MODDMA library I released.

29 Jan 2011

No, write not required. Enabling the DMA channel should be enough to start teh transfer. Did you remember to enable the SSP for DMA?...

    /* Enable SSP0 for DMA. */
    LPC_SSP0->DMACR = 0x3;

// or...

    /* Enable SSP1 for DMA. */
    LPC_SSP1->DMACR = 0x3;
29 Jan 2011

You may find this useful as a reference... /users/AjK/programs/SOWB/lg489e/docs/flash__read_8c_source.html

29 Jan 2011

Yes, I use

    /* Enable The transmit FIFO for the DMA */
    LPC_SSP1->DMACR|=2;

and I try the value 3 as on your example. But without success.
Before to configure the DMA I configure the SPI pins, format and speed.
The SPI at pins 5, 6 and 7 is the SSP1 so I'm sure I'm using the correct one...

Andy K wrote:

No, write not required. Enabling the DMA channel should be enough to start teh transfer. Did you remember to enable the SSP for DMA?...

29 Jan 2011

If you see the reference above I use the DMA to transfer pages from a flash device at 25MHz without any problems. Have a look through that, otherwise can you publish your program and place a link here so we can see it in whole?

29 Jan 2011

Andy,
I saw that I do not have
LPC_GPDMA->DMACSoftSReq = 0xC;
in my code.

Let me try this code...

Thank you for the fast replay!

Andy K wrote:

If you see the reference above I use the DMA to transfer pages from a flash device at 25MHz without any problems. Have a look through that, otherwise can you publish your program and place a link here so we can see it in whole?