P6SEL |= 0xFF; // Enable A/D channel A0
P6DIR &= 0x00;
REFCTL0 |= REFMSTR + REFVSEL_2 + REFON;
/* Initialize ADC12_A */
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_15; // Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1; // Use sampling timer, single sequence
ADC12MCTL0 = ADC12SREF_1+ADC12INCH_0; // ref+=AVcc, channel = A0
ADC12MCTL1 = ADC12SREF_1+ADC12INCH_1; // ref+=AVcc, channel = A1
ADC12MCTL2 = ADC12SREF_1+ADC12INCH_2; // ref+=AVcc, channel = A1
ADC12MCTL3 = ADC12SREF_1+ADC12INCH_3; // ref+=AVcc, channel = A1
ADC12MCTL4 = ADC12SREF_1+ADC12INCH_4; // ref+=AVcc, channel = A1
ADC12MCTL5 = ADC12SREF_1+ADC12INCH_5; // ref+=AVcc, channel = A1
ADC12MCTL6 = ADC12SREF_1+ADC12INCH_6; // ref+=AVcc, channel = A1
ADC12MCTL7 = ADC12SREF_1+ADC12INCH_7+ADC12EOS; // ref+=AVcc, channel = A1
// ADC12IE = 0x80;
ADC12CTL0 |= ADC12ENC; // Enable conversions
此帖出自
小平头技术问答
一周热门 更多>