I am having a problem of getting ADC data using DMA pingpong mode on CC3200.
Looks like there is a non-stop DMA interrupt.
Did anyone try getting ADC data using DMA mode?
This is how I setup the ADC and the DMA interrupt handler.
Appreciated if anyone can tell me what I missed.
#define DMA_ITEM_SIZE 800
unsigned long g_ulDMABuf0[DMA_ITEM_SIZE];
unsigned long g_ulDMABuf1[DMA_ITEM_SIZE];
int g_DMABufferIndex = 0;
void InitDMA(void)
{
g_DMABufferIndex = 0;
MAP_PinTypeADC(PIN_59, PIN_MODE_255);
ADCIntRegister(ADC_BASE, ADC_CH_2, DMAInterruptHandler);
ADCIntClear(ADC_BASE, ADC_CH_2, ADC_DMA_DONE);
ADCIntEnable(ADC_BASE, ADC_CH_2, ADC_DMA_DONE);
ADCChannelEnable(ADC_BASE, ADC_CH_2);
ADCDMAEnable(ADC_BASE, ADC_CH_2);
ADCChannelEnable(ADC_BASE, ADC_CH2_2);
ADCTimerConfig(ADC_BASE,2^17);
ADCTimerEnable(ADC_BASE);
ADCEnable(ADC_BASE);
SetupTransfer(UDMA_CH16_ADC_CH2 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
DMA_ITEM_SIZE-1, UDMA_SIZE_32, UDMA_ARB_4,
(void *)(ADC_BASE + ADC_O_channel4FIFODATA),
UDMA_SRC_INC_NONE,
&g_ulDMABuf0,
UDMA_DST_INC_32);
SetupTransfer(UDMA_CH16_ADC_CH2 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
DMA_ITEM_SIZE-1, UDMA_SIZE_32, UDMA_ARB_4,
(void *)(ADC_BASE + ADC_O_channel4FIFODATA),
UDMA_SRC_INC_NONE,
&g_ulDMABuf1,
UDMA_DST_INC_32);
}
void DMAInterruptHandler(void)
{
unsigned long ulStatus;
unsigned long ulMode;
if ((g_DMABufferIndex & 1) == 0)
{
ulMode = MAP_uDMAChannelModeGet(UDMA_CH16_ADC_CH2 | UDMA_PRI_SELECT);
if (ulMode == UDMA_MODE_STOP)
{
SetupTransfer(UDMA_CH16_ADC_CH2 | UDMA_PRI_SELECT,
UDMA_MODE_PINGPONG,
DMA_ITEM_SIZE-1, UDMA_SIZE_32, UDMA_ARB_4,
(void *)(ADC_BASE + ADC_O_channel4FIFODATA),
UDMA_SRC_INC_NONE,
&g_ulDMABuf0,
UDMA_DST_INC_32);
g_DMABufferIndex = 1;
}
}
else
{
ulMode = MAP_uDMAChannelModeGet(UDMA_CH16_ADC_CH2 | UDMA_ALT_SELECT);
if (ulMode == UDMA_MODE_STOP)
{
SetupTransfer(UDMA_CH16_ADC_CH2 | UDMA_ALT_SELECT,
UDMA_MODE_PINGPONG,
DMA_ITEM_SIZE-1, UDMA_SIZE_32, UDMA_ARB_4,
(void *)(ADC_BASE + ADC_O_channel4FIFODATA),
UDMA_SRC_INC_NONE,
&g_ulDMABuf1,
UDMA_DST_INC_32);
g_DMABufferIndex = 0;
}
}
ADCIntClear(ADC_BASE, ADC_CH_2, ADC_DMA_DONE);
}
Thanks.