#include<msp430f5529.h>
void sysInit()
{
ADC12CTL0 = ADC12SHT02+ADC12REFON + ADC12ON; // Sampling time, ADC12 on
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12IE = BIT6;
ADC12MCTL0=ADC12SREF_1+ADC12INCH_6;// Enable interrupt
__delay_cycles(75);
ADC12CTL0 |= ADC12ENC+ADC12EOS;
P6SEL |= BIT6; // P6.0 ADC option select
P1DIR |= BIT0;
P1OUT &=~BIT0;
}
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
REFCTL0 &= ~REFMSTR;
sysInit();
while(1)
{
ADC12CTL0 |= ADC12SC;
__bis_SR_register(LPM0_bits + GIE);
//__no_operation();
}
}
#pragma vector = ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
switch(__even_in_range(ADC12IV,34))
{
case 0:break;
case 2:break;
case 4:break;
case 6:
if(ADC12MEM0 >= 0x8FF) //大于1.5就亮
P1OUT |= BIT0;
else
P1OUT &=~BIT0;
__bic_SR_register_on_exit(LPM0_bits);
break;
//case 8:break;
default:break;
}
}
问题:为什么我想换一个采集端口比如A0换A6(我改了ADC12IE.P6SEL.ADC12INCH_6)可是为什么不能正常进入中断(进入中断后P1.1灯会亮)
灰小子:
if(ADC12MEM0 >= 0x8FF) //大于1.5就亮
ADC12MEMx也要用对应的