#include<msp430g2553.h>
unsigned int cap_TAR=0;
unsigned int puls_num;
unsigned int Freq;
void main()
{
WDTCTL = WDTPW + WDTHOLD;
P2DIR&=~BIT2;
P2SEL|=BIT2;
P1DIR|=BIT0;
TA0CTL=TASSEL_2+ID_3+MC_2+TAIE;
TA1CCTL0=CAP+CM_1+CCIE+CCIS_0+SCS;
TA0CCR0=2097;
_BIS_SR(LPM0_bits + GIE);
}
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TA1_PLV(void)
{
cap_TAR++;
}
#pragma vector=TIMER0_A1_VECTOR
__interrupt void TA0_PLV1(void)
{
switch(TAIV)
{
case 2:break;
case 4:break;
case 10:{
if(cap_TAR==0)
{
puls_num=0;
}
else
{
puls_num=cap_TAR-1;
}
Freq=puls_num*100;
CCR0+=2097;
P1OUT^=BIT0;
TAR=0;
cap_TAR=0;
break;}
}
}
此帖出自
小平头技术问答
一周热门 更多>