Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 21927

odd behaviour with adc on msp430g2553 while debugging using CCS (as designed?)

$
0
0

Hi everyone.

I have the following setup:

P1.0 (A0) is connected to a 1:1 resistor divider from my 5V rail (which is currently not connected, so assume p1.0 to be at 0v)

I would like to continuously sample:

channel 0 (to measure the actual voltage on the 5V rail)

channel 10 (to sample temperature)

and channel 11 (to get vcc/2)

I configured the adc to use 2.5V internal reference, clocked it off of MCLK with a sample&hold time of 64 clks.

I'm using the DTC to write the values continuously into a global array x[12]

Using a setting of ADC10AE0 = BIT0, ADC10DTC1 = 11 and ADC10CTL1 |= INCH11, i expect the array to be filled with the values from the 5V rail, VCC and the temperature sensor in x[0], x[11] and x[10] respectively. values x[1] - x[9] are ignored and presumed garbage

This seems to work beautifully until i break the program using CCS. whether the program has been running for a second, or for 10 minutes doesnt matter; the first time i break (by pausing or by having a specific breakpoint set), the array holds exactly what i expect. After continuing the program, however, the values seem to be offset randomly.

It appears, that breaking the program using CCS does not prevent the ADC from running and continuing to go down the mux to channel 10, but without properly modifying the internal counter based on ADC10SA.

Is that intended behaviour? Is there some configuration i'm missing?

I got it working as expected by doing single sequence conversion rather than repeated sequence conversions, and disabling continuous transfer.

I enabled adc-interrupts and rewriting the start address of the array into ADC10SA before restarting the sequence.

It works, but it's not as squeaky clean as i had hoped it would be with the DTC and continuous mode. 

So if anyone has seen this before or can point me in the right direction, i'd appreciate it. Even if it's just someone telling me that it's to be expected :)

Or maybe it'll help someone who stumbles upon this post :)

some code:

working:

void Main(void) {

	ADC10AE0 = BIT0;
	ADC10CTL1 = INCH_11 | ADC10SSEL_3 | CONSEQ_1 | ADC10IE;
	ADC10CTL0 = SREF_1 | REFON | REF2_5V | ADC10SHT_1 | MSC | ADC10ON | ADC10IE;
	ADC10DTC1 = 12;

	__enable_interrupt();
	while(1){
		ADC10CTL0 &= ~ENC;
		while(ADC10CTL1 & ADC10BUSY);
		ADC10SA = (unsigned int)adcdata;
		ADC10CTL0 |= ADC10SC | ENC;
		LPM0;
	}

}

#pragma vector=ADC10_VECTOR
__interrupt void ADC_ISR(void) {
	LPM4_EXIT;
}

not working:

int main(void) {

	ADC10AE0 = BIT0;
	ADC10CTL1 = INCH_11 | ADC10SSEL_3 | CONSEQ_3 | ADC10IE;
	ADC10CTL0 = SREF_1 | REFON | REF2_5V | ADC10SHT_1 | MSC | ADC10ON | ADC10IE;
	ADC10DTC0 = ADC10CT;
	ADC10DTC1 = 12;
	ADC10SA = (unsigned int)adcdata;
	ADC10CTL0 |= ADC10SC | ENC;

	__enable_interrupt();
	while(1){
	}

}


Viewing all articles
Browse latest Browse all 21927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>