#include "msp430g2553.h"
void Timer0A0Init();
unsigned int temp[3];
unsigned int overflow;
unsigned int m,i;
unsigned int p,q;
void main()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WTD
Timer0A0Init();
_enable_interrupts(); //使能总中断
_bis_SR_register(LPM3_bits); //LPM3方式休眠
while(1);
}
void Timer0A0Init()//定时器timer0的初始化程序
{
P1DIR &= ~BIT4;
P1SEL |= BIT4;
TACTL |= TASSEL_1 + MC_2 + TACLR + TAIE; //时钟源:ACLK;连续模式;清除; TAIE溢出中断
TACCTL0 |= CM_3 + CAP + SCS +CCIS_0 ;
q=1;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TA0_ISR(void)
{
switch(TAIV)
{
case 2: //是捕获中断 2为CCR1捕获中断向量值
p=1;
temp[i++]=TACCR0;
if(i==3)
{
i=0;
m=360*(temp[1]-temp[0])/(temp[2]-temp[0]);
}
break;
case 14: //是溢出中断
overflow++; //溢出次数自加1
break;
default: break;
}
P1IFG=0;
}
单步调试,或者全速运行都进不去中断,请问是哪里写的不对吗?这是个捕获然后计算脉宽的。。 |