//调整A0口电阻虽然对应ad值会变,但是其他口的数值也会随之改变,只是幅度没有A0口大而已
void adc_init(void)
{
P6SEL |= BIT0;
P6SEL |= BIT1;
P6SEL |= BIT2;
P6SEL |= BIT3;
ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_8;//感觉这个配置不好
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3;//感觉这个配置也不好
ADC12MCTL0 = ADC12INCH_0; // A0
ADC12MCTL1 = ADC12INCH_1; // A1
ADC12MCTL2 = ADC12INCH_2; // A2
ADC12MCTL3 = ADC12INCH_3+ADC12EOS; // A3
ADC12IE = 0x08; /
ADC12CTL0 |= ADC12ENC;
ADC12CTL0 |= ADC12SC;
}
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
results[0] = ADC12MEM0; // 保存A0值
results[1] = ADC12MEM1; // 保存A1值
results[2] = ADC12MEM2; // 保存A2值
results[3] = ADC12MEM3; // 保存A3值
}
此帖出自
小平头技术问答
一周热门 更多>