|
#include <MSP430x24x.h>
void InitSys();
void InitBhTimerB();
unsigned int Cyc,LastTBCCR0;
void main()
{
WDTCTL = WDTPW + WDTHOLD;
InitSys();
LPM3;
}
void InitSys()
{
unsigned int iq0;
BCSCTL1&=~XT2OFF;
do
{
IFG1 &= ~OFIFG;
for (iq0 = 0xFF; iq0 > 0; iq0--);
}
while ((IFG1 & OFIFG) != 0);
BCSCTL2 =SELM_2+SELS;
InitBhTimerB();
_EINT();
}
void InitBhTimerB()
{
TBCTL = TBSSEL_1+TBCLR;
TBCCTL0 = CCIS_0+CM_2+SCS+CAP;
P3SEL|=BIT1;
TBCTL+=MC_2;
TBCCTL0 |=CCIE;
}
#pragma vector=TIMERB0_VECTOR
__interrupt void TimerB0(void)
{
Cyc=TBCCR0-LastTBCCR0;
LastTBCCR0=TBCCR0;
}
unsigned int GetCyc()
{
return Cyc;
}
想用这个程序测周期,运行后可以计数,但中断就是进不去! 请各位高手帮帮忙!谢谢
|
|