zhoupan9109 发表于 2013-8-22 09:54:28

msp430f149控制超声波模块的程序

跪求大神指导控制hc-sr04的程序

zhoupan9109 发表于 2013-8-22 09:56:33

#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;
}
我的代码,求指导,哪里出问题了
页: [1]
查看完整版本: msp430f149控制超声波模块的程序