查看: 1632|回复: 0
打印 上一主题 下一主题

msp430f149控制超声波模块的程序

[复制链接]
跳转到指定楼层
沙发
发表于 2016-4-21 22:31:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#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;
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入因仑

本版积分规则

快速回复 返回顶部 返回列表