Hi,
I'm reading the ADC12 value at MEM2 but the value is not stable. Anyone can help me or which code is more suitable? I measure the input voltage for the A2 is very stable.
What is the main reason causing unstable value? It varies from 0x0092 to 0x00ED. It is very hard to determine the value of the ADC.
Below is my code modified from sample code. I'm using internal reference 2.5V
#include "msp430x54xA.h"
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL = BIT2; // Enable A/D channel A0
/* Initialize REF module */
// Enable 2.5V shared reference, disable temperature sensor to save power
REFCTL0 |= REFMSTR+REFVSEL_2+REFON+REFTCOFF;
/* Initialize ADC12 */
ADC12CTL0 = ADC12ON+ADC12SHT02; // Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP+ADC12CSTARTADD_2; // Use sampling timer
ADC12MCTL2 = ADC12SREF_1 + ADC12INCH_2; // Vr+=Vref+ and Vr-=AVss
__delay_cycles(75); // 75 us delay @ ~1MHz
ADC12CTL0 |= ADC12ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while ((!(ADC12IFG & BIT2)) ;
__no_operation(); // SET BREAKPOINT HERE
}
}
Thanks