#include <msp430x54x.h>
#include "LCD_12864.h"
#include "CLOCK.h"
unsigned int start,end;
unsigned char overflow,flag;
unsigned long gao,di;
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
InitSysCLKXT2();
INI_LCD();
P2SEL|=BIT2;
flag=0;
TA1CTL=TAIE+TASSEL__SMCLK+TACLR+MC__UP;//选择计时器时钟为SMCLK打 分频比为1 UP增模式
TA1CCTL1=CCIE+CAP+CM0+SCS;//打开中断 打开捕获 上升沿捕获 同步捕获
TA1CCR0=60000;
__bis_SR_register(GIE);
while(1)
{
}
}
#pragma vector=TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR(void)
{
switch(__even_in_range(TA1IV,14))
{
case 0: break; // No interrupt
case 2: // Add Offset to CCR1
{
if(TA1CCTL1&CM0)
{
start=TA1CCR1;
TA1CCTL1=(TA1CCTL1&(~CM0))|CM1; //改为下降沿触发
start=TA1CCR1;
gao=overflow*60000+start;
overflow=0;
}
else if(TA1CCTL1&CM1)
{
TA1CCTL1=(TA1CCTL1&(~CM1))|CM0;
end=TA1CCR1;
di=overflow*60000+end;
}
}
break;
case 4: break; // CCR2 not used
case 6: break; // CCR3 not used
case 8: break; // CCR4 not used
case 10: break; // CCR5 not used
case 12: break; // Reserved not used
case 14: // 溢出数加1
overflow++;
break;
default: break;
}
}
高电平时间在gao,低电平时间在di,仿真发现这两个数一直在加,很是不懂!求解释,告诉我怎么给分,然后100多分全给你!
此帖出自
小平头技术问答
一周热门 更多>