我的寄存器设置都在图上 请TI的工程师麻烦给我看看呢
如我有描述的不清楚 请留个言 谢谢啦
Xutong Han2:
看你的程序在AD通道设置上 ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0 ADC12MCTL1 = INCH_1+EOS; // ref+=AVcc, channel = A1, end seq. ADC12IE = 0x02; // Enable ADC12IFG.1
ADC的中断向量 #pragma vector=ADC12_VECTOR
试试这样可以进入中断吗?
size hu:
回复 Xutong Han2:
额 我昨天晚上调出来了刚开始是总中断没开后来加了_BIS_SR(LOM0+GIE);不能进入中断后改成_ENIT();才进入中断这两个有么区别
SurfaceBook:
回复 size hu:
_BIS_SR(LOM0+GIE);跟_ENIT();区别是肯定有的,ENIT仅仅是开启中断. _BIS_SR(LOM0+GIE);的意思是LPM0 与中断功能.而且你是不是打错了。
LPM0 的意思是 Enter Low Power Mode 0 ;
size hu:
回复 SurfaceBook:
没打错 怎么ad用BIS_SR(LPM0+GIE);进不了中断
而ENIT可进入
Lina Lian:
size hu,
我看你的程序是采用的Repeated Sequence of Conversions的模式,下面程序是TI关于这种用法的例程,你直接用这个程序跑试试。我看了觉得你的程序没有问题。
int main(void){ WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer P6SEL = 0x0F; // Enable A/D channel inputs ADC12CTL0 = ADC12ON+MSC+SHT0_8; // Turn on ADC12, extend sampling time // to avoid overflow of results ADC12CTL1 = SHP+CONSEQ_3; // Use sampling timer, repeated sequence ADC12MCTL0 = INCH_0; // ref+=AVcc, channel = A0 ADC12MCTL1 = INCH_1; // ref+=AVcc, channel = A1 ADC12MCTL2 = INCH_2; // ref+=AVcc, channel = A2 ADC12MCTL3 = INCH_3+EOS; // ref+=AVcc, channel = A3, end seq. ADC12IE = 0x08; // Enable ADC12IFG.3 ADC12CTL0 |= ENC; // Enable conversions ADC12CTL0 |= ADC12SC; // Start conversion _BIS_SR(LPM0_bits + GIE); // Enter LPM0, Enable interrupts}
#pragma vector=ADC12_VECTOR__interrupt void ADC12ISR (void){ static unsigned int index = 0;
A0results[index] = ADC12MEM0; // Move A0 results, IFG is cleared A1results[index] = ADC12MEM1; // Move A1 results, IFG is cleared A2results[index] = ADC12MEM2; // Move A2 results, IFG is cleared A3results[index] = ADC12MEM3; // Move A3 results, IFG is cleared index = (index+1)%Num_of_Results; // Increment results index, modulo; Set Breakpoint here}
size hu:
回复 Lina Lian:
这个问题解决了 我刚开始用的是TI的程序直接用也有WORNing前面设置的A0results[] A1results[] A2results[] A3results[]没被定义 我把_BIS_SR(LPM0+GIE);改成_ENIT();了就好了
user5767411:
回复 Lina Lian:
请问,为什么我用您给的程序进行在线调试的时候,在Register栏中查看MEM0,MEM1,MEM2,MEM3都是0000,这说明AD没有采样成功而且采样的值也没有写入MEMX寄存器吗?我该怎么解决,求告知,谢谢!!