|
程序跑到while判断采样是否完成就不跑了,是哪的问题,还有就是对各寄存器的用法还是不太清楚,求指点。
#include
void ADC12_init(void);
unsigned int voltag=0;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
unsigned int temp=0;
P2DIR|=BIT0;
P2OUT&=~BIT0;
void ADC12_init();
P2DIR|=BIT0;
P2OUT|=BIT0;
ADC12CTL0|=ADC12SC;
while((ADC12IFG&BIT0)==0);
temp=ADC12MEM0;
voltag=temp/4096*2.5;
while(1);
}
void ADC12_init(void)
{
ADC12CTL0&=~ADC12ENC;
P6SEL|=BIT4;
ADC12CTL0 |= ADC12ON+ADC12MSC+ADC12REFON+ADC12REF2_5V;
ADC12CTL1 |= ADC12CONSEQ_2+ADC12SSEL_3+ADC12DIV_3+ADC12SHP;
ADC12MCTL0|=ADC12INCH_4+ADC12SREF_1;
ADC12CTL0 |= ADC12ENC;
}
|
|