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-ADC0 pingpong mode doesn't work properly!



Hi, I'm using Stellaris Launchpad. My project using ADC0-SS3 to capture internal temp sensor continuously with uDMA ping pong mode. The ADC0 is triggered by Timer 0.

I have a problem that the ADC interrupt handler triggered only once, then the uDMA channel is disabled.

This is my code for the interrupt handler:

void adcInterruptHandler(void)
{
  uint32_t mode;

  ADCIntClear(ADC0_BASE, 3);

  //
  // Check if the ping-pong buffer A is full.
  //
  mode = uDMAChannelModeGet(UDMA_CHANNEL_ADC3 | UDMA_PRI_SELECT);
  if (mode == UDMA_MODE_STOP) {
    //
    // Data was received complete into buffer A. So the controller is transfer
    // using buffer B. We should reset the channel for a new transfer.
    //
    bufferATransferCounter++;
    uDMAChannelTransferSet(UDMA_CHANNEL_ADC3 | UDMA_PRI_SELECT,
                          UDMA_MODE_PINGPONG,
                          (void *) (ADC0_BASE + ADC_O_SSFIFO3),
                          bufferA,
                          BUFFER_SIZE);
  }

  mode = uDMAChannelModeGet(UDMA_CHANNEL_ADC3 | UDMA_ALT_SELECT);
  if (mode == UDMA_MODE_STOP) {
    //
    // Data was received complete into buffer B. So the controller is transfer
    // using buffer A. We should reset the channel for a new transfer.
    //
    bufferBTransferCounter++;
    uDMAChannelTransferSet(UDMA_CHANNEL_ADC3 | UDMA_ALT_SELECT,
                          UDMA_MODE_PINGPONG,
                          (void *) (ADC0_BASE + ADC_O_SSFIFO3),
                          bufferB,
                          BUFFER_SIZE);
  }

  // Toggle the Pin
  GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2,
      (uint8_t) (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2)) ^ ((1 << 2))  );
  //uDMAChannelEnable(UDMA_CHANNEL_ADC3);
}

If I uncommented the last line of the code (uDMAChannelEnable(UDMA_CHANNEL_ADC3);), the interrupt handler will trigger continuously but it's not that I expected. Both channel PRI and ALT are in stop mode, from what I understand, it should be only one.

  • Okay I think I found the cause of my problem. This thread http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/236103/829334.aspx#829334 express similar issue.

    Since I don't have an oscilloscope here, I managed to test the problem by adding one more counter in the interrupt handler, the number of interrupts counter. I didn't set any breakpoints. I let the code run a few seconds then I stopped it. I found that the total interrupts times is equal to (bufferATransferCounter + bufferBTransferCounter). That's mean the code run as expected. Also, after stopped the code, the uDMA is also stopped and it won't trigger the interrupt anymore.

    I don't know if this is a debugger problem or not, I use Stellaris ICDI.