#include <msp430x14x.h>
#define uchar unsigned char
#define uint unsigned int
uint temp,temp1;
long start, end, time ;
void delay(void)
{
uint f=500;
while(f--);
}
void delayms(int ms)
{
while(ms--)
{
int i=0;
for(i=0;i<=1600;i++);
}
}
void init(void)
{ uint i;
// P1DIR =0XFF;P1OUT =0XFF;
P2DIR =0XFF;P2OUT =0XF0;
P3DIR =0XFF;P3OUT =0XFF;
P4DIR =0XFF;P4OUT =0XFF;
P5DIR =0XFF;P5OUT =0XFF;
P6DIR =0XFF;P6OUT =0XFF;
P1DIR &=~BIT5;//P1IE = BIT5;
// P1IES=BIT5; P1IFG =0X00;
P1DIR &=~BIT2 ;P1SEL =BIT2;
_EINT();
BCSCTL1 &=~XT2OFF;
BCSCTL2 |= SELM1+DIVM_3;
TACTL=TASSEL_2+TACLR+MC_1 ; //timera_clk=Mclk=1MHz、连续计数模式、1分频
CCTL1=CM_3+SCS+CCIS_0+CAP+CCIE;
do
{
IFG1 &=~OFIFG;
for(i=0xFF;i>0;i--);
}
while ((IFG1 & OFIFG)!=0);
temp = temp1 = 0 ;
start = end = time =0 ;
}
void main(void)
{
WDTCTL =WDTPW+WDTHOLD ;
init();
uint i=0,j=0;
while(1)
{
delayms(5);
CCTL1 |=CCIE;
}
}
/********************Timer_A中断服务程序*************************/
#pragma vector = TIMERA1_VECTOR
__interrupt void Timer_A (void)
{
CCTL1 &=~CCIE;// TACTL |= MC_0;
P2OUT ^=0xff;
} |