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.

uDMA and ADC ping pong interrupt issue

Hello all.

I am using uDMA to get two channels of data  from the ADC0. Both channels (let's call them CHa and CHb) are sampled at the same time, so at the end of the pong buffer I have all the points alternated in the way:

array_of_data= CHa1-CHb1-CHa2-CHb2-.....-CHaN-CHbN

The interrupt handler for this DMA-ADC interrupt is:

ROM_ADCIntClear (ADC0_BASE, ADC_SEQUENCER);


//
// If the channel's not done capturing, we have an error
//
if (ROM_uDMAChannelIsEnabled (UDMA_CHANNEL_ADC2))
{
g_ulBadPeriphIsr2++;
return;

}

//First block - PRI
ulMode = ROM_uDMAChannelModeGet(UDMA_CHANNEL_ADC2 | UDMA_PRI_SELECT);

if (ulMode == UDMA_MODE_STOP)
{
cnt_bloque1++;
estado_int_bloque1=!estado_int_bloque1;

GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_3,estado_int_bloque1*0xFF);

ROM_uDMAChannelTransferSet (UDMA_CHANNEL_ADC2 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
(void *) (ADC0_BASE + ADC_O_SSFIFO2 + (0x20 * UDMA_ARB_1)),
g_ulADCValues, NUM_SAMPLES);/**/


}

//Second block - ALT
ulMode = ROM_uDMAChannelModeGet (UDMA_CHANNEL_ADC2 | UDMA_ALT_SELECT);

if (ulMode == UDMA_MODE_STOP)
{

cnt_bloque2++;
estado_int_bloque2=!estado_int_bloque2;

GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_0,estado_int_bloque2*0xFF);


ROM_uDMAChannelTransferSet (UDMA_CHANNEL_ADC2 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
(void *) (ADC0_BASE + ADC_O_SSFIFO2 + (0x20 * UDMA_ARB_1)),
&g_ulADCValues[NUM_SAMPLES], NUM_SAMPLES);/**/

}


ROM_uDMAChannelEnable (UDMA_CHANNEL_ADC2);

flag_data_ready=true;


The date seems to be consistent to what I am expecting, however, as you can see, I am changing the state of some GPIO pins to check in an oscilloscope the timing of the intterupt and what I find is this:

So both PRI and ALT states of the uDMA interrupt are interrupting at the same time!!!

I have checked also via JTAG and it happens the same, everytime "ulMode = ROM_uDMAChannelModeGet()" is checked I get a UDMA_MODE_STOP for both modes even in the same interrupt.

Shouldn't I get somethinbg like this and half the period?

 I mean, shouldn't PRI and ALT modes interrupt alternated instead of interrupt at the same time? But the data seems to be OK, just a little glitch of some samples (about 8) at the beggining of the capture.

Regards

  • PAk SY said:

    The interrupt handler for this DMA-ADC interrupt is:

    ROM_ADCIntClear (ADC0_BASE, ADC_SEQUENCER);


    //
    // If the channel's not done capturing, we have an error
    //
    if (ROM_uDMAChannelIsEnabled (UDMA_CHANNEL_ADC2))
    {
    g_ulBadPeriphIsr2++;
    return;

    }

    [/quote]Since the UDMA_CHANNEL_ADC2 is configured for ping-pong mode i think the test on if the channel is done capturing at the start of the DMA interrupt handler is causing the problem in that the sequence is:

    a) UDMA_CHANNEL_ADC2 is configured for ping-pong mode with the PRI and ALT channels configured.

    b) The PRI channel capture completes, and the DMA interrupt fires. The ROM_uDMAChannelIsEnabled (UDMA_CHANNEL_ADC2) test indicates the channel is enabled, since the ALT channel capture is in progress. This causes the DMA interrupt handler to return and not re-enable the PRI channel.

    c) The ALT channel capture completes, and the DMA interrupt fires. The ROM_uDMAChannelIsEnabled (UDMA_CHANNEL_ADC2) test now indicates the channel is disabled since both the PRI and ALT channel captures have completed. The interrupt handler then re-enables both the PRI and ALT channels at the same time.

    d) The sequence b) and c) repeats. The apparent glitch in the samples could be explained by the PRI and ALT channels only being re-enabled once both PRI and ALT have completed their captures.

    Can you try removing the test on ROM_uDMAChannelIsEnabled (UDMA_CHANNEL_ADC2) from the DMA interrupt handler to see if that corrects the problems of:

    1) Both PRI and ALT channel completion being handled at the same time

    2) The glitch of some samples between captures.

    [Looking at TivaWave DMA examples  uDMAChannelIsEnabled isn't checked when ping-pong mode is used]

  • Chester Gillon said:

    Can you try removing the test on ROM_uDMAChannelIsEnabled (UDMA_CHANNEL_ADC2) from the DMA interrupt handler to see if that corrects the problems of:

    1) Both PRI and ALT channel completion being handled at the same time

    2) The glitch of some samples between captures.

    [Looking at TivaWave DMA examples  uDMAChannelIsEnabled isn't checked when ping-pong mode is used]

    Like that, worked 100% as you said.
     
     
     
    Thank you very much for the time and support Chester, your help in this forum is more than essential.
    Best Regards