int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0x04; // Enable A/D channel A2
REFCTL0 &= ~REFMSTR; // Reset REFMSTR to hand over control to
// ADC12_A ref control registers
ADC12CTL0 = ADC12ON+ADC12SHT0_8+ADC12REFON+ADC12REF2_5V;
// Turn on ADC12, Sampling time
// On Reference Generator and set to
// 2.5V
ADC12CTL1 = ADC12CSTARTADD_1+ADC12SHP; // Use sampling timer,,用ADC12MEM1存储结果
ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_2; // Vr+=Vref+ and Vr-=AVss,,,选择通道2
for ( i=0; i<0x30; i++); // Delay for reference start-up
ADC12CTL0 |= ADC12ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while (!(ADC12IFG & BIT0));
__no_operation(); // SET BREAKPOINT HERE
int main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL |= 0x01; // Enable A/D channel A0
REFCTL0 &= ~REFMSTR; // Reset REFMSTR to hand over control to
// ADC12_A ref control registers
ADC12CTL0 = ADC12ON+ADC12SHT02+ADC12REFON+ADC12REF2_5V;
// Turn on ADC12, Sampling time
// On Reference Generator and set to
// 2.5V
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12MCTL0 = ADC12SREF_1; // Vr+=Vref+ and Vr-=AVss
for ( i=0; i<0x30; i++); // Delay for reference start-up
ADC12CTL0 |= ADC12ENC; // Enable conversions
while (1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
while (!(ADC12IFG & BIT0));
__no_operation(); // SET BREAKPOINT HERE