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.

Problems with ADC and uDMA

Hello everyone,

I'm modifying the uDMA example to work with the ADC in ping-pong mode, but it's not working, the Tiva never gets into the interrupt handle of the ADC and the buffers never gets filled.

I'm using the TM4C129X, the configuration of the ADC is the one below

//*****************************************************************************
//
// Initializes the ADC peripheral to read the 
//
//*****************************************************************************
void
InitADCWithDMAModule(void)
{
    //
    // Enable the uDMA controller at the system level.  Enable it to continue
    // to run while the processor is in sleep.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    ROM_SysCtlPeripheralSleepEnable(SYSCTL_PERIPH_UDMA);
    
    //
    // Enable the ADC module and the port where the ADC pin is
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    
    while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_ADC0));
    
    
    
//******************************************************************************
//
//              Start the ADC sequence configuration
//
//******************************************************************************    
    
    //
    // Configure the function for the ADC pin in the port E
    //
    GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);

    //
    // Configure the ADC's clock to work on the desire frequency
    //
    ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 30);

    //
    // Configure the ADC's sequence in which the ADC will be working
    //
    ROM_ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_ALWAYS, 0);
    
    //
    // Configure step 0 on sequence 0.  Sample channel 0 (ADC_CTL_CH0) in
    // single-ended mode (default) and configure the interrupt flag
    // (ADC_CTL_IE) to be set when the sample is done.  Tell the ADC logic
    // that this is the last conversion on sequence 0 (ADC_CTL_END).
    // sequence 0 has 8 programmable steps. For more information on the ADC
    // sequences and steps, reference the datasheet.
    //
    ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH0);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_CH0);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH0);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 3, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
    
    
//******************************************************************************
//
//              Finish the ADC sequence configuration
//
//******************************************************************************





//******************************************************************************
//
//      Start the DMA configuration to work along with the ADC
//
//******************************************************************************
    //
    // Enable the uDMA controller.
    //
    ROM_uDMAEnable();
    
    //
    // Assign the DMA channel, in this case the ADC0 is in the channel 14
    //
    ROM_uDMAChannelAssign(UDMA_CH14_ADC0_0);

    //
    // Point at the control table to use for channel control structures.
    //
    ROM_uDMAControlBaseSet(pui8ControlTable);
    
    //
    // Enables DMA for sample sequence 0 (sequence needs to be previously config)
    //
    ROM_ADCSequenceDMAEnable(ADC0_BASE, 0);
    
    //
    // Put the attributes in a known state for the uDMA ADC channel.  These
    // should already be disabled by default.
    //
    ROM_uDMAChannelAttributeDisable(UDMA_CH14_ADC0_0,
                                    UDMA_ATTR_ALTSELECT | UDMA_ATTR_USEBURST |
                                    UDMA_ATTR_HIGH_PRIORITY |
                                    UDMA_ATTR_REQMASK);
    
    //
    // Only allow burst transfers for ADC0 channel
    //
    ROM_uDMAChannelAttributeEnable(UDMA_CH14_ADC0_0, UDMA_ATTR_USEBURST);

    //
    // Configure the control parameters for the primary control structure for
    // the ADC0 channel. The primary contol structure is used for the "A"
    // part of the ping-pong receive.
    //
    ROM_uDMAChannelControlSet(UDMA_CH14_ADC0_0 | UDMA_PRI_SELECT,
                              UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 |
                              UDMA_ARB_1024);

    //
    // Configure the control parameters for the alternate control structure for
    // the ADC0 channel.  The alternate contol structure is used for the "B"
    // part of the ping-pong receive.  The configuration is identical to the
    // primary/A control structure.
    //
    ROM_uDMAChannelControlSet(UDMA_CH14_ADC0_0 | UDMA_ALT_SELECT,
                              UDMA_SIZE_16 | UDMA_SRC_INC_NONE | UDMA_DST_INC_16 |
                              UDMA_ARB_1024);

    //
    // Set up the transfer parameters for the ADC0 primary control
    // structure.  The mode is set to ping-pong, the transfer source is the
    // SSFIFO0 data register, and the destination is the receive "A" buffer.  The
    // transfer size is set to match the size of the buffer.
    //
    ROM_uDMAChannelTransferSet(UDMA_CH14_ADC0_0 | UDMA_PRI_SELECT,
                               UDMA_MODE_PINGPONG,
                               (void *)(ADC0_BASE + ADC_O_SSFIFO0),
                               ADCpingBuff, 1024);

    //
    // Set up the transfer parameters for the ADC0 alternate control
    // structure.  The mode is set to ping-pong, the transfer source is the
    // SSFIFO0 data register, and the destination is the receive "B" buffer.  The
    // transfer size is set to match the size of the buffer.
    //
    ROM_uDMAChannelTransferSet(UDMA_CH14_ADC0_0 | UDMA_ALT_SELECT,
                               UDMA_MODE_PINGPONG,
                               (void *)(ADC0_BASE + ADC_O_SSFIFO0),
                               ADCpongBuff, 1024);

    //
    // Enable the ADC channel to transfer data
    //
    ROM_uDMAChannelEnable(UDMA_CH14_ADC0_0);
    ROM_uDMAChannelEnable(UDMA_CHANNEL_ADC0);

    //
    // Enable the ADC/DMA interrupts.
    //
    ROM_IntEnable(INT_UDMAERR);
    ROM_IntEnable(INT_ADC0SS0);

    ROM_ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS0);
    
//******************************************************************************
//
//      Finish the DMA configuration to work along with the ADC
//
//******************************************************************************  
}

Regards, Juan.

  • Hello Juan

    The software associated with the following reference design shows how to use ADC with DMA in Ping Pong mode

    www.ti.com/.../TIDM-TM4C129POEAUDIO

    Regards
    Amit
  • Amit Ashara said:
    The software associated with the following reference design shows how to use ADC with DMA...

    Hi Amit,

    You (always) know (just) where to go to find these (often requested) Tech Aids!   Now that's valuable - until you're away - or other vendor staff appear here - what then?

    Would it not make GREAT SENSE for (say) the "top ten" (predictable) user requests - which already have (nearly complete) solutions - to be published - and well-noted?

    Many, many user hours must be lost (wasted) by not better (i.e. somewhat) publicizing the availability of such EXISTENT Solutions.   

    Surely none here would "dare to challenge" the full right/entitlement of uber-useful: Blogs, Groups, Videos to their priority, "Top of forum, Red-Stripe emboldment" yet might there be (some) slight room to include, "Useful program solutions/associations?"   This reporter - among others - senses this addition as a significant value enhancement for the forum...   (and we realize it will be "duly noted...")

  • Hello cb1,

    And it has been challenged, among other "artifacts". The first step of addressing a lot of development issues, are getting the correct code in the context. The second step is to enable how easily users can navigate to it, which is a parallel (500% effort task at a giant).

    Regards
    Amit
  • Somehow the fact that, "Blogs, Groups, Videos" have found their way (near effortlessly) to, "Top of the Forum - High RECOGNITION STATUS" argues against such "500% effort task" as being (really) required to "properly" publicize vital Tech Aids.    Now that's duly noted!

    Withholding key/critical data from client users - even when requested repeatedly (as long done by this reporter) - appears not an especially well considered method to build brand loyalty AND boost Sales.   May we suggest that such, "giant" status may not have occurred if such "hoarding" of key/critical data was a long accepted & practiced - Standard Operating Procedure.

    And - even though "giant" status does speak to (some) skill/capability - it speaks (not one whit) to the fact that (seemingly) destructive (i.e. subtractive) roadblocks have been admitted (even welcomed) and that an even higher level of "giant" performance COULD be achieved...   Maddening...

  • Hello cb1,

    We have had this discussion earlier, and we need to get not only the correct links which lead to more relevant data, but also be able to somehow get what device-peripheral-functions are being covered....

    Regards
    Amit
  • cb1_mobile said:
    You (always) know (just) where to go to find these (often requested) Tech Aids!   Now that's valuable - until you're away - or other vendor staff appear here - what then?

    I note that the revamped Resource Explorer in CCS 6.2.0 now contains links to the TI Designs for the TM4C devices, albeit doesn't currently include the Audio Communication With Power Over Ethernet (PoE) Reference Design which Amit provided a link for. E.g.:

    So, it does look like improvements are being made to provide links to the available information.

  • Hello Chester,

    The Audio Communication With Power Over Ethernet (PoE) Reference Design got published on 31st Aug, after the Resource Explorer release. I have already asked the team to update the new TI Design, so it shall come up soon as well.....

    Regards
    Amit
  • Chester Gillon said:
    I note that the revamped Resource Explorer in CCS 6.2.0 now contains links to the TI Designs for the TM4C devices,

    Good that - yet HOW might that aid we "serious" multi-ARM vendor device users - who never/ever would employ (the so limited, & vendor restricted) CCS?   (as we must employ a "Pro" IDE - such as IAR and/or Keil)

    And - is it not true that STILL - that CCS mention remains: minor, hidden, buried, obscured?   How many besides CCS "mavens" knew of that?

    This always has been - and remains - an MCU centric forum.  (dating to pre T.I. - LMI days)   How possibly can, "Blogs/Groups/Videos" receive such over-arching publicity (very top of the forum, bathed in red stripe) - while key/critical MCU Trench/Tech Data - receives, (very) "back of the bus" treatment? 

    "Blogs, Groups, Videos" remain crystal clear - instantly "findable!"   Key/critical MCU Tech Data/Associations receive (only) - in stark contrast - an obscure, dismal reference.   Is this not quite similar to, "Applying a bandaid to a sliced Artery?"   How can this (ever) be justified?

  • cb1_mobile said:
    Good that - yet HOW might that aid we "serious" multi-ARM vendor device users - who never/ever would employ (the so limited, & vendor restricted) CCS?

    For those without CCS the Resource Explorer is available on the web. E.g. see http://dev.ti.com/tirex/#/?link=TM4C%20ARM%C2%AE%20Cortex%C2%AE-M4F%20MCU%2FTI%20Designs

  • And - of course - that link (properly) deserves Top of Forum Page, Red-Stripe Status - so that such key/critical data is rendered, "Quick, easy, even obvious to find."

    Your efforts are appreciated - yet the decision to "hoard" such data runs counter to client-user needs - and your silence in that regard is noted...
  • Hi Amit

    Thank you, I will check it and if I have some doubt I will ask you again. That's the kind of example I was looking for, all my code I base it on the uDMA example and the examples I see here in the forum.

    Regards, Juan
  • Hello Juan

    Do note that when starting and stopping DMA, the order of initialization and de-init of the peripherals can make a difference in code working/not working
  • cb1 said:
    Somehow the fact that, "Blogs, Groups, Videos" have found their way (near effortlessly) to, "Top of the Forum - High RECOGNITION STATUS" argues against such "500% effort task" as being (really) required to "properly" publicize vital Tech Aids.

    Despite the visual appearance of that red banner it appears that all the links on it are global rather than local. It may be that the site design/CMS does not allow more localized links there.

    Having said that, there is a strong need for such localized links (even a single link to a resources page would be a help). There are a number of items that otherwise are either difficult to find or are simply not found because almost no one knows they exist.

    Robert

  • Robert Adsett said:
    ...are simply not found because almost no one knows they exist.

    And - those (official) who DO know - allow the, "Hiding/hoarding of key/critical" Tech Data - which (was) and (remains) INDEFENSIBLE!

  • Hi Amit

    My code finally works, it was the order of initialization, I was doing first the ADC initialization and then the uDMA initialization.
    Also I forget to call ROM_ADCSequenceEnable(ADC0_BASE, 0); because I think that ROM_ADCSequenceDMAEnable(ADC0_BASE, 0); was the replace of the first one but I guess that both are needed, now I can see valid ADC lectures.

    Thanks Amit

    Regards