想实现的功能就是在A0通道提取模拟信号并将ADC12MEMO的数据存到数组中,可是ADC12MEM0里面i就是不没有数据。求大神帮忙看看哪里出错了、我是新手。#include <msp430.h>
#define Num_of_Results 1000
unsigned int results[Num_of_Results] = {0x00};
void ADC_Init(void);
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Disable the Watchdog.
ADC_Init(); // Initialize ADC12
ADC12CTL0 |= ADC12ENC;
_EINT();
while(1)
{
ADC12CTL0 |= ADC12SC ; // Start conversion
}
}
void ADC_Init(void)
{
P1DIR |= BIT0; // set port to outputs
P1DIR |= BIT3; // reset port outputs
P6SEL |= 0x01; // select A0 input
ADC12CTL0 |= ADC12ON+ADC12SHT0_1+ADC12REF2_5V+ADC12REFON; // Setup ADC12
ADC12CTL1 = ADC12SHP+ADC12CONSEQ_2+ADC12SHS_1; // Timer triggers sampling
ADC12MCTL0 = ADC12INCH_0 + ADC12SREF_1;
ADC12IE = 0x0001; // Enable ADC12IFG.0
P1SEL |= BIT2; // Set for Timer A1
P1DIR |= BIT2;
TA0CCR0 =15; // Init TACCR0 w/ sample prd=CCR0+1
TA0CCR1 = 5; // Trig for ADC12 sample & convert
TA0CCTL1 = OUTMOD_3; // Set/reset
TA0CTL = TACLR | MC_1 | TASSEL_1; // ACLK, clear TAR, up mode
}
// ADC12 Interrupt Service Routine
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
static unsigned int index = 0;
P1OUT ^= 0x01;
P1OUT ^= BIT3;
results[index] = ADC12MEM0; // Move results
index = (index+1)%Num_of_Results ;
if (index == Num_of_Results)
{
index = 0;
}
}
|