This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC43XX (Cortex-M4): Timer triggered DMA transfer?

Hi to you all,
thank you for your patience: I know I'm publishing a lot of LPC43XX related questions. but the support on NXP forums is just.. well, something different from the one I found here, so I keep taking advantage of your know-how: maybe one day I'll be able to give something back, at least i hope so.

My first question generated a second question which brought me here.. I really hope this thing will not keep going on, but anyway.

As I asked on NXP Community Forum:

I've search the web, 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 it is grayed out:

    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 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. For your reference I'll attach the example 's source, the user manual can be found here.

Best regards,
Andrea

 7612.periph_dma_timertrig.zip