#include <msp430f5529.h>
#include "nokia_5110.h"
//#include "systemclk.h"
unsigned int new_flag=0,old_flag=0;
unsigned char N1=0;
long time,pluse=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
P1DIR &=~BIT3; //TA0输入捕捉端口(P1.2)
P1SEL |= BIT3;
// setclock(8);
TA0CTL = TASSEL_2 + MC_2 + TACLR + TAIE; // ACLK~1MHz, contmode, clear TAR
// enable interrupt
TA0CCTL0 = CM_1+CCIS_0+CAP+SCS+CCIE;
LCD_init();
LCD_ShowFloat(0,1,1000000*pluse/time,1);
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, enable interrupts
__no_operation(); // For debugger
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void TIMER0_A0_ISR(void)
{ if(N1==0)
{ N1++;
old_flag = TA0CCR0;}
else
{ N1++;
new_flag = TA0CCR0;}
}
// Timer0_A5 Interrupt Vector (TAIV) handler
#pragma vector=TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_ISR(void)
{
switch(__even_in_range(TA0IV,14))
{
case 0: break; // No interrupt
case 2: break; // CCR1 not used
case 4: break; // CCR2 not used
case 6: break; // reserved
case 8: break; // reserved
case 10: break; // reserved
case 12: break; // reserved
case 14: if(N1==0)
{ pluse=0;}
else
{ pluse=N1-1;}
time=new_flag-old_flag;
N1=0;
P1OUT ^= 0x01; // overflow
break;
default: break;
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>