预览加载中,请您耐心等待几秒...
1/10
2/10
3/10
4/10
5/10
6/10
7/10
8/10
9/10
10/10

亲,该文档总共43页,到这已经超出免费预览范围,如果喜欢就直接下载吧~

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

51篇51单片机第二十课PS2键盘键值解码所属类别:课程代码发布日期:2011-03-05点击量:383#include<reg52.h>#defineucharunsignedchar#defineuintunsignedintsbitpsdata=P3^0;sbitpsclk=P3^2;ucharnumbit;ucharkeyv;ucharkey[3];ucharkeynum;ucharm,n;unsignedcharcodesmg_du[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};unsignedcharcodesmg_we[]={0x08,0x18,0x28,0x38,0x48,0x58,0x68,0x78};//************************************************//延时函数,在12MHz的晶振频率下//大约50us的延时//************************************************voiddelay_50us(uintt){ucharj;for(;t>0;t--)for(j=19;j>0;j--);}//************************************************//延时函数,在12MHz的晶振频率下//大约50ms的延时//************************************************voiddelay_50ms(uintt){uintj;for(;t>0;t--)for(j=6245;j>0;j--);}voidmain(){IT0=1;//外部中断下降沿触发EX0=1;//打开外部中断0EA=1;//打开总中断while(1){if(keynum==3){keynum=0;//0x1cn=key[0]/16;m=key[0]%16;}P1=smg_du[m];P2=smg_we[0];delay_50us(20);P1=smg_du[n];P2=smg_we[1];delay_50us(20);}}voidint0()interrupt0{if((numbit>0)&&(numbit<9))//>>{keyv=keyv>>1;//001000000if(psdata)keyv=keyv|0x80;//10000000}//01numbit++;//0if(numbit>10){numbit=0;key[keynum]=keyv;keynum++;}}51单片机第二十三课实时时钟芯片DS1302的读写所属类别:课程代码发布日期:2011-03-05点击量:531#include<reg52.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbitsck=P1^0;sbitio=P1^1;sbitrst=P3^6;sbitsmgen=P2^3;unsignedcharcodesmg_du[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00,0x10};unsignedcharcodesmg_we[]={0x08,0x18,0x28,0x38,0x48,0x58,0x68,0x78};uchartime_data[7]={10,6,4,17,11,58,30};//年周月日时分秒ucharwrite_add[7]={0x8c,0x8a,0x88,0x86,0x84,0x82,0x80};ucharread_add[7]={0x8d,0x8b,0x89,0x87,0x85,0x83,0x81};uchardisp[8];voidwrite_ds1302_byte(uchardat);voidwrite_ds1302(ucharadd,uchardat);ucharread_ds1302(ucharadd);voidset_rtc(void);voidread_rtc(void);voidtime_pros(void);voiddisplay(void);//************************************************//延时函数,在12MHz的晶振频率下//大约50us的延时//************************************************voiddelay_5