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

📄 22.c

📁 一些常用的74系列芯片好壞的檢測程序
💻 C
📖 第 1 页 / 共 2 页
字号:
#include"at89x52.h"
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int


uchar i;
uchar chip=0;

unsigned char code flush[]={
	0xfe,0xfd,0xef,0xdf,0xbf,0x7f
};

//     初始化6位数码管     //     
unsigned char LED[]={
					10,11,17,18,1,13
					};



//    设置显示字符    //
unsigned char code seg[]={
	0x3F,		// 0
	0x06,		// 1
	0x5B,		// 2
	0x4F,		// 3
	0x66,		// 4
	0x6D,		// 5
	0x7D,		// 6
	0x07,		// 7
	0x7F,		// 8
	0x6F,		// 9
	0x00,       //
	0x77,		// a
	0x7c,		// b
	0x39,		// c
	0x5e,		// d
	0x79,		// e
	0x71,		// f
	0x37,       // n
	0xee,       // y
	0x74,		// h
	0x73		// p
								   
};



//  延时子程序   //
void delay(long time)
{
 	while(time--);			  
}
//    test数组为测试数组   retu数组为检测数组          //
//          检测程序一般为查表检测					   //
//      按表test发送检测信号    检测返回信号对表retu   //
//     如果不同返回0。  对完所有检测信号没有不同返回1。//
/*****************************************************/
/*                IC4001 检测程序                    */
/*****************************************************/

unsigned char IC4001(void)
{
uchar temp;
code test1[]={
			0x8c,0x9d,0xae,0xbf
			};
code test2[]={
				0x99,0xbb,0xdd,0xff
				};
				
code retu[]={
			0xCC,0x00,0x00,0x00
			};
	
	for(i=0;i<4;i++)
	{
		P1=test1[i];
		P0=test2[i];
		P1_6=0;
	   	temp=(P1&0X0C)|((P0&0X18)<<3);
	
		if(temp!=retu[i])
		{
			P1=0xff;
			P0=0xff;
			return 0;
			
		}	
		
	}
	P1=0xff;
	P0=0xff;
	return 1;
}
/*****************************************************/
/*                IC4030 检测程序                    */
/*****************************************************/
unsigned char IC4030(void)
{
uchar temp;
code test1[]={
			0x8c,0x9d,0xae,0xbf
			};
code test2[]={
				0x99,0xbb,0xdd,0xff
				};
				
code retu[]={
			0x00,0xcc,0xcc,0x00
			};
	
	for(i=0;i<4;i++)
	{
		P1=test1[i];
		P0=test2[i];
		P1_6=0;
	 	temp=(P1&0X0C)|((P0&0X18)<<3);
	
		if(temp!=retu[i])
		{
			P1=0xff;
			P0=0xff;
			return 0;
		}	
		
	}
	P1=0xff;
	P0=0xff;
	return 1;
}
/*****************************************************/
/*                IC4069 检测程序                    */
/*****************************************************/
unsigned char IC4069(void)
{
  			uchar temp1;
			P1_6=0;
			temp1=(P1&0x2a)|(P0&0x54);
			if(temp1!=0x00)
			{
				P1=0xff;
				P0=0xff;
				return 0;
			}
			P1=0xaa;P0=0xd5;
			temp1=(P1&0x2a)|(P0&0x54);
				if(temp1!=0x7e)
				{
					P1=0xff;
					P0=0xff;
					return 0;
				}
			P1=0xff;
			P0=0xff;
			return 1;
			
}
/*****************************************************/
/*                IC74138检测程序                    */
/*****************************************************/
unsigned char IC74138(void)
{
	uchar temp;
	code test[]={
				0x7f,0x7f,0x5f,0x60,
				0x61,0x62,0x63,0x64,
				0x65,0x66,0x67
				};
	code retu[]={
				0xff,0xff,0xff,0xfe,
				0xfd,0xfb,0xf7,0xef,
				0xdf,0xbf,0x7f
				};
	for(i=0;i<11;i++)
	{
	
		P1=test[i];
	
		//temp1=P1;
		//temp2=P3;
	  	temp=((P0>>1)|0x80&0x7f)|((P1&0x40)<<1);
	 	if(temp!=retu[i])
		{
			P1=0xff;
			P0=0xff;
			return 0;
			
		}
	
	}
	P1=0xff;
	P0=0xff;
	return 1;	
}
/*****************************************************/
/*                IC4011 检测程序                    */
/*****************************************************/
unsigned char IC4011(void)
{
uchar temp;
code test1[]={
			0x8c,0x9d,0xae,0xbf
			};
code test2[]={
				0x99,0xbb,0xdd,0xff
				};
				
code retu[]={
			0xcc,0xcc,0xcc,0x00
			};
	
	for(i=0;i<4;i++)
	{
		P1=test1[i];
		P0=test2[i];
		P1_6=0;
	 	temp=(P1&0X0C)|((P0&0X18)<<3);
	
		if(temp!=retu[i])
		{
			P1=0xff;
			P0=0xff;
			return 0;
		}	
		
	}
	P1=0xff;
	P0=0xff;
	return 1;
}
/*****************************************************/
/*                IC4071 检测程序                    */
/*****************************************************/
unsigned char IC4071(void)
{
uchar temp;
code test1[]={
			0x8c,0x9d,0xae,0xbf
			};
code test2[]={
				0x99,0xbb,0xdd,0xff
				};
				
code retu[]={
			0x00,0xcc,0xcc,0xcc
			};

	for(i=0;i<4;i++)
	{
		P1=test1[i];
		P0=test2[i];
		P1_6=0;
	
		temp=(P1&0X0C)|((P0&0X18)<<3);
	
		if(temp!=retu[i])
		{
			P1=0xff;
			P0=0xff;
			return 0;
			
		}	
		
	}
	P1=0xff;
	P0=0xff;
	return 1;
}
/*****************************************************/
/*                IC7420 检测程序                    */
/*****************************************************/
unsigned char IC7420(void)
{
  			uchar temp,temp1;
			code retu[]={
			0x60,0x60,0x60,0x60,
			0x60,0x60,0x60,0x60,
			0x60,0x60,0x60,0x60,
			0x60,0x60,0x60,0x00
			};
			
			for(i=0;i<16;i++)
			{
				temp=i;
				P1=((temp&0xfc)<<1)|(temp&0x03)|0xe0;
				P0=((temp&0xfc)<<2)|((temp&0x03)<<1)|0xc0;
				P1_6=0;
				P0_0=1;
					temp1=(P1&0x20)|(P0&0x40);
				if(temp1!=retu[i])
				{
					P1=0xff;
					P0=0xff;
					return 0;
				
				   }	
			}
			P1=0xff;
			P0=0xff;
			return 1;	
}
/*****************************************************/
/*                IC7442 检测程序                    */
/*****************************************************/
unsigned char IC7442(void)
{
  	uchar temp,temp1;
	code retu[]={
			0x7e,0x7d,0x7b,0x77,
			0x6f,0x5f,0x3f,0x60,
			0xa0,0xc0					
			};
		for(i=0;i<7;i++)
	 {
		temp=i;
		P0=(temp<<1)|0xe0;
		P1_7=0;
		P0_0=1;
		if(P1!=retu[i])
		{
			P1=0xff;
			P0=0xff;
			return 0;
		}
				
 	 }
	for(;i<10;i++)
	{
		temp=i;
		P0=(temp<<1)|0xe0;
		P1_7=0;
		P0_0=1;
		temp1=P0&0xe0;
	  	if(temp1!=retu[i])
		{	
			P1=0xff;
			P0=0xff;
			return 0;
		}		
 	 }	
	P1=0xff;
	P0=0xff;
	return 1;	
}
/*****************************************************/
/*                IC7474 检测程序                    */
/*****************************************************/
uchar IC7474(void)
{
	P1=0xb7;P0=0xef;
   if((P1_4&(~P1_5)&P0_5&(~P0_6))!=1)
	  {		
			P1=0xff;
			P0=0xff;
			return 0;}
		P1=0xbe;P0=0xfd;
		if(((~P1_4)&P1_5&(~P0_5)&P0_6)!=1)
		 {	P1=0xff;
			P0=0xff;
			return 0;}
		 P1=0xb6;P0=0xed;
		 if((P1_4&P1_5&P0_5&P0_6)!=1)
		  {	P1=0xff;
			P0=0xff;
			return 0;}
		   	P1=0xbb;P0=0xf7;
			P1_2=1;P0_3=1;
			 if((P1_4&(~P1_5)&P0_5&(~P0_6))!=1)
			{P1=0xff;
			P0=0xff;
			return 0;}
			   P1=0xb9;P0=0xf3;
				  P1_2=1;P0_3=1;
				  if(((~P1_4)&P1_5&(~P0_5)&P0_6)!=1)
				   {P1=0xff;
					P0=0xff;
					return 0;}
				   P1_2=0;P0_3=0;
				   if(((~P1_4)&P1_5&(~P0_5)&P0_6)!=1)
				   {P1=0xff;
					P0=0xff;
					return 0;}
				   return 1;
}
/*****************************************************/
/*                IC74112检测程序                    */
/*****************************************************/
uchar IC74112(void)
{
	P1=0x77;P0=0xbf;
   if(P1_4&(~P1_5)&(~P1_6)&(P0_7)!=1)//1
	{P1=0xff;
	P0=0xff;
	return 0;}
		P1_3=1;P0_6=1;
	
		P1_0=0;P0_3=0;
		if(((~P1_4)&P1_5&(P1_6)&(~P0_7))!=1)//4
		{	P1=0xff;
			P0=0xff;
			return 0;}
		 P1_0=1;P0_3=1;P1_2=0;P0_5=0;
		 P1_0=0;P0_3=0;
			 if(((~P1_4)&P1_5&(P1_6)&(~P0_7))!=1)//5
		 {	P1=0xff;
			P0=0xff;
			return 0;}
		  P1_0=1;P0_3=1;P1_1=0;P0_4=0;
		  P1_0=0;P0_3=0;
		    if(((~P1_4)&P1_5&(P1_6)&(~P0_7))!=1)	//7	  
		 {	P1=0xff;
			P0=0xff;
			return 0;}
	    P1_0=1;P0_3=1;P1_2=1;P0_5=1;
	
		 P1_0=0;P0_3=0;
		
		if((P1_4&(~P1_5)&(~P1_6)&(P0_7))!=1)//6
			{
			P1=0xff;
			P0=0xff;
			return 0;}
		P1=0xef;P0=0xf9;
		
		if(((~P1_4)&P1_5&(P1_6)&(~P0_7))!=1)	//2
		 {	P1=0xff;
			P0=0xff;
			return 0;}
		 
		 P1=0xf7;P0=0xb9;
	
		 if((P1_4&P1_5&P1_6&P0_7)!=1) //3
		  {	P1=0xff;
			P0=0xff;
			return 0;}
		  return 1;
		  
}
/****************************************************/
/*                IC74192和IC74193                  */
/*				  输入输出信号设置					*/
/****************************************************/
 
void Input19(unsigned char input)
{
	
	P0_7=input&0x08;
	P0_6=input&0x04;
	P1_0=input&0x02;
	P0_1=input&0x01;
}


unsigned char Output19(void)
{
   unsigned char output=0;
   output|=P1_6;
   output<<=1;
   output|=P1_5;
   output<<=1;
   output|=P1_1;
   output<<=1;
   output|=P1_2;
   return output;
}

⌨️ 快捷键说明

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