# ADuC7061 - right way to channel switching

Question asked by Dimion on Mar 2, 2011
Latest reply on Mar 7, 2011 by MikeL

Hello!

I'm want to measure 4 channels at secondary ADC and one channel at first ADC. Right now I switching channels for secondary ADC after ADC1 ready flag is set. But it looks like this method is change ADC0 measuring period. Please look at source bellow. Question - what is right way to switch channel at secondary ADC?

unsigned int    temp;

ADCFLT = 0x0003;                                            // Chop off, 2Khz samping rate, SF = 3.    No averaging

//ADCMDE = 0x0080 | 0x0003;                            // 512KHz clock source to ADC, Idle mode

ADCMDE = 0x0080 | 0x0000;                            // 512KHz clock source to ADC, Power down

// Configure ADC1 for continuous conversions

ADC1CON =                                                        //Internal reference Gain = 1

0x0400 | 0x0100 |                                    // bits{10:7} = [1010] = ADC9/ADC5 (single-ended mode).

// Configure ADC0 for continuous conversions

ADC0CON =                                                        //Internal reference Gain = 1

FIQEN     |= 0x0400;                                    // Enable ADC interrupt

ADCMDE = 0x0001 | 0x0080;                        // Continious Conversion mode, 512KHz clock source to ADC.

};

__arm void fiq_handler(void){
static    unsigned int    adc1_ch = 0;
const        unsigned int    adc1_channels[] = {(0x04<<7), (0x05<<7), (0x06<<7)};
int    temp, have_ch1 =0;

/* Check for ADC interrupt */
if((FIQSTA & 0x0400) == 0) {       // Read  IRQSTA register and check for valid mask
//    debug_pin_0_set();
return;
}

debug_pin_1_togle();
debug_pin_0_togle();
have_ch1 =1;
break;
debug_pin_0_togle();
have_ch1 =1;
break;
debug_pin_1_togle();
break;
}