Hi I'm trying to setup a repeating DMA transfer of a ADC repeating sequnce to an array. When I run this code and exit from my setup function the controller dies on me. Seems like it jumps all over the place. I'm using the following setup code: void InitADC(void) { memset(ADCmemory, 0, sizeof(ADCmemory)); // ADC setup P6SEL = 0x07; // (A0-A2 = P6.0-P6.2) ADC12CTL0|=SHT0_8; // set sample and hold timings ADC12CTL0|C12ON;// Turn on ADC12 ADC12CTL0|=MSC; // Enable sequence ADC12CTL0|=REF2_5V; ADC12CTL0|=REFON; ADC12CTL1|=SHP; // Set sample and hold pulse mode ADC12CTL1|C12SSEL_0; // Set ADC12OSC source ADC12CTL1|C12DIV_5; // set clock divider=8 ADC12CTL1|=CONSEQ_1; // Set repeat sequence mode ADC12MCTL0 = SREF_1 + INCH_0; // ADC memory 0 channel 0 ADC12MCTL1 = SREF_1 + INCH_1; // ADC memory 1 channel 1 ADC12MCTL2 = SREF_1 + INCH_2; // ADC memory 2 channel 2 ADC12MCTL3 = SREF_1 + INCH_10 + EOS; // ADC memory 3 channel 10, EOS ADC12IFG = 0x00; // Clear IF ADC12CTL0|=ENC; // enable conversion DMA0SA = ADC12MEM0_; // Src address = ADC12 module DMA0DA = (int)ADCmemory; // Dst address = RAM array DMA0SZ = sizeof(ADC12MEM0_)*4; // Size in words (4 samples) DMACTL0 = DMA0TSEL_6; // ADC12IFGx triggers DMA0 // Block xfer, both src and dst increment, enable interrupt and DMA DMA0CTL = DMADT_5 + DMASRCINCR_3 + DMADSTINCR_3 + DMAIE + DMAEN; ADC12CTL0 |= ADC12SC; // Start conversion } And I use the following DMA ISR // DMA interrupt service routine interrupt[DACDMA_VECTOR] void DACDMA_ISR (void) { ADC12IFG = 0x00; // Clear ADCIFG to prepare for next trigger DMA0CTL &= ~DMAIFG; // Clear DMA0 interrupt flag _BIC_SR_IRQ(LPM0_bits); // Exit LPM0 on reti } I have found out that if I leave out the bit to start the conversion the code keeps running, but I'm not able to find out why it crashes when I do start the conversion... Any tips? Thanks Ingar F Pedersen
DMA transfer of ADC sequnce
Started by ●November 5, 2004