CT107D_测试程序3.docxVIP

  • 8
  • 0
  • 约6.3千字
  • 约 10页
  • 2016-12-29 发布于重庆
  • 举报
超声波测距定时器2捕获超声波测距外部中断捕获温度显示 DS18B20超声波测距定时器2捕获#include reg52.h //包括一个52标准内核的头文件#define BYTE unsigned char #define uint unsigned int#define ulong unsigned longsbit LS138A=P2^5;sbit LS138B=P2^6;sbit LS138C=P2^7;BYTE code disp_duan[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//数码管0-9BYTE code disp_wei[]={0x01,0x02,0x04,0x08};BYTE ledout[4],flag,i=0;bit succeed_flag; //测量成功标志ulong distance_data,sum;ulong distance_data_buff[2];void sys_ini(){ LS138C=1;LS138B=0;LS138A=1;P0=0; //关蜂鸣器T2=0; //首先拉低脉冲输入引脚TMOD=0x01; //定时器0,16位工作方式TR0=1; //启动定时器0ET0=1; //打开定时器溢出0中断 ET2=1;

文档评论(0)

1亿VIP精品文档

相关文档