TempV1 = 0; //Reset variables TempI1 = 0; TempV2 = 0; TempI2 = 0; //Setup ADC for first trigger ADC10CTL1 = CONSEQ_3 + ADC10SSEL_2 + ADC10DIV_0 + SHS_2 + INCH_1; int c = 0; //Counter variable ADC10CTL0 |= ENC; //Enable ADC reading on next trigger of TIMER0_AO while (!(ADC10CTL1 & BUSY)); //This statement holds the micro until Timer0 CCR0 triggers. { } P3OUT |= BIT2; //Set port 2 pin 3. Flag for checking timing. while(c < 8 ) { while(!(ADC10CTL0 & ADC10IFG)) //ADC10B1: 0 Block 2 is filled. { // 1 Block 1 is filled } //ADC10IFG is set when either block becomes full //ADC10B1 is set when block 1 is full if(ADC10DTC0 & ADC10B1) { TempV1 = TempV1 + ADCData[0]; //Store readings TempI1 = TempI1 + ADCData[1]; _bic_SR_register(ADC10IFG); //_bic_SR_register(mask) is used to Clear bits in the status register. c++; } else { TempV1 = TempV1 + ADCData[2]; //Store readings TempI1 = TempI1 + ADCData[3]; _bic_SR_register(ADC10IFG); c++; } } P3OUT &= ~BIT2; ADC10CTL0 &= ~ENC; //Disable after desired number of readings. ADC10CTL1 &= ~CONSEQ_3; while ((ADC10CTL1 & BUSY)) //Verify that ADC has stopped. { { //Change trigger source here. ADC10CTL1 = CONSEQ_3 + ADC10SSEL_2 + ADC10DIV_0 + SHS_1 + INCH_1; ADC10CTL0 |= ENC; //Enable ADC reading on next trigger of TIMER0_A1 while (!(ADC10CTL1 & BUSY)); //This statement holds the micro until Timer0 CCR0 triggers at the start of dithering. { } P3OUT |= BIT3; c = 0; while(c < 8 ) { while(!(ADC10CTL0 & ADC10IFG)) { } if(ADC10DTC0 & ADC10B1) { TempV2 = TempV2 + ADCData[0]; //Store readings TempI2 = TempI2 + ADCData[1]; _bic_SR_register(ADC10IFG); //_bic_SR_register(mask) is used to Clear bits in the status register. c++; } else { TempV2 = TempV2 + ADCData[2]; //Store readings TempI2 = TempI2 + ADCData[3]; _bic_SR_register(ADC10IFG); c++; } } P3OUT &= ~BIT3; ADC10CTL0 &= ~ENC; //Disable after desired number of readings. ADC10CTL1 &= ~CONSEQ_3; Voltage1 = TempV1 >> 3; //Divide by 8 to average. Current1 = TempI1 >> 3; Voltage2 = TempV2 >> 3; Current2 = TempI2 >> 3;