⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text1.c

📁 KA010产品时间测试程式 望大家有用
💻 C
字号:
				  					 			/* -----------------------       版权声明      ---------------------------------- 
  ------------------------------ 创新科技   2007/01/05 --------------------------
 
  --------------  Mobile:13433018379  (陶志学) ---------------------------------- 
  ------       Email:taozhixue123@163.com   --------
  未经东莞市创新科技书面同意, 不得将本程序泄露、公开给第三方。
  不得将本程序(或修改后的程序)使用在非东莞市创新科技销售的产品上。
  客户产品上使用本程序时,客户产品的源程序中必须注明使用了东莞市创新科技的程序,
  并保留如下内容:

  ------------------------------*/
#include <REG51.H>
#include <stdio.h>
#define uchar unsigned char
#define uint  unsigned int 

 unsigned int a; 
unsigned char ceshi1,ceshi2,ceshi3,ceshi4;


uint  jishu;  
uint  jishu_a;  
uint  jishu_b; 
uint  jishu_c; 
uint  jishu_d1; 
uint  jishu_d2; 




unsigned int  count_down;      //1秒钟计时用 
sbit M_green = P0^7; 
sbit A_green = P0^6;   
sbit B_green = P0^5;   
sbit C_green = P0^4; 
sbit D_green = P0^3; 

sbit M_red = P2^7; 
sbit A_red = P2^6;   
sbit B_red = P2^5;   
sbit C_red = P2^4; 
sbit D_red = P2^3; 


sbit M1 = P1^4; 
sbit M2 = P1^3;   
sbit M_B = P3^5; 
sbit M_A = P3^2;  
sbit M_AB = P1^0; 

sbit T_1 = P1^7;   
sbit T_2 = P1^6; 
sbit T_3 = P1^5; 









void Delay1ms(unsigned int count)		//延迟函数,参数为毫秒数
{unsigned int i,j;
  for(i=0;i<count;i++)
    for(j=0;j<240;j++)	  ; 
 }
void send_char(unsigned char txd)
// 传送一个字符
{
	SBUF = txd;
	while(!TI);				// 等特数据传送
	TI = 0;					// 清除数据传送标志
}





void Timer1ISR(void) interrupt 1 using 3	//定时器1中断,用于按键扫描
{

  TH0=0xCB; TL0=0xEA;      // 

  jishu++;


}


void main(void)
{
  P0=0XFF;
  P1=0XFF;
  P2=0XFF;
  P3=0XFF;
  Delay1ms(100);
  count_down=8000;
  jishu=0;

  


	TMOD = 0x21;			// 定时器1工作于8位自动重载模式, 用于产生波特率
	SCON = 0x40;			// 设定串行口工作方式
	PCON &= 0xef;			// 波特率不倍增
	TH1 = 0xF7;				// 波特率9600
	TL1 = 0xF7;

	TH0=0xCB;
	TL0=0xEA;
	TR0= 0;	 
    TR1= 1;				// 启动定时器1
	
	ET0=1;
 	 EA=1; 

 



 T_1=1;		//a
 T_2=0;
 T_3=0;

 while( M_A==1	 );	
  TR0=1;
  Delay1ms(100);
 
 while( M_A==0	 )A_red=0;


    TR0=0;
 jishu_a=jishu;
 A_green=0;
 jishu=0;


 T_1=1;		//b
 T_2=1;
 T_3=0;
 while( M_B==1);
  TR0=1;
  Delay1ms(100);
 while( M_B==0	 ) B_red=0;
    TR0=0;
 jishu_b=jishu;
 B_green=0;
 jishu=0;

	   
 T_1=0;		//c
 T_2=0;
 T_3=1;
 while( M_A==1);
 TR0=1;
 Delay1ms(100);
 while( M_A==0	 ) C_red=0;
  TR0=0;
 jishu_c=jishu;
 C_green=0;
 jishu=0;

	   
 T_1=1;		//d
 T_2=0;
 T_3=1;

  while( M_A==1);
  TR0=1;
  Delay1ms(100);
 while( M_A==0	 ) D_red=0;
    TR0=0;
 jishu_d1=jishu;
 jishu=0;

 while( M_B==1);
  TR0=1;
  Delay1ms(100);
 while( M_B==0	 ) D_red=0;
    TR0=0;
 jishu_d2=jishu;
 D_green=0;
 jishu=0;
  EA=0;  
 while(1)
 {

  a=jishu_a;
  ceshi1=a/1000;
  ceshi2= (a-=ceshi1*1000)/100;
  ceshi3= (a-=ceshi2*100)/10;
  ceshi4= a-=ceshi3*10;
    Delay1ms(10);
 send_char(ceshi1);
   Delay1ms(10);
 send_char(ceshi2);
  Delay1ms(10);
 send_char(ceshi3);
  Delay1ms(10);
 send_char(ceshi4);
  Delay1ms(10);
  a=jishu_b;
  ceshi1=a/1000;
  ceshi2= (a-=ceshi1*1000)/100;
  ceshi3= (a-=ceshi2*100)/10;
  ceshi4= a-=ceshi3*10;
    Delay1ms(10);
 send_char(ceshi1);
   Delay1ms(10);
 send_char(ceshi2);
  Delay1ms(10);
 send_char(ceshi3);
  Delay1ms(10);
 send_char(ceshi4);
  Delay1ms(10);
  a=jishu_c;
  ceshi1=a/1000;
  ceshi2= (a-=ceshi1*1000)/100;
  ceshi3= (a-=ceshi2*100)/10;
  ceshi4= a-=ceshi3*10;
    Delay1ms(10);
 send_char(ceshi1);
   Delay1ms(10);
 send_char(ceshi2);
  Delay1ms(10);
 send_char(ceshi3);
  Delay1ms(10);
 send_char(ceshi4);
  Delay1ms(10);

   a=jishu_d1;
  ceshi1=a/1000;
  ceshi2= (a-=ceshi1*1000)/100;
  ceshi3= (a-=ceshi2*100)/10;
  ceshi4= a-=ceshi3*10;
    Delay1ms(10);
 send_char(ceshi1);
   Delay1ms(10);
 send_char(ceshi2);
  Delay1ms(10);
 send_char(ceshi3);
  Delay1ms(10);
 send_char(ceshi4);
  Delay1ms(10);

   a=jishu_d2;
  ceshi1=a/1000;
  ceshi2= (a-=ceshi1*1000)/100;
  ceshi3= (a-=ceshi2*100)/10;
  ceshi4= a-=ceshi3*10;
    Delay1ms(10);
 send_char(ceshi1);
   Delay1ms(10);
 send_char(ceshi2);
  Delay1ms(10);
 send_char(ceshi3);
  Delay1ms(10);
 send_char(ceshi4);
  Delay1ms(10);

 Delay1ms(10000);
 }



}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -