#include<msp430x14x.h>
#include"DELAY.h"
#define uint unsigned int
#define uchar unsigned char
void main()
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR=0x00;
P1IES=0x00;
P1OUT=0X00;
_EINT();
P2DIR=0xff;
P2OUT=0xff;
uint time=0;
P6DIR=0xff;
P6OUT=0x00;
while(1)
{
P1IE=0xff;
P6OUT=0xff;
DELAY_us(1);
P6OUT=0x00;
// while(P1IFG==0x00);
while(TBR==0);
if(P1IN==0x00)
time=TBR;
if(time>50)
P2OUT=0xff;
if(time<50)
P2OUT=0x00;
}
}
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_(void)
{
P1IFG=0x00;
TBCTL=TBSSEL_2+ID_3+MC_1;
TBCCR0=65535;
TBR=0;
//P2OUT=0x00;
P1IE=0x00;
} |
|