MSP430 fr2110 进行序列通道采集问题
我设置了A5通道与A1通道,通道选择了A5
在进入调试,按F8,数值都是正确的。
再次按F8,并且手按住温度传感器,数值却没有任何变化。手松开也是一样
然而,我采用单通道采集A5或者A1,怎么按F8,数值都变化一次
求大佬解答
附上代码
#include <msp430.h>
float ADC_Result[6]={0}; // 8-bit ADC conversion result array
int i = 5;
float temp_1;
float temp_2;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure ADC A0~2 pins
P1SEL0 |= BIT0 + BIT1 + BIT2 + BIT5;
P1SEL1 |= BIT0 + BIT1 + BIT2 + BIT5;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
// Configure ADC
ADCCTL0 |= ADCSHT_5 | ADCMSC | ADCON; // 16ADCclks, MSC, ADC ON
ADCCTL1 |= ADCSHP | ADCCONSEQ_1 | ADCSSEL_1; // ADC clock ACLK, sampling timer, s/w trig.,single sequence
ADCCTL2 |= ADCRES_1; // 8-bit conversion results
ADCMCTL0 |= ADCINCH_5 | ADCSREF_0; // A0~2(EoS); Vref=1.5V
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
__delay_cycles(400); // Delay for reference settling
__no_operation();
while(1)
{
while(ADCCTL1 & ADCBUSY); // Wait if ADC core is active
ADCCTL0 |= ADCENC | ADCSC; // Sampling and conversion start
__bis_SR_register(LPM0_bits | GIE); // Enter LPM0 w/ interrupts
__no_operation(); // Only for debug
temp_1 = ADC_Result[1] * 33/10/1024*1000 ;
temp_2 = ADC_Result[5] * 33/10/1024*1000;
__delay_cycles(5000);
__no_operation();
}
}
// ADC interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(ADC_VECTOR))) ADC_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(ADCIV,ADCIV_ADCIFG))
{
case ADCIV_NONE:
break;
case ADCIV_ADCOVIFG:
break;
case ADCIV_ADCTOVIFG:
break;
case ADCIV_ADCHIIFG:
break;
case ADCIV_ADCLOIFG:
break;
case ADCIV_ADCINIFG:
break;
case ADCIV_ADCIFG:
ADC_Result[i] = ADCMEM0;
if(i == 0)
{
ADCCTL0 &= ~ADCENC;
i = 5;
__bic_SR_register_on_exit(LPM0_bits); // Exist LPM0
}
else
{
i--;
}
break;
default:
break;
}
}
此帖出自
小平头技术问答
一周热门 更多>