#include <msp430g2452.h>
/*
* main.c
*/
uint x;
void initadc()
{
P1SEL|=BIT4;//通道4
P1DIR |=BIT4;
ADC10CTL0&=~(ENC);
ADC10CTL0=REFON+REF2_5V+ADC10IE+ADC10ON+ADC10SHT_0;// 打开内部参考电压发生器 参考电压选择2.5V 开启AD功能
ADC10CTL1|= INCH_4 + CONSEQ_0; // 采样触发源选择ADC10SC 输入通道A4 单通道单次转换
//ADC10CTL0&=~ADC10IFG;
ADC10AE0 |= BIT4;
}
void main(void) {
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation */
initadc();
ADC10CTL0|=ADC10SC+ENC;//开始采样
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
x=ADC10MEM;
}
中断进不去啊…… |