我用ADC10的多通道采样模式采样信号,但是采样的结果都是0。看了一宿了,很累,但是在线等。先谢谢大家,帮帮忙,附上相关程序。
float adc_temp[8];
float IntDegu;
float IntDegi;
unsigned int IntDeg1;
unsigned int IntDeg2;
void GPIO_Init()
{
P2SEL&=~(BIT6+BIT7);
// P1SEL |= BIT1+BIT0;
// P1DIR &= ~(BIT1+BIT0);
P1REN |= BIT3;
P1IE |= BIT3;
P1IES |= BIT3;
P1IFG &= 0x00;
}
void ADC10_init(void)
{
ADC10CTL0&=~ENC;
ADC10CTL1=CONSEQ_1+INCH_1;
ADC10CTL0=SREF_0+MSC+ADC10ON+ADC10IE;
ADC10DTC1=0x02;
ADC10AE0|=BIT0+BIT1;
__delay_cycles(300000);
ADC10CTL0&=~ADC10IFG;
ADC10CTL0|=ENC;
}
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR_HOOK(void)
{
__bic_SR_register_on_exit(CPUOFF);
IntDegu=14*11/(3*7)-3*adc_temp[1]/(3*1023);
IntDegi=3/20-3*adc_temp[0]/(10230);
IntDeg1=IntDegu/IntDegi;
IntDeg2=23.3;
DisplayRes();
ADC10CTL0&=~ENC;
}
void main( void )
{
WDTCTL = WDTPW+WDTHOLD;
BCSCTL1 = CALBC1_12MHZ; //设定cpu时钟DCO频率为12MHz
DCOCTL = CALDCO_12MHZ;
GPIO_Init();
LcdReset();
Lcd_Init();
ADC10_init();
while(1)
{
while(ADC10CTL1&BUSY);
ADC10SA=(unsigned int)(adc_temp);
ADC10CTL0|=ENC+ADC10SC;
_BIS_SR(LPM0_bits+GIE);
ADC10CTL0&=~ENC;
}
}
YIHONG LIU:
自顶,大神们,帮帮我,还在等
灰小子:
回复 YIHONG LIU:
可以参考下这个例程:http://www.deyisupport.com/question_answer/microcontrollers/msp430/f/55/t/84726.aspx
Hardy Hu:
你好!
建议先下载MSPWARE,下载地址:http://www.ti.com/tool/MSPWARE
然后打开对应芯片的ADC例程,里面有一个是直接采内部温度传感器的,能够直接读出数值。
希望能够帮到你!