因仑“3+1”工程特种兵精英论坛

标题: msp430f149控制超声波模块的程序 [打印本页]

作者: 曾经最美    时间: 2016-4-21 22:31
标题: msp430f149控制超声波模块的程序
#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;
}






欢迎光临 因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) Powered by Discuz! X3.4