硬件出什么问题会使msp430f149在ad采样时失败(无法进入中断),我用的TI给的ad采样的例程,编译时会出现results(results是中断中的变量)定义但没有使用的警告,在线调试时应该是无法进入中断,在register栏中MEM0,MEM1,MEM2,MEM3的值都为零,求会的朋友帮忙,谢谢了!!ad转换的值没有写进去如下图
程序如下
#include <msp430.h>
static unsigned int results[4]; // Needs to be global in this example
// Otherwise, the compiler removes it
// because it is not used for anything.
int main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P6SEL = 0x0F; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON+MSC+SHT0_2; // Turn on ADC12, set sampling time
ADC12CTL1 = SHP+CONSEQ_1; // Use sampling timer, single 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
while(1)
{
ADC12CTL0 |= ADC12SC; // Start conversion
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, Enable interrupts
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC12_VECTOR))) ADC12ISR (void)
#else
#error Compiler not supported!
#endif
{ results[0] = ADC12MEM0; // Move results, IFG is cleared
results[1] = ADC12MEM1; // Move results, IFG is cleared
results[2] = ADC12MEM2; // Move results, IFG is cleared
results[3] = ADC12MEM3; // Move results, IFG is cleared
__bic_SR_register_on_exit(LPM0_bits); // Clear LPM0, SET BREAKPOINT HERE
}
Susan Yang:
请问您是直接使用TI的例程而没有修改?工程编译时会出现什么错误呢?
user5767411:
回复 Susan Yang:
您好,我又直接用TI的例程试了试,编译时有警告说"results" was set but never used ,(换了好几个例程基本都是这个问题) 用的例程是fet140_adc12_09 程序如下
#include <msp430x14x.h>
static unsigned int results[4]; // Needs to be global in this example // Otherwise, the compiler removes it // because it is not used for anything.
void main(void){ WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer P6SEL = 0x0F; // Enable A/D channel inputs ADC12CTL0 = ADC12ON+MSC+SHT0_2; // Turn on ADC12, set sampling time ADC12CTL1 = SHP+CONSEQ_1; // Use sampling timer, single 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
while(1) { ADC12CTL0 |= ADC12SC; // Start conversion _BIS_SR(LPM0_bits + GIE); // Enter LPM0, Enable interrupts }}
#pragma vector=ADC_VECTOR__interrupt void ADC12ISR (void){ results[0] = ADC12MEM0; // Move results, IFG is cleared results[1] = ADC12MEM1; // Move results, IFG is cleared results[2] = ADC12MEM2; // Move results, IFG is cleared results[3] = ADC12MEM3; // Move results, IFG is cleared _BIC_SR_IRQ(LPM0_bits); // Clear LPM0, SET BREAKPOINT HERE}
user5767411:
回复 Susan Yang:
对了,还有就是例程上虽然用到p6.0端口了,但我的p6.0端口是没有接东西的,用的 P6.1 和 P6.2 ,不过即使这样,正常情况下用这个例程 P6.1 和 P6.2 应该也是能够采集到电压的吧,但是MEM0,MEM1,MEM2,MEM3这几个寄存器的值都是0,还有编译时出现result虽然定义但没有使用的警告,由于这个result变量是在中断函数中使用的,这里说没有使用,是不是编译时根本就没有进入中断,但是我原封不动用的TI给的例程也是这么警告,研究了好久了没弄明白,如果您看出来问题所在希望您告知一下,麻烦您了,谢谢
灰小子:
回复 user5767411:
建议把编译过程出现的详细的console和log信息贴出来
user5767411:
回复 灰小子:
谢谢,已经解决了,是虚焊的问题,没有接到邮箱通知回复晚了,不好意思