程序如下所示:
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
//////P6SEL |= 0x40;
//P7DIR |= 0XFE;
// P7SEL |= 0x0c;
P6SEL |= BIT6; // Enable A/D channel A6,P6.6 input anolog voltage
ADC12CTL0 = ADC12ON+ADC12SHT0_2; // Turn on ADC12, set sampling time
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12MCTL0 = ADC12SREF_2+ADC12INCH_6; // Vr+ = VeREF+ (ext) and Vr-=AVss
ADC12CTL0 |= ADC12ENC; // Enable conversions
while(1)
{
ADC12CTL0 |= ADC12SC; // Start conversion-software trigger
while (!(ADC12IFG & BIT0));//while (!(ADC12IFG & BIT0));
ad= ADC12MEM0;
}
}
这个程序单步运行的时候,会有这样的结果输出:
但是一旦全速运行,就会得到极大值的结果4095,请问这是什么原因?该怎样解决?
谢谢!!!
此帖出自
小平头技术问答
一周热门 更多>