Recently I have spent quite a long time with the following issue: I need to measure an ADC input in continuous mode with reding results in interrupt. Occasionally I need to take one sample from different input and return back to the continuous mode. I wanted to perform four single shot conversions to settle the filter and take the last one as a result. But the single convert mode always timed out. After reading datasheet again and again, searching forums and a lot of source code tweaks I found a solution by adding a few us delay after reading single conversion result when the SM shall return back to the idle state before issuing command for new single conversion by writing 2 to ADC0MDE. The code excerpt looked like this:
case SD0_VOLT: //ADC0 mesures INP2
pADI_ADC0->MSKI = 0; //stop ADC0 interrupts measuring INP0
pADI_ADC0->CON = //change +INP mux to INP2, enable unipol no buffer intref ch2 AGND as -inp
(1<<19) + (1<<18) + (0xF<<14) + (0<<12) + (2<<5) + 0xF ;
dwData = 0xFFFF; //error return
bStatus = pADI_ADC0->STA; //clears status bits
for(i=0 ; i<4 ; i++) //measure 4-times to settle filter
Delay(5); //few us needed from finishing to starting new conversion !!!!!
pADI_ADC0->MDE = 2; //single conversion
dwStrt = dwTick;
if(dwTick - dwStrt > ADC_TO) //timeout 20ms
bStatus = pADI_ADC0->STA;
if(bStatus & 1)
dwData = pADI_ADC0->DAT >> 12; //resets RDY, goes to idle
break; //exit while loop
pADI_ADC0->CON = //+INP back INP0 enable unipol no buffer intref chan0 AGND as -inp
(1<<19) + (1<<18) + (0xF<<14) + (0<<12) + (0<<5) + 0xF ;
pADI_ADC0->MDE = 1; //continuous conversion
pADI_ADC0->MSKI = 1; //renew ADC0 interrupts measuring channel A current
Is this behavior of the ADC expected or mentioned anywhere in the datasheet or did I anything else wrong? The code was compiled with Keil MDK522 eval version tool.
Your insight would be appreciated.