Hi TI Team,
I am using DMA to fetch the conversion result from ADC10 module. It has been observed that sometimes DMA interrupts gets lost or maybe ADC10 module gets stuck. Please check the attached snapshot and below code Initialization.
void initAdc10(void) {
// Setup P1.2 A0, 1.1 A1, 1.0 A2
P1SEL |= BIT0 | BIT1 | BIT2; // Set P1.0,.1,.2 to non-IO
__disable_interrupt(); // Disable interrupts; Port Map cnfg
PMAPKEYID = PMAPKEY; // Enable access Port Mapping regs
P1MAP2 = PM_ANALOG; // Enable A0
P1MAP1 = PM_ANALOG; // Enable A1
P1MAP0 = PM_ANALOG; // Enable A2
PMAPKEYID = 0; // Disable access Port Mapping regs
__enable_interrupt(); // Re-enable all interrupts
// Setup ADC10
ADC10CTL0 = ADC10SHT_2 | ADC10MSC | ADC10ON; // 16ADCclks, MSC, ADC ON
ADC10CTL1 = ADC10SHP | ADC10CONSEQ_3; // pulse sample mode, repeated sequence
ADC10CTL2 = ADC10RES; // 10-bit resolution
ADC10MCTL0 = ADC10INCH_2; // A0,A1,A2(EoS), AVCC reference
// Setup DMA0 (ADC10IFG trigger)
DMACTL0 = DMA0TSEL_24; // ADC10IFG trigger
DMA0SZ = 192;
__data20_write_long((uintptr_t) &DMA0SA, (uintptr_t) &ADC10MEM0);
// Source single address
__data20_write_long((uintptr_t) &DMA0DA, (uintptr_t) &ADC_Result[0]);
// Destination array address
DMA0CTL = DMADT_4 | DMADSTINCR_3 | DMASWDW | DMAEN | DMAIE;
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=DMA_VECTOR
__interrupt void DMA0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(DMA_VECTOR))) DMA0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch (__even_in_range(DMAIV, 16))
{
case DMAIV_NONE: break; // No interrupts
case DMAIV_DMA0IFG: // DMA0IFG = DMA Channel 0
ADC10CTL0 &= ~ADC10ENC; // 64 conversions complete
dma_flag = 1;
break;
case DMAIV_DMA1IFG: break; // DMA1IFG = DMA Channel 1
case DMAIV_DMA2IFG: break; // DMA2IFG = DMA Channel 2
case 8: break; // Reserved
case 10: break; // Reserved
case 12: break; // Reserved
case 14: break; // Reserved
case 16: break; // Reserved
default: break;
}
}
// ADC main task
void adc_main(void) {
if (dma_flag) {
ADC10CTL0 |= ADC10ENC | ADC10SC;
dma_flag = 0;
}
}