I am unsuccessfully attempting to take successive measurements and store them to memory on the G2955. My goal is to use the timer to trigger the start of measurements and then rapidly take four and average the result.
My ADC initialization is as follows:
void ADC10_init(void)
{
ADC10CTL0 &= ~ENC;
ADC10CTL0 = ADC10IE + MSC + ADC10ON + REFON + REF2_5V + ADC10SHT_0 + SREF_1;
ADC10AE0 |= 0x7; // P2.0, P2.1, and P2.2 for ADC. (000111 = 0x7)
//Continuous data transfer
ADC10DTC0 = ADC10TB + ADC10CT;
//Define the number of transfers in each block of data
ADC10DTC1 = 2; //Ch 1 down to 0.
while (ADC10CTL1 & BUSY); // Wait if ADC10 core is active
ADC10SA = (unsigned int)&ADCData[0]; // Data buffer, start declared as: unsigned int ADCData[5];
ADC10CTL0 |= ENC; // Enable ADC
}
My measurement code is:
ADC10CTL1 = CONSEQ_2 + ADC10SSEL_2 + ADC10DIV_0 + SHS_2 + INCH_1;
ADC10CTL0 |= ENC; //Enable ADC reading on next trigger of TIMER0_A
while (!(ADC10CTL1 & BUSY)); //This statement holds the micro until Timer0 CCR0 triggers.
{
}
int c = 0;
while (ADC10CTL1 & BUSY); //Micro should stay in this loop unitl I disable the ADC
{
while(c <= 4 )
{
if(ADC10IFG && ADC10B1) //This code should trigger when the first block is full
{
TempV1 = TempV1 + ADCData[0]; //Store readings 0,1
TempI1 = TempI1 + ADCData[1];
_bic_SR_register(ADC10IFG); //_bic_SR_register(mask) is used to Clear bits in the status register.
c++;
}
if(ADC10IFG && !ADC10B1) //This block should trigger when the second block is full
{
TempV1 = TempV1 + ADCData[2]; //Store readings
TempI1 = TempI1 + ADCData[3];
_bic_SR_register(ADC10IFG);
c++;
}
}
ADC10CTL0 &= ~ENC; //Disable after 4 readings.
}
Currently, when I step through the code I only enter the block one (first) if statement. For some reason when I step I just loop through that code four times instead of moving on to read block two data. I guess this could be because none of the interrupt timing works well when stepping. My temp variables are also not registering the test signal I am sending into the ADC.
Any advice would be appreciated!
Thanks,