登录注册
表妹酱 发表于 2015-5-7 16:20 void ADC12() { P6SEL = 0x0F; // Enable A/D channel inputs ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_15; // Turn on ADC12, extend sampling time // to avoid overflow of results ADC12CTL1 = ADC12SHP+ADC12CONSEQ_3; // Use sampling timer, repeated sequence ADC12MCTL0 = ADC12INCH_0; // ref+=AVcc, channel = A0 ADC12MCTL1 = ADC12INCH_1+ADC12EOS; // ref+=AVcc, channel = A1 //ADC12MCTL2 = ADC12INCH_2+ADC12EOS; // ref+=AVcc, channel = A2 //ADC12MCTL3 = ADC12INCH_3+ADC12EOS; // ref+=AVcc, channel = A3, end seq. ADC12IE = 0x02; // Enable ADC12IFG.2 ADC12CTL0 |= ADC12ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start convn - software trigger } #pragma vector=ADC12_VECTOR __interrupt void ADC12ISR(void) { static unsigned int index = 0; u16 c; switch(__even_in_range(ADC12IV,34)) { case 0: break; // Vector 0: No interrupt case 2: break; // Vector 2: ADC overflow case 4: break; // Vector 4: ADC timing overflow case 6: break; // Vector 6: ADC12IFG0 case 10: break; // Vector 8: ADC12IFG2 case 12: break; // Vector 10: ADC12IFG3 case 8: // Vector 12: ADC12IFG1 A0results = ADC12MEM0; // Move A0 results, IFG is cleared A1results = ADC12MEM1; // Move A1 results, IFG is cleared ... case 14: break; // Vector 14: ADC12IFG4 case 16: break; // Vector 16: ADC12IFG5 case 18: break; // Vector 18: ADC12IFG6 case 20: break; // Vector 20: ADC12IFG7 case 22: break; // Vector 22: ADC12IFG8 case 24: break; // Vector 24: ADC12IFG9 case 26: break; // Vector 26: ADC12IFG10 case 28: break; // Vector 28: ADC12IFG11 case 30: break; // Vector 30: ADC12IFG12 case 32: break; // Vector 32: ADC12IFG13 case 34: break; // Vector 34: ADC12IFG14 default: break; } }
表妹酱 发表于 2015-5-7 15:02 中断向量指向错误了把,你只用了ad0和ad1,应该进ifg1
惠美丽
吴世勋
< 1/1 >
已有2人来访过
留言
现在还没有留言