这个程序包含三个方面的知识:
1。4*4按键的部份--完成(0~9)数字键,功能键,字母键的输入;按键抬起后才能作用;
2。LCD12232的显示部份;串行显示,只用两根线,显示中英文字母及数字;
3。TTL系列芯片与CMOS系列芯片的知识,及做库;这部份还没完成;
我想第三步完成了,MM还符合一名合格的大学毕业生的;
哈!直接上代码了,下载地址:http://www.51hei.com/f/12232ch.rar
#include
#define uint unsigned int
#define uchar unsigned char
#define uchar unsigned char
sbit SID = P0^5 ;
sbit SCK = P0^6 ;
sbit BUZ = P0^7;
sbit A0 = P3^0;
sbit A1 = P3^1;
sbit A2 = P3^2;
sbit A3 = P3^3;
sbit A4 = P3^4;
sbit A5 = P3^5;
sbit SCK = P0^6 ;
sbit BUZ = P0^7;
sbit A0 = P3^0;
sbit A1 = P3^1;
sbit A2 = P3^2;
sbit A3 = P3^3;
sbit A4 = P3^4;
sbit A5 = P3^5;
sbit B0 = P0^0;
sbit B7 = P1^7;
sbit B6 = P1^6;
sbit B5 = P1^5;
sbit B4 = P1^4;
sbit B3 = P1^3;
sbit B2 = P1^2;
sbit B7 = P1^7;
sbit B6 = P1^6;
sbit B5 = P1^5;
sbit B4 = P1^4;
sbit B3 = P1^3;
sbit B2 = P1^2;
uchar Key_Select,Key_Mode;
uchar code Disp_1[]={"浙江师范大学行"};
uchar code Disp_2[]={"知学院电子信息"};
uchar code Disp_3[]={"工程08级毛梦超"};
uchar code Disp_4[]={"的毕业设计--集"};
uchar code Disp_5[]={"成电路测试系统!"};
uchar code Disp_6[]={"指导老师:丁宇"};
uchar code Disp_2[]={"知学院电子信息"};
uchar code Disp_3[]={"工程08级毛梦超"};
uchar code Disp_4[]={"的毕业设计--集"};
uchar code Disp_5[]={"成电路测试系统!"};
uchar code Disp_6[]={"指导老师:丁宇"};
uchar code Disp_7[]={"请插入芯片后按"};
uchar code Disp_8[]={"确认键进行测试!"};
uchar code Disp_9[]={"请选择芯片类型:"};
uchar code Disp_10[]={"1-CMOS; 2-TTL;"};
uchar code Disp_11[]={"请输入CMOS系列"};
uchar code Disp_12[]={"请输入TTL 系列"};
uchar code Disp_13[]={"IC型号:"};
uchar code Disp_8[]={"确认键进行测试!"};
uchar code Disp_9[]={"请选择芯片类型:"};
uchar code Disp_10[]={"1-CMOS; 2-TTL;"};
uchar code Disp_11[]={"请输入CMOS系列"};
uchar code Disp_12[]={"请输入TTL 系列"};
uchar code Disp_13[]={"IC型号:"};
//-----------------Delay_*2us-------------------
void Delay_us(uchar x2us)
{
while(--x2us);
}
void Delay_ms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=122;j>0;j--)
{}
}
//-------------4KHz-------------------
void Buz(void)
{
uint i;
for(i=200;i>0;i--)
{
BUZ=1;
Delay_us(120);
BUZ=0;
}
BUZ=0;
}
//-------------LCD Part--------------------
//LCD显示部份之写地址
//-----------------------------------------
void Lcd_Wr_Command(uchar com_data)
{
uchar i;
uchar i_data;
i_data=0xf8;
SCK=0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data<<=4;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
Delay_ms(1);
}
//-------------LCD Part--------------------
//LCD显示部份之写数据
//-----------------------------------------
void Lcd_Wr_Data(uchar com_data)
{
uchar i;
uchar i_data;
i_data=0xfa;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data<<=4;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
Delay_ms(1);
}
//-------------LCD Part--------------------
//LCD显示部份之初始化
//-----------------------------------------
void Lcd_init()
{
Delay_ms(100);
Lcd_Wr_Command(0x30);
Delay_ms(5);
Lcd_Wr_Command(0x02);
Delay_ms(5);
Lcd_Wr_Command(0x06);
Delay_ms(5);
Lcd_Wr_Command(0x0c);
Delay_ms(5);
Lcd_Wr_Command(0x01);
Delay_ms(5);
//Lcd_Wr_Command(0x80);
}
void Posit(uchar x,uchar y,uchar *String)
{
uchar Posit,Addr;
if(y==1)
Addr=0x80;
if(y==2)
Addr=0x90;
void Delay_us(uchar x2us)
{
while(--x2us);
}
void Delay_ms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=122;j>0;j--)
{}
}
//-------------4KHz-------------------
void Buz(void)
{
uint i;
for(i=200;i>0;i--)
{
BUZ=1;
Delay_us(120);
BUZ=0;
}
BUZ=0;
}
//-------------LCD Part--------------------
//LCD显示部份之写地址
//-----------------------------------------
void Lcd_Wr_Command(uchar com_data)
{
uchar i;
uchar i_data;
i_data=0xf8;
SCK=0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data<<=4;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
Delay_ms(1);
}
//-------------LCD Part--------------------
//LCD显示部份之写数据
//-----------------------------------------
void Lcd_Wr_Data(uchar com_data)
{
uchar i;
uchar i_data;
i_data=0xfa;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data&=0xf0;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
i_data=com_data;
i_data<<=4;
for(i=0;i<8;i++)
{
SID=(bit)(i_data&0x80);
SCK=0;
SCK=1;
i_data=i_data<<1;
}
Delay_ms(1);
}
//-------------LCD Part--------------------
//LCD显示部份之初始化
//-----------------------------------------
void Lcd_init()
{
Delay_ms(100);
Lcd_Wr_Command(0x30);
Delay_ms(5);
Lcd_Wr_Command(0x02);
Delay_ms(5);
Lcd_Wr_Command(0x06);
Delay_ms(5);
Lcd_Wr_Command(0x0c);
Delay_ms(5);
Lcd_Wr_Command(0x01);
Delay_ms(5);
//Lcd_Wr_Command(0x80);
}
void Posit(uchar x,uchar y,uchar *String)
{
uchar Posit,Addr;
if(y==1)
Addr=0x80;
if(y==2)
Addr=0x90;
Posit=Addr+x;
Lcd_Wr_Command(Posit);
while(*String!='
Lcd_Wr_Command(Posit);
while(*String!='