为什么用定时器A做触发源时,无法进入ADC的中断呢?
#include<msp430x14x.h>
#define M 4
static unsigned int index = 0 ;
unsigned int results[M];
void ADC12_Init ( void ) ;
void UART_Init ( void );
void main()
{
WDTCTL = WDTPW + WDTHOLD;
UART_Init();
ADC12_Init();
_EINT();
while(1)
{
ADC12CTL0 |= ADC12SC;
LPM0;
}
}
void ADC12_Init ( void )
{
P6SEL = 0x0f;
P6DIR |= BIT7 + BIT6;
P6OUT &= ~(BIT7 + BIT6);
P2SEL |= BIT3;
P2DIR |= 0x08;//0000 0100
// CCR0 = 7;
CCR1 = 0x0fff;
TACCTL0 = OUTMOD_3;
TACTL = TASSEL_2 + MC_2 + TACLR + TAIE;
ADC12CTL0 |= SHT0_2 + ADC12ON + MSC;
ADC12CTL1 |= SHP + CONSEQ_1 + ADC12SSEL_3 + SHS_1;
ADC12MCTL0 |= INCH_0;
ADC12MCTL1 |= INCH_1;
ADC12MCTL2 |= INCH_2;
ADC12MCTL3 |= INCH_3 + EOS;
ADC12IE |= 0x08;
ADC12CTL0 |= ENC;
}
void UART_Init ( void )
{
P3SEL |= BIT4 + BIT5;
ME1 |= URXE0 + UTXE0;
UCTL0 |= CHAR;
UTCTL0 |= SSEL0;
UBR00 = 0x03;
UBR10 = 0x00;
UMCTL0 = 0x4a;
UCTL0 &= ~SWRST;
// IE1 |= UTXIE0;
}
#pragma vector = ADC_VECTOR
__interrupt void adc(void)
{
P6OUT ^= BIT7;
// _NOP();
results[0] = ADC12MEM0;
results[1] = ADC12MEM1;
results[2] = ADC12MEM2;
results[3] = ADC12MEM3;
// while(!(IFG1&UTXIFG0));
TXBUF0 = results[index]/16;
index = (index + 1) % M;
ADC12CTL0 &= ~ENC;
LPM0_EXIT;
}
#pragma vector = TIMERA1_VECTOR
__interrupt void timer(void)
{
switch(TAIV)
{
case 2:break;
case 4:break;
case 10:P6OUT ^= BIT6;_NOP();break;
}
}
此帖出自
小平头技术问答
一周热门 更多>