?? 22.c
字號:
#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位數(shù)碼管 //
unsigned char LED[]={
10,11,17,18,1,13
};
// 設(shè)置顯示字符 //
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
};
// 延時(shí)子程序 //
void delay(long time)
{
while(time--);
}
// test數(shù)組為測試數(shù)組 retu數(shù)組為檢測數(shù)組 //
// 檢測程序一般為查表檢測 //
// 按表test發(fā)送檢測信號 檢測返回信號對表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 */
/* 輸入輸出信號設(shè)置 */
/****************************************************/
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;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -