集成电路芯片测试仪
报告
林明杰
信息sy0701
0120709320517
随着电子技术的迅速发展,数字集成电路的应用越来越广泛,二
74系列逻辑芯片在数字电路中又有着非常广泛的应用,数字电路设计
中要保证设计电路的准确性,必须要求所用的芯片逻辑功能完整,但
若对所用芯片进行逐一测试,未免有些繁琐,另外,在数字电路的维
修中经常要对芯片的型号和好坏进行判断,针对上述需要,我们针对
常用的74系列逻辑芯片设计了74系列逻辑芯片测试仪,用来检测常用74系列芯片的型号和逻辑功能的好坏,从而使数字电路的设计,制
作与维修过程得到简化,达到事半功倍的效果。
关键字
74逻辑芯片 单片机 芯片测试
第2页
1
显示模块主要实现对芯片检测结果的显示,包括芯片型号及芯片功能是否完
好,同时也要给用户提供必要的提示信息,提高系统界面的友好性。 1.1.1
由于所有芯片均为74系列,因而只显示最后两位编号即可实现对芯片型号的
显示,但由于数码管显示效果较差并且动态扫描时会占用很多CPU时间,因而舍弃该
。
1.1.2
采用有二极管构成的16×16点阵,通过主控单元的控制可以实现汉字及英文
字符的显示,可以显示芯片型号以及芯片功能完整性,采用点阵显示的优点是显示
内容可以随意控制,显示内容丰富。但点阵显示也存在占用I/O口较多并且会占用大量CPU时间的缺点,另外,在使用点阵显示是还要存储大量的字模信息,而由于本系统需要扫描大量的逻辑芯片,为节约成本又未扩展程序存储区,因而考虑到所用主控单元I/O口资源有限和对程序存储区容量的限制,舍弃该方案。
1.1.31602
1602液晶为字符型液晶,可以显示16×2共32个字符,不仅可以显示芯片型号及判断结果,并且还可以在程序运行过程中为用户提供必要的提示信息,提高
了系统的交互性,并且1602液晶占用CPU时间较少,虽然显示能力较弱,仅能
显示英文字符,但基本能满足设计的要求,因而本设计采用1602液晶作为显示输出设备。
输入模块主要采用键盘进行输入有如下两种方案:
第3页
1.2.1
采用独立按键的优点是控制程序和硬件电路都很简单,缺点是如果每个按键都
要占用一个I/O口,当按键较多时占用I/O口较多,考虑到主控单元I/O口数目有限,舍弃本方案。
1.2.2
采用矩阵式键盘是通过对按键进行矩阵排列,通过主控单元分别对其行线和列
线进行扫描,从而取得按键值,它的优点是相对于独立按键占用I/O口较少,缺点是控制程序和硬件电路稍显复杂,但通过综合分析,为节省I/O口,采用矩阵式键盘作为系统的输入设备。
本设计电路模拟部分较少,电源主要用于驱动单片机、液晶以及待检测的74逻辑芯片,由于都是数字电路,对于电源的要求较低,故采用比较简单的基于
LM7805芯片的电源,电源的输出为5V刚好满足电路各部分的供电要求。
2
对于逻辑芯片的检测,我们主要是检测芯片逻辑功能好坏,由于主控单元采用
AT89s52单片机,其I/O与TTL电平完全兼容,因而直接由单片机对芯片的引
脚进行扫描,即通过单片机输出端口模拟芯片的各种输入状态,并通过单片机读回
芯片的输出结果,通过与芯片真值表的比较即可判断芯片逻辑功能的好坏,由于单
片机I/O口设置为输入方式时必须首先将其输出置为1(此时单片机输出的高电平可有外部低电平拉低,但若输出为低电平外部的高电平不能将单片机的输出拉
高),否则会发生输入逻辑错误,因而,在进行芯片扫描时必须将芯片的输出引脚
置为高电平,即让相应的单片机I/O口输出1,然后对芯片的输入引脚进行各种
状态的扫描,通过单片机读回芯片的输出,再依据芯片的真值表对其输出进相比
较,不一致则说明芯片的逻辑功能发生错误,断定芯片为坏的,若芯片的输出与真
值表完全相符,则说明芯片的逻辑功能正确,可以判断为好芯片。 由于涉及的74芯片种类多样,各种芯片的输入和输出引脚各不一样,因而必须首
先得到芯片的具体型号才能进一步判断芯片逻辑功能的好坏,芯片的型号可以通过
用户键盘输入或通过单片机程序进行检测得到,对于型号检测仍然要保证芯片的输
出引脚所接的单片机I/O口输出高电平,因而在实际设计中在保证芯片输入脚所
第4页
对应的I/O口置1的前提下,通过芯片的部分逻辑功能初步判断出芯片的型号,
然后再依据所检测的结果,可以得到芯片的引脚排列,通过单片机对芯片的逻辑功
能加以详细测试,并对结果加以显示。
3
系统主要由主控单元(单片机),检测模块,输入模块,显示模块,电源模块
几部分构成,系统的流程框图如下
图一 系统流程图
在自动检测部分主要是通过各74系列逻辑芯片逻辑功能的不同,在保证所有的输出引脚所接的单片机I/O口被配置为输入的前提下,设置逻辑芯片的输
第5页
入,然后检测芯片的输出,从而判断芯片的型号,该检测必须建立在所检测的逻辑
芯片功能完好,若检测结果为未知芯片则芯片必定为坏的或超出检测范围,为弥补
这方面的不足,在自动检测完成后,要求用户进一步确认,若型号不符则可由用户
通过键盘输入型号。
详细逻辑功能检测,该部分主要是对芯片的逻辑功能进行完整的测试,该部分
不仅实现了对芯片好坏的判别,还能够在芯片出错时判断芯片具体的错误所在,提
高了系统的实用性。
4
用所做的实物依次对所要求的芯片进行检测,验证系统能否正确检测芯片的型号,
以及芯片的逻辑功能好坏,模拟芯片错误,分为以下几种情况: a)芯片输入端断路;
b)芯片输出端断路;
c)芯片输入端之间短路;
依次对上述几种情况进行测试,验证系统能否正确检测芯片错误所在,并指示出芯
片的具体错误。
对于00/02/04/08/10/11/20/21/27/30芯片进行实物测试,测试结果满足要求,模拟错误均可正常检测,对于包含时序电路的74/109/160/245芯片进行仿
真测试,测试结果满足要求。
第6页
5
表一:系统元器件清单
名称 数量 名称 数量 AT89s52 1 带锁开关 1 1602液晶 1 ISP下载口 1 按键 13 液晶插座 1 10K排阻 1 DIP14插座 1 DIP40插座 1 400Ω电阻 2 10KΩ电阻 1 104瓷片电容 2 12M晶振 1 10uF电解电容 2 2200uF电解电1 整流桥 1 容
9V输出变压器 1 LM7805 1 杜邦线 若干 导线 若干
6
[1] 康华光. 电子技术基础(数字部分). 高等教育出版社 [2] 康华光. 电子技术基础(模拟部分). 高等教育出版社 [3] 沙占友,王彦朋,孟志永等. 单片机外围电路设计. 电子工业出版社
第7页
附件一:系统电路图
第8页
实物照片:
代码:
/*********************************
所有者:灵动组合
编写时间:2009.4.9
版本:1.0.0
*********************************/
#include "reg51.h"
sbit P20=P2^0; //定义引脚供芯片检测输出时使用 sbit P21=P2^1; //定义引脚供芯片检测输出时使用 sbit P22=P2^2; //定义引脚供芯片检测输出时使用 sbit P23=P2^3; //定义引脚供芯片检测输出时使用 sbit P24=P2^4; //定义引脚供芯片检测输出时使用 sbit P25=P2^5; //定义引脚供芯片检测输出时使用 sbit P26=P2^6; //定义引脚供芯片检测输出时使用 sbit P27=P2^7; //开始信号检测使用
第9页
sbit P10=P1^0; //定义引脚供芯片检测输出时使用 sbit P11=P1^1; //定义引脚供芯片检测输出时使用 sbit P12=P1^2; //定义引脚供芯片检测输出时使用 sbit P13=P1^3; //定义引脚供芯片检测输出时使用 sbit P14=P1^4; //定义引脚供芯片检测输出时使用 sbit P15=P1^5; //定义引脚供芯片检测输出时使用 sbit P16=P1^6; //定义引脚供芯片检测输出时使用 sbit P17=P1^7; //定义引脚供芯片检测输出时使用 sbit P33=P3^3; //定义引脚供芯片检测输出时使用 sbit P34=P3^4; //定义引脚供芯片检测输出时使用 sbit P35=P3^5; //定义引脚供芯片检测输出时使用 sbit set14=P3^6; //设置14脚芯片的地 sbit set16=P3^7; //设置14脚芯片的地
unsigned char code
table[15][8]={"74xx00","74xx02","74xx04","74xx08","74xx10",
"74xx11","74xx20","74xx21","74xx27","74xx30","74xx74","74xx
109","74xx245","74xx160","unknown"};
#include "type.h"
#include "LCD1602.h"
#include "disp.h"
#include "function.h"
main()
{
unsigned char scantype,goodchip=1,i;
unsigned char bad[7]={' ',' ',' ',' ',' ',' ',' '};
LCD_Initial();
GotoXY(3,0);
Print("LING DONG");
scantype=setpin();//返回16,20脚芯片的芯片型号,并设置相应的地引脚
LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN);//清屏
if(scantype==14)
{
scantype=type();//重新扫描14脚的芯片型号
}
switch (scantype)
{
case 0:
goodchip=chip7400(bad);
第10页
break;
case 2:
goodchip=chip7404(bad);
break;
case 3:
goodchip=chip7408(bad);
break;
case 4:
goodchip=chip7410(bad);
break;
case 1:
goodchip=chip7402(bad);
break;
case 5:
goodchip=chip7411(bad);
break;
case 8:
goodchip=chip7427(bad);
break;
case 6:
goodchip=chip7420(bad);
break;
case 9:
goodchip=chip7430(bad);
break;
case 7:
goodchip=chip7421(bad);
break;
case 10:
goodchip=chip7474(bad);
break;
case 11:
goodchip=chip74109(bad);
break;
case 12:
goodchip=chip74245(bad);
break;
case 13:
goodchip=chip74160(bad);
break;
default:
goodchip=0;
break;
第11页
}
if(goodchip)
dispresult(1,scantype);
else if(scantype==14)
dispresult(0,scantype);
else
{
dispresult(0,scantype);
delayms(60000);
LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN);//清屏
GotoXY(0,0);
for(i=0;i<=6;i++)
{
GotoXY(2*i,0);
delayms(10);
LCD_Write(LCD_DATA, bad[i]);
LCD_Write(LCD_DATA, ' ');
}
GotoXY(1,1);
Print("is (are) bad!");
}
while(1);
}
//函数名称:chip7400()
//函数功能:实现对7400逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip7400(unsigned char *bad)
{
unsigned char goodchip,x0,x1,x2,x3,x4,x5,x6,x7;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x01ff;temp>=0x0100;temp--)
{
第12页
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
x5=(bit)(temp&0x0020);
x6=(bit)(temp&0x0040);
x7=(bit)(temp&0x0080);
P10=(bit)(temp&0x0001);//给输入端赋值
P11=(bit)(temp&0x0002);
P13=(bit)(temp&0x0004);
P14=(bit)(temp&0x0008);
P16=(bit)(temp&0x0010);
P17=(bit)(temp&0x0020);
P21=(bit)(temp&0x0040);
P22=(bit)(temp&0x0080);
if(x0!=P10||x1!=P11)
{
goodchip=0;
bad[4]='4';
} //检测输入端是否发生变化
if(x2!=P13||x3!=P14)
{
goodchip=0;
bad[3]='3';
} //检测输入端是否发生变化
if(x4!=P16||x5!=P17)
{
goodchip=0;
bad[2]='2';
} //检测输入端是否发生变化
if(x6!=P21||x7!=P22)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
if((!(P10&&P11)&&(!P12))||(P10&&P11&&P12))
第13页
{
goodchip=0;
bad[4]='4';
}
if((!(P13&&P14)&&(!P15))||(P13&&P14&&P15))
{
goodchip=0;
bad[3]='3';
}
if((!(P16&&P17)&&(!P20))||(P16&&P17&&P20))
{
goodchip=0;
bad[2]='2';
}
if((!(P21&&P22)&&(!P23))||(P21&&P22&&P23))
{
goodchip=0;
bad[1]='1';
}
}
return goodchip;
}
//函数名称:chip7404()
//函数功能:实现对7404逻辑芯片逻辑功能的检测
//输入:无 //输出:芯片好坏标志,1为好,0为坏
unsigned char chip7404(unsigned char *bad)
{
unsigned char goodchip,x0,x1,x2,x3,x4,x5;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x01ff;temp>=0x0100;temp--)
{
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
第14页
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
x5=(bit)(temp&0x0020);
P10=(bit)(temp&0x0001);//给输入端赋值
P12=(bit)(temp&0x0002);
P14=(bit)(temp&0x0004);
P16=(bit)(temp&0x0008);
P20=(bit)(temp&0x0010);
P22=(bit)(temp&0x0020);
if(x0!=P10)
{
goodchip=0;
bad[5]='6';
} //检测输入端是否发生变化
if(x1!=P12)
{
goodchip=0;
bad[4]='5';
} //检测输入端是否发生变化
if(x2!=P14)
{
goodchip=0;
bad[3]='4';
} //检测输入端是否发生变化
if(x3!=P16)
{
goodchip=0;
bad[0]='1';
} //检测输入端是否发生变化
if(x4!=P20)
{
goodchip=0;
bad[1]='2';
} //检测输入端是否发生变化
if(x5!=P22)
{
goodchip=0;
bad[2]='3';
} //检测输入端是否发生变化
第15页
if((P10&&P11)||((!P10)&&(!P11)))
{
goodchip=0;
bad[5]='6';
}
if((P12&&P13)||((!P12)&&(!P13)))
{
goodchip=0;
bad[4]='5';
}
if((P14&&P15)||((!P14)&&(!P15)))
{
goodchip=0;
bad[3]='4';
}
if((P16&&P17)||((!P16)&&(!P17)))
{
goodchip=0;
bad[0]='1';
}
if((P20&&P21)||((!P20)&&(!P21)))
{
goodchip=0;
bad[1]='2';
}
if((P22&&P23)||((!P22)&&(!P23)))
{
goodchip=0;
bad[2]='3';
}
}
return goodchip;
}
//函数名称:chip7408()
//函数功能:实现对7408逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip7408(unsigned char * bad)
第16页
{
unsigned char goodchip,x0,x1,x2,x3,x4,x5,x6,x7;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x01ff;temp>=0x0100;temp--)
{
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
x5=(bit)(temp&0x0020);
x6=(bit)(temp&0x0040);
x7=(bit)(temp&0x0080);
P10=(bit)(temp&0x0001);//给输入端赋值
P11=(bit)(temp&0x0002);
P13=(bit)(temp&0x0004);
P14=(bit)(temp&0x0008);
P16=(bit)(temp&0x0010);
P17=(bit)(temp&0x0020);
P21=(bit)(temp&0x0040);
P22=(bit)(temp&0x0080);
if(x0!=P10||x1!=P11)
{
goodchip=0;
bad[4]='4';
} //检测输入端是否发生变化
if(x2!=P13||x3!=P14)
{
goodchip=0;
bad[3]='3';
} //检测输入端是否发生变化
if(x4!=P16||x5!=P17)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
if(x6!=P21||x7!=P22)
{
第17页
goodchip=0;
bad[2]='2';
} //检测输入端是否发生变化
if((!(P10&&P11)&&P12)||((P10&&P11)&&(!P12)))
{
goodchip=0;
bad[4]='4';
}
if((!(P13&&P14)&&P15)||((P13&&P14)&&(!P15)))
{
goodchip=0;
bad[3]='3';
}
if((!(P16&&P17)&&P20)||((P16&&P17)&&(!P20)))
{
goodchip=0;
bad[1]='1';
}
if((!(P21&&P22)&&P23)||((P21&&P22)&&(!P23)))
{
goodchip=0;
bad[2]='2';
}
}
return goodchip;
}
//函数名称:chip7410()
//函数功能:实现对7410逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip7410(unsigned char *bad)
{
unsigned char goodchip,x0,x1,x2,x3,x4,x5,x6,x7,x8;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x03ff;temp>=0x0200;temp--)
第18页
{
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
x5=(bit)(temp&0x0020);
x6=(bit)(temp&0x0040);
x7=(bit)(temp&0x0080);
x8=(bit)(temp&0x0100);
P10=(bit)(temp&0x0001);//给输入端赋值
P12=(bit)(temp&0x0002);
P13=(bit)(temp&0x0004);
P14=(bit)(temp&0x0008);
P16=(bit)(temp&0x0010);
P17=(bit)(temp&0x0020);
P20=(bit)(temp&0x0040);
P21=(bit)(temp&0x0080);
P22=(bit)(temp&0x0100);
if(x0!=P10||x4!=P16||x5!=P17)
{
goodchip=0;
bad[1]='1';
} //检测输入端
是否发生变化
if(x1!=P12||x2!=P13||x3!=P14)
{
goodchip=0;
bad[3]='3';
} //检测输入端
是否发生变化
if(x6!=P20||x7!=P21||x8!=P22)
{
goodchip=0;
bad[2]='2';
} //检测输入端
是否发生变化
第19页
if((!(P10&&P16&&P17)&&(!P11))||((P10&&P16&&P17)&&P11))
{
goodchip=0;
bad[1]='1';
}
if((!(P20&&P21&&P22)&&(!P23))||((P20&&P21&&P22)&&P23))
{
goodchip=0;
bad[2]='2';
}
if((!(P12&&P13&&P14)&&(!P15))||((P12&&P13&&P14)&&P15))
{
goodchip=0;
bad[3]='3';
}
}
return goodchip;
}
//函数名称:chip7402()
//函数功能:实现对7402逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip7402(unsigned char *bad)
{
unsigned char goodchip,x0,x1,x2,x3,x4,x5,x6,x7;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x01ff;temp>=0x0100;temp--)
{
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
第20页
x5=(bit)(temp&0x0020);
x6=(bit)(temp&0x0040);
x7=(bit)(temp&0x0080);
P11=(bit)(temp&0x0001);//给输入端赋值
P12=(bit)(temp&0x0002);
P14=(bit)(temp&0x0004);
P15=(bit)(temp&0x0008);
P17=(bit)(temp&0x0010);
P20=(bit)(temp&0x0020);
P22=(bit)(temp&0x0040);
P23=(bit)(temp&0x0080);
if(x0!=P11||x1!=P12)
{
goodchip=0;
bad[4]='4';
} //检测输入端是否发生变化
if(x2!=P14||x3!=P15)
{
goodchip=0;
bad[3]='3';
} //检测输入端是否发生变化
if(x4!=P17||x5!=P20)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
if(x6!=P22||x7!=P23)
{
goodchip=0;
bad[2]='2';
} //检测输入端是否发生变化
if(((P11||P12)&&P10)||(!(P11||P12)&&(!P10)))
{
goodchip=0;
bad[4]='4';
}
if(((P14||P15)&&P13)||(!(P14||P15)&&(!P13)))
{
goodchip=0;
第21页
bad[3]='3';
}
if(((P17||P20)&&P16)||(!(P17||P20)&&(!P16)))
{
goodchip=0;
bad[1]='1';
}
if(((P22||P23)&&P21)||(!(P22||P23)&&(!P21)))
{
goodchip=0;
bad[2]='2';
}
}
return goodchip;
}
//函数名称:chip7411()
//函数功能:实现对7411逻辑芯片逻辑功能的检测
//输入:无 //输出:芯片好坏标志,1为好,0为坏
unsigned char chip7411(unsigned char *bad)
{
unsigned char goodchip,x0,x1,x2,x3,x4,x5,x6,x7,x8;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x03ff;temp>=0x0200;temp--)
{
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
x5=(bit)(temp&0x0020);
x6=(bit)(temp&0x0040);
x7=(bit)(temp&0x0080);
x8=(bit)(temp&0x0100);
第22页
P10=(bit)(temp&0x0001);//给输入端赋值
P12=(bit)(temp&0x0002);
P13=(bit)(temp&0x0004);
P14=(bit)(temp&0x0008);
P16=(bit)(temp&0x0010);
P17=(bit)(temp&0x0020);
P20=(bit)(temp&0x0040);
P21=(bit)(temp&0x0080);
P22=(bit)(temp&0x0100);
if(x0!=P10||x4!=P16||x5!=P17)
{
goodchip=0;
bad[1]='1';
} //检测输入端
是否发生变化
if(x1!=P12||x2!=P13||x3!=P14)
{
goodchip=0;
bad[3]='3';
} //检测输入端
是否发生变化
if(x6!=P20||x7!=P21||x8!=P22)
{
goodchip=0;
bad[2]='2';
} //检测输入端
是否发生变化
if(((P10&&P16&&P17)&&(!P11))||(!(P10&&P16&&P17)&&P11))
{
goodchip=0;
bad[1]='1';
}
if(((P20&&P21&&P22)&&(!P23))||(!(P20&&P21&&P22)&&P23))
{
goodchip=0;
bad[2]='2';
}
第23页
if(((P12&&P13&&P14)&&(!P15))||(!(P12&&P13&&P14)&&P15))
{
goodchip=0;
bad[3]='3';
}
}
return goodchip;
}
//函数名称:chip7427() //函数功能:实现对7427逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip7427(unsigned char *bad)
{
unsigned char goodchip=1,x0,x1,x2,x3,x4,x5,x6,x7,x8;
unsigned int temp;
goodchip=1;//芯片好坏标志,初始为好
for(temp=0x03ff;temp>=0x0200;temp--)
{
P1=0XFF;
P2=0X0F;
x0=(bit)(temp&0x0001);//取出赋给输入端的值
x1=(bit)(temp&0x0002);
x2=(bit)(temp&0x0004);
x3=(bit)(temp&0x0008);
x4=(bit)(temp&0x0010);
x5=(bit)(temp&0x0020);
x6=(bit)(temp&0x0040);
x7=(bit)(temp&0x0080);
x8=(bit)(temp&0x0100);
P10=(bit)(temp&0x0001);//给输入端赋值
P12=(bit)(temp&0x0002);
P13=(bit)(temp&0x0004);
P14=(bit)(temp&0x0008);
P16=(bit)(temp&0x0010);
P17=(bit)(temp&0x0020);
第24页
P20=(bit)(temp&0x0040);
P21=(bit)(temp&0x0080);
P22=(bit)(temp&0x0100);
if(x0!=P10||x4!=P16||x5!=P17)
{
goodchip=0;
bad[1]='1';
} //检测输入端
是否发生变化
if(x1!=P12||x2!=P13||x3!=P14)
{
goodchip=0;
bad[3]='3';
} //检测输入端
是否发生变化
if(x6!=P20||x7!=P21||x8!=P22)
{
goodchip=0;
bad[2]='2';
} //检测输入端
是否发生变化
if((!(P10||P16|P17)&&(!P11))||(P10||P16||P17)&&P11)
{
goodchip=0;
bad[1]='1';
}
if((!(P20||P21||P22)&&(!P23))||(P20||P21||P22)&&P23)
{
goodchip=0;
bad[2]='2';
}
if((!(P12||P13||P14)&&(!P15))||(P12||P13||P14)&&P15)
{
goodchip=0;
bad[3]='3';
}
}
return goodchip;
}
//函数名称 chip7420
第25页
//函数功能 精确判断芯片74ls20好坏
//输入变量无
//输出变量无
unsigned char chip7420(unsigned char *bad) {
unsigned char
goodchip=1,temp,temp1,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9;
temp=0x3f;
temp1=0x20;
while(temp>=0x20&&temp1<=0x3f)
{
//取出输入端初始状态
x0=(bit)(temp&0x01);
x1=(bit)(temp&0x02);
x2=(bit)(temp&0x04);
x3=(bit)(temp&0x08);
x4=(bit)(temp&0x10);
x5=(bit)(temp1&0x01);
x6=(bit)(temp1&0x02);
x7=(bit)(temp1&0x04);
x8=(bit)(temp1&0x08);
x9=(bit)(temp1&0x10);
//给端口赋值
P10=(bit)(temp&0x01);
P11=(bit)(temp&0x02);
P12=(bit)(temp&0x04);
P13=(bit)(temp&0x08);
P14=(bit)(temp&0x10);
P15=(bit)(temp&0x20);
P16=(bit)(temp1&0x01);
P17=(bit)(temp1&0x02);
P20=(bit)(temp1&0x04);
P21=(bit)(temp1&0x08);
P22=(bit)(temp1&0x10);
P23=(bit)(temp1&0x20);
if(x0!=P10||x1!=P11||x2!=P12||x3!=P13||x4!=P14)
{
goodchip=0;
bad[2]='2';
}
第26页
//检测输入端是否发生变化
if(x0!=P10||x1!=P11||x2!=P12||x3!=P13||x4!=P14||x5!=P16||x
6!=P17||x7!=P20||x8!=P21||x9!=P22)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
//检测第二个
switch(P1&0x3f)
{
case 0x3f:
case 0x3b:
{
goodchip=0;
bad[2]='2';
}
case 0x1f:
case 0x1b:
break;
default :
if(P15==0)
{
goodchip=0;
bad[2]='2';
}
}
//检测第一个
if(P16==1&&P17==1)
{
if((P21==0&&P22==0)||(P21==0&&P22==1)||(P21==1&&P22=
=0))
{
if(P23==0)
{
goodchip=0;
bad[1]='1';
}
}
if(P21==1&&P22==1)
{
if(P23==1)
第27页
{
goodchip=0;
bad[1]='1';
}
}
}
if((P16==1&&P17==0)||(P16==0&&P17==1)||(P16==0&&P17==0))
if(P23==0)
{
goodchip=0;
bad[1]='1';
}
temp--;
temp1++;
}
return goodchip;
}
//函数名称 chip7421
//函数功能 精确判断芯片74ls21好坏
//输入变量无
//输出变量无
unsigned char chip7421(unsigned char *bad) {
unsigned char
goodchip=1,temp,temp1,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9;
temp=0x3f;
temp1=0x20;
while(temp>=0x20&&temp1<=0x3f)
{
//取出输入端初始状态
x0=(bit)(temp&0x01);
x1=(bit)(temp&0x02);
x2=(bit)(temp&0x04);
x3=(bit)(temp&0x08);
x4=(bit)(temp&0x10);
x5=(bit)(temp1&0x01);
第28页
x6=(bit)(temp1&0x02);
x7=(bit)(temp1&0x04);
x8=(bit)(temp1&0x08);
x9=(bit)(temp1&0x10);
//给端口赋值
P10=(bit)(temp&0x01);
P11=(bit)(temp&0x02);
P12=(bit)(temp&0x04);
P13=(bit)(temp&0x08);
P14=(bit)(temp&0x10);
P15=(bit)(temp&0x20);
P16=(bit)(temp1&0x01);
P17=(bit)(temp1&0x02);
P20=(bit)(temp1&0x04);
P21=(bit)(temp1&0x08);
P22=(bit)(temp1&0x10);
P23=(bit)(temp1&0x20);
if(x0!=P10||x1!=P11||x2!=P12||x3!=P13||x4!=P14)
{
goodchip=0;
bad[2]='2';
} //检测输入端是否发生变化
if(x5!=P16||x6!=P17||x7!=P20||x8!=P21||x9!=P22)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
//检测第二个
switch (P1&0x3f)
{
case 0x3f:
case 0x3b:
break;
case 0x1f:
case 0x1b:
{
goodchip=0;
bad[2]='2';
}
default:
if(P15==1)
{
第29页
goodchip=0;
bad[2]='2';
}
}
//检测第一个
if(P16&&P17&&((P2&0X0f)==0x07||(P2&0X0f)==0x06))
{
goodchip=0;
bad[1]='1';
}
if((P16==1&&P17==0)||(P16==0&&P17==1)||(P16==0&&P17=
=0))
if(P23==1)
{
goodchip=0;
bad[1]='1';
}
temp--;
temp1++;
}
return goodchip;
}
//函数名称 chip7430 //函数功能 精确判断芯片74ls30好坏
//输入变量无 //输出变量 e30
unsigned char chip7430(unsigned char *bad)
{
unsigned char templ,goodchip=1,temp,x0,x1,x2,x3,x4,x5,x6,x7;
goodchip=1;
templ=0xff;
while(templ>=1)
第30页
{
P1=0x20;
temp=templ-1;
x0=(bit)(temp&0x01);//取出赋给输入端口的状态
x1=(bit)(temp&0x02);
x2=(bit)(temp&0x04);
x3=(bit)(temp&0x08);
x4=(bit)(temp&0x10);
x5=(bit)(temp&0x20);
x6=(bit)(temp&0x40);
x7=(bit)(temp&0x80);
P11=(bit)(temp&0x01);//给输入端口赋值
P12=(bit)(temp&0x02);
P16=(bit)(temp&0x04);
P17=(bit)(temp&0x08);
P20=(bit)(temp&0x10);
P21=(bit)(temp&0x20);
P22=(bit)(temp&0x40);
P23=(bit)(temp&0x80);
if((x0!=P11)||(x1!=P12)||(x2!=P16)||(x3!=P17)||(x4!=P20)||(x
5!=P21)||(x6!=P22)||(x7!=P23))
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
if(P15!=1)
{
goodchip=0;
bad[1]='1';
}
templ--;
}
//取出赋给输入端口的状态
temp=0xff;
templ=0x0f;
第31页
//给输入端口赋值
P1=0xff;
P2=0x0f;
if(((temp&0xdf)!=(P1&0xdf))||(templ!=P2))//检测输入端是否发生
变化
{
goodchip=0;
bad[1]='1';
}
if(P15!=0)
{
goodchip=0;
bad[1]='1';
}
return goodchip;
}
//函数名称 chip7474 //函数功能 精确判断芯片74ls74好坏
//输入变量 无 //输出变量 e30
unsigned char chip7474(unsigned char *bad)
{
unsigned char goodchip=1,temp,temp1,x0,x1,x2,x3,x4,x5,x6,x7;
temp=0x3f;
temp1=0x30;
while(temp>=0x30&&temp1<=0x3f)
{
//取出输入端初始状态
x0=(bit)(temp&0x01);
x1=(bit)(temp&0x02);
x2=(bit)(temp&0x04);
x3=(bit)(temp&0x08);
x4=(bit)(temp1&0x01);
x5=(bit)(temp1&0x02);
x6=(bit)(temp1&0x04);
x7=(bit)(temp1&0x08);
//给端口赋值
P10=(bit)(temp&0x01);
第32页
P11=(bit)(temp&0x02);
P12=(bit)(temp&0x04);
P13=(bit)(temp&0x08);
P14=(bit)(temp&0x10);
P15=(bit)(temp&0x20);
P16=(bit)(temp1&0x01);
P17=(bit)(temp1&0x02);
P20=(bit)(temp1&0x04);
P21=(bit)(temp1&0x08);
P22=(bit)(temp1&0x10);
P23=(bit)(temp1&0x20);
if(x0!=P10||x1!=P11||x2!=P12||x3!=P13)
{
goodchip=0;
bad[2]='2';
} //检测输入端是否发生变化
if(x4!=P16||x5!=P17||x6!=P20||x7!=P21)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
//检测上一个
if(P10==1&&P13==0&&(P14==0||P15==1))
{
goodchip=0;
bad[2]='2';
}
if(P10==0&&P13==1&&(P14==1||P15==0))
{
goodchip=0;
bad[2]='2';
}
if(P10==1&&P13==1)
{
if(P11==1&&P12==1)
{
P12=0;
P12=1;
if(P14==0||P15==1)
{
goodchip=0;
第33页
bad[2]='2';
}
}
if(P11==0&&P12==1)
{
P12=0;
P12=1;
if(P14==1||P15==0)
{
goodchip=0;
bad[2]='2';
}
}
if(P12==0)
if(P14==1||P15==0)
{
goodchip=0;
bad[2]='2';
}
}
//检测下一个
if(P16==1&&P21==0&&(P22==0||P23==1))
{
goodchip=0;
bad[1]='1';
}
if(P16==0&&P21==1&&(P22==1||P23==0))
{
goodchip=0;
bad[1]='1';
}
if(P16==1&&P21==1)
{
if(P17==1&&P20==1)
{
P20=0;
P20=1;
if(P22==0||P23==1)
{
goodchip=0;
bad[1]='1';
}
}
第34页
if(P17==0&&P20==1)
{
P20=0;
P20=1;
if(P22==1||P23==0)
{
goodchip=0;
bad[1]='1';
}
}
if(P20==0)
if(P22==1||P23==0)
{
goodchip=0;
bad[1]='1';
}
}
temp--;
temp1++;
}
return goodchip;
}
//函数名称:chip74109()
//函数功能:实现对74109逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip74109(unsigned char *bad) {
unsigned char
goodchip=1,temp,temp1,x0,x1,x2,x3,x4,x5,x6,x7,x8,x9;
temp=0x7f;
temp1=0x60;
while(temp>=0x60&&temp1<=0x7f)
{
第35页
//取出输入端初始状态
x0=(bit)(temp&0x01);
x1=(bit)(temp&0x02);
x2=(bit)(temp&0x04);
x3=(bit)(temp&0x08);
x4=(bit)(temp&0x10);
x5=(bit)(temp1&0x01);
x6=(bit)(temp1&0x02);
x7=(bit)(temp1&0x04);
x8=(bit)(temp1&0x08);
x9=(bit)(temp1&0x10);
//给端口赋值
P10=(bit)(temp&0x01);
P11=(bit)(temp&0x02);
P12=(bit)(temp&0x04);
P13=(bit)(temp&0x08);
P14=(bit)(temp&0x10);
P15=(bit)(temp&0x20);
P27=(bit)(temp&0x40);
P16=(bit)(temp1&0x01);
P17=(bit)(temp1&0x02);
P20=(bit)(temp1&0x04);
P21=(bit)(temp1&0x08);
P22=(bit)(temp1&0x10);
P23=(bit)(temp1&0x20);
P24=(bit)(temp1&0x40);
if(x0!=P10||x1!=P11||x2!=P12||x3!=P13||x4!=P14)
{
goodchip=0;
bad[2]='2';
} //检测输入端是否发生变化
if(x5!=P16||x6!=P17||x7!=P20||x8!=P21||x9!=P22)
{
goodchip=0;
bad[1]='1';
} //检测输入端是否发生变化
//检测上一个
if(P10==0&&P14==1)
{
if(P15!=0||P27!=1)
第36页
{
goodchip=0;
bad[2]='2';
}
else //取反
{
P10=1;//PR置1
P14=1;//CLR置1
P11=1;//J置1
P12=0;//K置0
P13=0;//CLK置0
P13=1;//CLK置1
if(P15==0||P27==1)
{
goodchip=0;
bad[2]='2';
}
}
P10=0;
P14=1;
}
if(P10==1&&P14==0)
{
if(P15!=1||P27!=0)
{
goodchip=0;
bad[2]='2';
}
else //取反
{
P10=1;//PR置1
P14=1;//CLR置1
P11=1;//J置1
P12=0;//K置0
P13=0;//CLK置0
P13=1;//CLK置1
if(P15==1||P27==0)
{
goodchip=0;
bad[2]='2';
}
}
第37页
P10=1;
P14=0;
}
if(P10==1&&P14==1)
{
if((P11==0)&&(P12==0)&&(P13==1))
{
P13=0;
P13=1;
if((P15!=0)||(P27!=1))
{
goodchip=0;
bad[2]='2';
}
}
if((P11==1)&&(P12==1)&&(P13==1))
{
P13=0;
P13=1;
if((P15!=1)||(P27!=0))
{
goodchip=0;
bad[2]='2';
}
}
x0=P15;
x1=P27;
if((P11==0)&&(P12==1)&&(P13==1))
{
P13=0;
P13=1;
if((P15!=x0)||(P27!=x1))
{
goodchip=0;
bad[2]='2';
}
}
if(P13==0)
if((P15!=x0)||(P27!=x1))
{
goodchip=0;
bad[2]='2';
}
第38页
}
if(P16==0&&P22==1)
{
if(P23!=0||P24!=1)
{
goodchip=0;
bad[1]='1';
}
else //取反
{
P16=1;//PR置1
P22=1;//CLR置1
P17=1;//J置1
P20=0;//K置0
P21=0;//CLK置0
P21=1;//CLK置1
if(P23==0||P24==1)
{
goodchip=0;
bad[1]='1';
}
}
P16=0;
P22=1;
}
if(P16==1&&P22==0)
{
if(P23!=1||P24!=0)
{
goodchip=0;
bad[1]='1';
}
else //取反
{
P16=1;//PR置1
P22=1;//CLR置1
第39页
P17=1;//J置1
P20=0;//K置0
P21=0;//CLK置0
P21=1;//CLK置1
if(P23==1||P24==0)
{
goodchip=0;
bad[1]='1';
}
}
P16=1;
P22=0;
}
if(P16==1&&P22==1)
{
if((P17==0)&&(P20==0)&&(P21==1))
{
P21=0;
P21=1;
if((P23!=0)||(P24!=1))
{
goodchip=0;
bad[1]='1';
}
}
if((P17==1)&&(P20==1)&&(P21==1))
{
P21=0;
P21=1;
if((P23!=1)||(P24!=0))
{
goodchip=0;
bad[1]='1';
}
}
x0=P23;
x1=P24;
if((P17==0)&&(P20==1)&&(P21==1))
{
P21=0;
P21=1;
if((P23!=x0)||(P24!=x1))
第40页
{
goodchip=0;
bad[1]='1';
}
}
if(P21==0)
if((P23!=x0)||(P24!=x1))
{
goodchip=0;
bad[1]='1';
}
}
temp--;
temp1++;
}
return goodchip;
}
//函数名称:chip74245() //函数功能:实现对74245逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip74245(unsigned char *bad)
{
unsigned char goodchip=1,i,temp,temp2;
//使能端的检测部分
P10=1;//关闭使能端
P1=0xff;
P2=0xff;
P3=0x30;
if(P1!=0xff||P2!=0xff||P3!=0x30)
{
goodchip=0;
bad[1]='1';
} //检测出错,芯片好坏标志置0
P1=0x01;
P2=0x00;
P3=0x00;
if(P1!=0x01||P2!=0x00||P3!=0x00)
第41页
{
goodchip=0;
bad[1]='1';
} //检测出错,芯片好坏标志置0
temp=0x01;
for(i=1;i<=8;i++)
{
P1=0xff;
P2=0xff;
P3=0x30;
P10=0;//设置芯片使能
P16=1;//设置传输方向为A?B
P17=(bit)(temp&0x01);
P20=(bit)(temp&0x02);
P21=(bit)(temp&0x04);
P22=(bit)(temp&0x08);
P23=(bit)(temp&0x10);
P24=(bit)(temp&0x20);
P25=(bit)(temp&0x40);
P26=(bit)(temp&0x80);
if(P11!=(bit)(temp&0x01)||
P12!=(bit)(temp&0x02)||
P13!=(bit)(temp&0x04)||
P14!=(bit)(temp&0x08)||
P15!=(bit)(temp&0x10)||
P27!=(bit)(temp&0x20)||
P34!=(bit)(temp&0x40)||
P35!=(bit)(temp&0x80))
{
goodchip=0;//检测出错,芯片好坏标志置0
bad[1]='1';
break;
}
temp=_crol_(temp,1);
}
temp=0x01;
for(i=1;i<=8;i++)
{
P1=0xff;
第42页
P2=0xff;
P3=0x30;
P10=0;//设置芯片使能
P16=0;//设置传输方向为A?B
P11=(bit)(temp&0x01);
P12=(bit)(temp&0x02);
P13=(bit)(temp&0x04);
P14=(bit)(temp&0x08);
P15=(bit)(temp&0x10);
P27=(bit)(temp&0x20);
P34=(bit)(temp&0x40);
P35=(bit)(temp&0x80);
temp2=P2;
temp2=(temp&0x7f)<<1;
if(P17!=(bit)(temp&0x01)||temp2!=temp&0xfe)
{
goodchip=0;//检测出错,芯片好坏标志置0
bad[1]='1';
break;
}
temp=_crol_(temp,1);
}
return goodchip;
}
//函数名称:chip74160() //函数功能:实现对74160逻辑芯片逻辑功能的检测
//输入:无
//输出:芯片好坏标志,1为好,0为坏
unsigned char chip74160(unsigned char *bad)
{
unsigned char goodchip=1,temp,temp1,temp2,y0,y1,y2,y3;
P16=0;
if((P10==1)||(P11==1)||(P12==1)||(P13==1)||(P14==1))
{
goodchip=0;
bad[1]='1';
}
P16=1;
第43页
P27=0;
for(temp=0x10;temp>=0x01;temp--)//预置数
{
temp1=temp-1;
//取出端口值
y0=(bit)(temp1&0x01);
y1=(bit)(temp1&0x02);
y2=(bit)(temp1&0x04);
y3=(bit)(temp1&0x08);
//给端口赋值
P20=(bit)(temp1&0x01);
P21=(bit)(temp1&0x02);
P22=(bit)(temp1&0x04);
P23=(bit)(temp1&0x08);
P11=1;
P12=1;
P13=1;
P14=1;
P17=0;
P17=1;
if((y0!=P11)||(y1!=P12)||(y2!=P13)||(y3!=P14))
{
goodchip=0;
bad[1]='1';
}
}
P16=0;
P16=1;
P27=1;
P15=1;
P24=1;
for(temp2=0x00;temp2<=0x08;temp2++)//从0计数
{
P17=0;
P17=1;
y0=P11;
y1=P12;
y2=P13;
y3=P14;
if((y0+y1*2+y2*4+y3*8-1)!=temp2)
第44页
{
goodchip=0;
bad[1]='1';
}
if(temp2==0x08&&P10!=1)
{
goodchip=0;
bad[1]='1';
}
P15=0;
P17=0;
P17=1;
if((y0+y1*2+y2*4+y3*8-1)!=temp2)//保持不变
{
goodchip=0;
bad[1]='1';
} ;
P15=1;
P24=0;
P17=0;
P17=1;
if((y0+y1*2+y2*4+y3*8-1)!=temp2)//保持不变
{
goodchip=0;
bad[1]='1';
}
P24=1;
P15=0;
P24=0;
P17=0;
P17=1;
if((y0+y1*2+y2*4+y3*8-1)!=temp2)//保持不变
{
goodchip=0;
bad[1]='1';
}
P15=1;
P24=1;
}
return goodchip; }
第45页
/*******************************************************
*******************
THE 1602 CHAR LCD LIB
COPYRIGHT (c) 2009 BY LMJ.
-- ALL RIGHTS RESERVED --
File Name: LCD.h
Author: 林明杰
Created: 2009/2/19
Modified: NO
Revision: 1.0
********************************************************
*******************/
#include
//Port
Definitions************************************************
**********
sbit LcdRs = P3^0;
sbit LcdRw = P3^1;
sbit LcdEn = P3^2;
sfr DBPort = 0x80;
//P0=0x80,P1=0x90,P2=0xA0,P3=0xB0.数据端口
//内部等待函数
********************************************************
******************
unsigned char LCD_Wait(void)
{
LcdRs=0;
LcdRw=1; _nop_();
LcdEn=1; _nop_();
//while(DBPort&0x80);//在用Proteus仿真时,注意用屏蔽此语句,在
调用GotoXY()时,会进入死循环,
//可能在写该控制字时,该模块没有返
第46页
回写入完备命令,即DBPort&0x80==0x80
//实际硬件时打开此语句
LcdEn=0;
return DBPort;
}
//向LCD写入命令或数据
********************************************************
****
#define LCD_COMMAND 0 // Command
#define LCD_DATA 1 // Data
#define LCD_CLEAR_SCREEN 0x01 // 清屏 #define LCD_HOMING 0x02 // 光标返回原点 void LCD_Write(bit style, unsigned char input)
{
LcdEn=0;
LcdRs=style;
LcdRw=0; _nop_();
DBPort=input; _nop_();//注意顺序
LcdEn=1; _nop_();//注意顺序
LcdEn=0; _nop_();
LCD_Wait();
}
//设置显示模式
********************************************************
****
#define LCD_SHOW 0x04 //显示开 #define LCD_HIDE 0x00 //显示关
#define LCD_CURSOR 0x02 //显示光标 #define LCD_NO_CURSOR 0x00 //无光标
#define LCD_FLASH 0x01 //光标闪动 #define LCD_NO_FLASH 0x00 //光标不闪动
void LCD_SetDisplay(unsigned char DisplayMode)
{
LCD_Write(LCD_COMMAND, 0x08|DisplayMode);
}
//设置输入模式
********************************************************
第47页
****
#define LCD_AC_UP 0x02
#define LCD_AC_DOWN 0x00 // default
#define LCD_MOVE 0x01 // 画面可平移
#define LCD_NO_MOVE 0x00 //default
void LCD_SetInput(unsigned char InputMode)
{
LCD_Write(LCD_COMMAND, 0x04|InputMode);
}
//移动光标或屏幕
********************************************************
****
/*
#define LCD_CURSOR 0x02
#define LCD_SCREEN 0x08
#define LCD_LEFT 0x00
#define LCD_RIGHT 0x04
void LCD_Move(unsigned char object, unsigned char direction)
{
if(object==LCD_CURSOR)
LCD_Write(LCD_COMMAND,0x10|direction);
if(object==LCD_SCREEN)
LCD_Write(LCD_COMMAND,0x18|direction);
}
*/
//初始化
LCD*****************************************************
*******
void LCD_Initial()
{
LcdEn=0;
LCD_Write(LCD_COMMAND,0x38); //8位数据端口,2行
显示,5*7点阵
LCD_Write(LCD_COMMAND,0x38);
LCD_SetDisplay(LCD_SHOW|LCD_NO_CURSOR); //开启显示,
无光标
LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN); //清屏
LCD_SetInput(LCD_AC_UP|LCD_NO_MOVE); //AC递增, 画
面不动
第48页
}
//************************************************************************
void GotoXY(unsigned char x, unsigned char y)
{
if(y==0)
LCD_Write(LCD_COMMAND,0x80|x);
if(y==1)
LCD_Write(LCD_COMMAND,0x80|(x-0x40));
}
void Print(unsigned char *str)
{
while(*str!='\0')
{
LCD_Write(LCD_DATA,*str);
str++;
}
}
/*
void LCD_LoadChar(unsigned char user[8], unsigned char place) {
unsigned char i;
LCD_Write(LCD_COMMAND,0x40|(place*8));
for(i=0; i<8; i++)
LCD_Write(LCD_DATA,user[i]);
}
*/
//************************************************************************
//函数名称:setpin()
//函数功能:设置芯片的引脚,主要是电源地的变换
//函数输入:无
//函数输出:芯片型号
unsigned char setpin()
{
unsigned char chiptype=14,temp;
set14=0;//设置14脚地不接地
第49页
set16=0;//设置16脚地不接地
//判断是否为20脚,只有245为20脚
P16=1;
P2=0xaa;
P17=1;
P10=0;
if(P1==0xea&&P35==0&&P34==1&&P27==0)
chiptype=12;
else
{
set16=1;//设置16脚的电源地
P1=0xff;
P2=0xff;
P3=0xb0;
P16=0;
temp=P1;
if(temp==0xa0)
{
chiptype=13;
}
else
{
P14=1;
P10=0;
P27=1;
P14=0;
P10=1;
if(P27==0)
chiptype=11;
}
}
return chiptype;
}
//芯片型号粗略判别函数
//输出:芯片型号字
//调用:type();
unsigned char subtype1()
{
unsigned char temp,type;
P1=0xae;
第50页
temp=P1;
switch (temp)
{
case 0x8a :
type=3; //74xx08
break;
case 0x8c :
type=5; //74xx11
break;
case 0x8e :
type=7; //74xx21
break;
default :
type=14;
break;
}
return type;
}
//芯片型号粗略判别函数
//输出:芯片型号字
//调用:type();
unsigned char subtype2()
{
unsigned char temp,type;
P1=0xee;
temp=P1;
switch (temp)
{
case 0xee :
type=4; //74xx10
break;
case 0xcc :
type=8; //74xx27
break;
default :
type=14;
break;
}
return type;
}
第51页
//芯片型号粗略判别函数
//输出:芯片型号字
//调用:type();
unsigned char subtype3() {
unsigned char temp,type;
P1=0xbf;
temp=P1;
switch (temp)
{
case 0xbf :
type=9; //74xx30
break;
case 0x9f :
type=6; //74xx20
break;
default :
type=14;
break;
}
return type;
}
//芯片型号粗略判别函数
//输出:芯片型号字
unsigned char type() {
unsigned char temp,type;
P1=0xff;
P2=0x0f;
temp=P1;
switch (temp)
{
case 0xdb :
type=0; //74xx00
break;
case 0xb6 :
type=1; //74xx02
break;
case 0x55 :
type=2; //74xx04
第52页
break;
case 0xef:
type=10;//74xx74
break;
case 0xff :
type=subtype1();
break;
case 0xdd :
type=subtype2();
break;
case 0xdf :
type=subtype3();
break;
default :
type=14;
break;
}
return type;
}
//函数名称:dispresult()
//函数功能:实现芯片信息显示
//输入:好坏表示good,芯片标号 type
//输出:无
void dispresult(unsigned char good,unsigned char type) {
LCD_Write(LCD_COMMAND,LCD_CLEAR_SCREEN);//清屏
GotoXY(1,0);
Print(" TYPE:");
GotoXY(7,0);
Print(table[type]);
GotoXY(1,1);
Print("Result:");
GotoXY(8,1);
if(good)
Print("Good");
else
Print("Bad");
}
第53页
//函数名称:delayms()
//函数功能:实现粗略的毫秒延时 //输入:需要延时的毫秒数 最大65535 //输出:无
void delayms(unsigned int n)
{
unsigned char x;
for(x=114;x>0;x--)
for(;n>0;n--);
}
第54页