Part Number:CC3200
Tool/software: Code Composer Studio
Hello!
I am trying to set up the DMA with ADC in Ping-Pong mode. I initialize the ADC, and its interrupt code is like this:
void ADCIntHandlerChV(void)
{
unsigned long ulChannelStructIndex, ulMode, ulControl;
tDMAControlTable *pControlTable;
unsigned long *pDataDumpBuff = NULL;
unsigned short Status;
Status = ADCIntStatus(ADC_BASE, pChannelVoltageAdcChannelNum);
ADCIntClear(ADC_BASE, pChannelVoltageAdcChannelNum,Status|ADC_DMA_DONE);
ulMode = MAP_uDMAChannelModeGet(pChannelVoltageDmaChannelNum | UDMA_PRI_SELECT);
if(ulMode == UDMA_MODE_STOP) {
ulChannelStructIndex = pChannelVoltageDmaChannelNum | UDMA_PRI_SELECT;
pDataDumpBuff = &(pChannelVoltageDmaDataDumpPing[0]);
}
else {
ulMode = MAP_uDMAChannelModeGet(pChannelVoltageDmaChannelNum | UDMA_ALT_SELECT);
if(ulMode == UDMA_MODE_STOP) {
ulChannelStructIndex = pChannelVoltageDmaChannelNum | UDMA_ALT_SELECT;
pDataDumpBuff = &(pChannelVoltageDmaDataDumpPong[0]);
}
}
if(pDataDumpBuff != NULL) {
pChannelVoltageDmaBlockCount++;
ulChannelStructIndex &= 0x3f;
pControlTable = uDMAControlBaseGet();
ulControl = (pControlTable[ulChannelStructIndex].ulControl &
~(UDMA_CHCTL_XFERSIZE_M | UDMA_CHCTL_XFERMODE_M));
ulControl |= UDMA_MODE_PINGPONG | ((M_TOTAL_DMA_SAMPLES - 1) << 4);
uDMAChannelControlSet(ulChannelStructIndex,ulControl);
CalculateFrequency();
if(M_TOTAL_DMA_BLOCKS_PER_SEC == pChannelVoltageDmaBlockCount) {
pChannelVoltageDmaBlockCount = 0;
BloackCount++;
}
ulChannelStructIndex &= 0x3f;
pControlTable = (tDMAControlTable *)HWREG(UDMA_BASE + UDMA_O_CTLBASE);
ulControl = (pControlTable[ulChannelStructIndex].ulControl &
~(UDMA_CHCTL_XFERSIZE_M | UDMA_CHCTL_XFERMODE_M));
ulControl |= UDMA_MODE_PINGPONG | ((M_TOTAL_DMA_SAMPLES - 1) << 4);
pControlTable[ulChannelStructIndex].ulControl = ulControl;
#if 0
ArrayIndexV = 0;
printf("\n\n\n\r");
while(ArrayIndexV < M_TOTAL_DMA_SAMPLES) {
printf("%d\n",(pDataDumpBuff[ArrayIndexV++]>> 2) & 0xFFF);
}
#endif
}
}
My idea is to continuously get the data with DMA, and do some calculations in the interrupt. The function I used to do the calculation is CalculateFrequency(). I found that when I put some simple codes in CalculateFrequency() and its computation time is short, the program can run continuously. But when I put some complicated codes in CalculateFrequency() thus increase its computation time. The program will go dead after running for some time, and the ADCIntHandlerChV function will be called only once or twice. I do not understand what's wrong with it. Can you give me some clues to solve this problem? Thank you in advance for your help.