- Sat Apr 19, 2008 2:58 pm
#46720
I am trying to get my ADC to sample 4 channels either all at once or one every quarter second. So, each channel would be sampled about once every second. So far I think I have the ISR and the ADC all setup right, I just can't seem to start the sampling process, here is my code
Code: Select all
I would really appreciate any help, thanks.int main(void) {
WDTCTL = WDTPW + WDTHOLD; //turn off watchdog timer
P6SEL = 0x0F;
int A0results = 0;
int A1results = 0;
int A2results = 0;
int A3results = 0;
/***** ADC ISR *****/
#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR (void);
{
A0results = ADC12MEM0; // 5 volt rail voltage
A1results = ADC12MEM1; // 5 volt rail current
A2results = ADC12MEM2; // 12 volt rail voltage
A3results = ADC12MEM3; // 12 volt rail current
}
/***** Setup ADC *****/
ADC12CTL0 |= SHT0_6; //sample and hold time -- 128 cycles
ADC12CTL0 |= REF2_5V; //2.5V Ref
ADC12CTL0 |= REFON; //Ref On
ADC12CTL0 |= ADC12ON; //Turn on ADC12
ADC12CTL0 |= ENC; //ADC12 Enabled
ADC12CTL0 |= ADC12SC; //Start Conversion
ADC12CTL1 |= SHP;//selects ADC source to output of sampling timer
ADC12CTL1 |= ADC12SSEL_1;
ADC12CTL1 |= CONSEQ1; // Use sampling timer signal sourced from sampling timer, use ACLK
ADC12IE = 0x01; //Enable Interrupts
ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1
ADC12MCTL2 = INCH_2; // ref+=AVcc, channel = A2
ADC12MCTL3 = INCH_3+EOS; // ref+=AVcc, channel = A3, end seq.
}