AnsweredAssumed Answered

LPC43XX: Timer triggered DMA transfer?

Question asked by Andrea Bettati on Mar 5, 2017
Latest reply on Apr 15, 2018 by Yuanchen Gao

Hi to you all,
I've search the web (having a thread going on ARM Connected Community), read the manual, tried LPCOpenV2.20 (last available) and tried my code too, but: I'm still unable to trigger a memory-to-memory DMA transfer using a timer as a trigger.
LPCOpen provides an example which is similar to what I'm trying to do: "DMA example using a timer capture input as a trigger", actually I'm trying to use a timer match as a trigger.
The setup function looks like this (Note that the //comments are not mine):

/* Setup DMA M2M transfer to trigger on timer match */
static void setupDMATrigger(void)
{
    /* Initialize GPDMA controller */
    Chip_GPDMA_Init(LPC_GPDMA);

    /* Get DMA channel */
    dmaCh = Chip_GPDMA_GetFreeChannel(LPC_GPDMA, GPDMA_CONN_MAT0_0);

    /* Setup DMA transfer */
    Chip_GPDMA_Transfer(LPC_GPDMA, dmaCh,
                      (uint32_t) &source[0], GPDMA_CONN_MAT0_0, //(uint32_t) &dest[0],
                      GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA,
                      sizeof(source));

//            Chip_GPDMA_Stop(LPC_GPDMA, dmaChSSPTx);

    /* Enable GPDMA interrupt */
    NVIC_EnableIRQ(DMA_IRQn);
}

But then in the main function:

int main(void)
{
    int numDmaXfers = 0;

    SystemCoreClockUpdate();
    Board_Init();

    /* Setup tiemr capture input used for DMA trigger */
    setupTimerCapInput();

    /* Setup timer for match event on each capture event */
    setupTimerTrigger();


    /* Setup DMA for memory to memory transfer on timer match event */
//    setupDMATrigger();


    /* Enable timer interrupt */
    NVIC_EnableIRQ(TIMER0_IRQn);
    NVIC_ClearPendingIRQ(TIMER0_IRQn);

... etc, etc ...

The function is grayed out!

The timer has it's own setup, but I believe that's not critical, the manual states this about DMA Operation (Chapter 32, sec. 32.7.2):

DMA requests are generated by 0 to 1 transitions of the External Match 0 and 1 bits of
each timer. In order to have an effect, the GPDMA must be configured and the relevant
timer DMA request selected as a DMA source via the CREG block, see Table 101.

So it looks to me, that the timer just keeps going and the DMA must "sense" the timer REQ. That makes well.. sense.
The problem is in the Chip_GPDMA_Transfer call: GPDMA_CONN_MAT0_0 is not the destination. And I believe &dest[0] was correct.

How am I supposed to connect the peripheral to DMA in a way such that it triggers the transfer, but it is not the source nor the destination (because actually it isn't)?


Any help would be highly appreciated, and I'll attach both the example 's source and the user manual for your reference.

Regards,
Andrea

Original Attachment has been moved to: cr_startup_lpc43xx.c.zip

Original Attachment has been moved to: sysinit.c.zip

Original Attachment has been moved to: periph_dma_timertrig.c.zip

Outcomes