您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > AI人工智能 > 指纹识别模块程序及原理图(DOC34页)
程序:#includereg52.h#includeintrins.h#defineucharunsignedchar#defineuintunsignedint#defineDbusP0#definebuffer1ID0x01#definebuffer2ID0x02#definequeren0x88#definetuichu0x84#defineshanchu0x82sbitB0=B^0;sbitB7=B^7;sbitjidianqi=P3^6;sbitRS=P2^2;sbitRW=P2^1;sbitE1=P2^0;sbitLEDK=P3^4;//控制背光sbitSCLK=P2^3;sbitIO=P2^5;sbitRST=P2^4;ucharcodeta[8]={0x00,0x51,0x09,0x10,0x05,0x02,0x11,0xbe};uchardataa[7];//秒分时日月星期年uchardz[4];//存键输入值ucharmima[7];ucharmimaID[6]={1,2,3,4,5,6};uchardataK;uchardataKey;uintPageID;uchardataquerenma;ucharsum[2];intsummaf,summas;ucharcodenian[]={年};ucharcodeyue[]={月};ucharcoderi[]={日};ucharcodexinqi[]={星期};ucharcodemao=0x3a;unsignedcharcodetext1[]={请按指纹};unsignedcharcodetext2[]={请再次按指纹};unsignedcharcodetext3[]={指纹采集成功};unsignedcharcodetext4[]={请按任意键继续};unsignedcharcodetext5[]={指纹采集失败};unsignedcharcodetext6[]={输入删去的指纹号};unsignedcharcodetext7[]={删指纹号成功};unsignedcharcodetext8[]={按键一:增加指纹};unsignedcharcodetext9[]={按键二:删去指纹};unsignedcharcodetext10[]={请重新按指纹};unsignedcharcodetext11[]={清空指纹库成功};unsignedcharcodetext12[]={没搜索到指纹};unsignedcharcodetext13[]={请先按键再刷指纹};unsignedcharcodetext14[]={请重新操作};unsignedcharcodetext15[]={删去失败};unsignedcharcodetext16[]={接收包出错};unsignedcharcodetext17[]={编号为:};unsignedcharcodetext18[]={指纹已找到请进};unsignedcharcodetext19[]={该指纹已存储};unsignedcharcodetext20[]={请输入密码};unsignedcharcodetext21[]={密码错误};unsignedcharcodetext22[]={按键三:更新密码};//@@@unsignedcharcodetext23[]={请再次输入密码};unsignedcharcodetext24[]={两次输入的密码不};unsignedcharcodetext25[]={一致,请重新操作};unsignedcharcodetext26[]={密码更新成功};另外:voiddelay(uinttt){uchari;while(tt--){for(i=0;i125;i++);}}voidinitialize51(){SCON=0x50;//串口方式1//REN=1;允许接收PCON=0x80;//SMOD=1TMOD=0x20;//定时器1定时方式2TH1=0xff;//11.0592MHz模块默认波特率为57600bpsTL1=0xff;TR1=1;//启动定时器}unsignedcharKeycan(void)//按键扫描程序P1.0--P1.3为行线P1.4--P1.7为列线{unsignedcharrcode,ccode;P1=0xF0;//发全0行扫描码,列线输入if((P1&0xF0)!=0xF0)//若有键按下{delay(1);//延时去抖动if((P1&0xF0)!=0xF0){rcode=0xFE;//逐行扫描初值while((rcode&0x10)!=0){P1=rcode;//输出行扫描码if((P1&0xF0)!=0xF0)//本行有键按下{ccode=(P1&0xF0)|0x0F;//do{;}while((P1&0xF0)!=0xF0);//等待键释放return((~rcode)+(~ccode));//返回键编码}elsercode=(rcode1)|0x01;//行扫描码左移一位}}}return0;//无键按下,返回值为0}voidKeyDeal(unsignedcharKey){//unsignedcharn;if(Key!=0){switch(Key){case0x11:K=1;break;case0x21:K=2;break;case0x41:K=3;break;case0x81:break;//K=funguanliyuan;case0x12:K=4;break;case0x22:K=5;break;case0x42:K=6;break;case0x82:K=34;break;//K=funshanchu;case0x14:K=7;break;case0x24:K=8;break;case0x44:K=9;break;case0x84:break;//K=funtuichu;case0x18:break;//K=shuazhiwencase0x28:K=0;break;case0x48:break;case0x88:break;//K=funqueren;default:break;}}}//*************************************//12864//读12864忙voidReadBusy(void){unsignedcharch;cheak:Dbus=0xff;RS=0;RW=1;E1=1;ch=Dbus;E1=0;ch=ch|0x7f;if(ch!=0x7f)gotocheak;}//向LCD写命令voidWriteCommand(ucharcommand){ReadBusy();RW=0;Dbus=command;E1=1;E1=0;}//向LCD写数据voidWriteData(ucharLcd_data){ReadBusy();RS=1;RW=0;Dbus=Lcd_data;E1=1;E1=0;}//清屏函数清DDRAMvoidClrram(void){WriteCommand(0x01);}//LCD12864初始化程序voidLcd_int(){WriteCommand(0x30);//30---基本指令动作WriteCommand(0x0c);//开显示,关游标WriteCommand(0x01);//清屏,地址指针指向00HWriteCommand(0x02);}//LCD12864显示时间voidplaytime(){uchari,n3,n4,y1,y2,r1,r2,s1,s2,f1,f2,m1,m2;WriteCommand(0x80);//指定第一行显示位置for(i=0;i16;i++)WriteData(text13[i]);//显示LCD12864并行显示n3=a[6]4;n4=a[6]&0x0f;WriteCommand(0x90);//指定第二行显示位置WriteData(0x32);WriteData(0x30);WriteData(0x30+n3);WriteData(0x30+n4);for(i=0;i2;i++)WriteData(nian[i]);y1=a[4]4;y2=a[4]&0x0f;WriteData(0x30+y1);WriteData(0x30+y2);for(i=0;i2;i++)WriteData(yue[i]);r1=a[3]4;r2=a[3]&0x0f;WriteData(0x30+r1);WriteData(0x30+r2);for(i=0;i2;i++)WriteData(ri[i]);WriteCommand(0x88);//指定第三行显示位置for(i=0;i4;i++)WriteData(xinqi[i]);WriteData(a[5]+0x30);s1=a[2]4;s2=a[2]&0x0f;f1=a[1]4;f2=a[1]&0x0f;m1=a[0]4;m2=a[0]&0x0f;WriteCommand(0x98);//指定第四行显示位置WriteData(0x30+s1);WriteData(0x30+s2);WriteData(mao);WriteData(0x30+f1);WriteData(0x30+f2);WriteData(mao);WriteData(0x30+m1);WriteData(0x30+m2);}//*************************************//12864//*********************************//ds1302控制ucharr1302()//读数据ds1302{uchari;for(i=0;i8;i++){B=1;B7=IO;SCLK=1;SCLK=0;}returnB;}voidw1302(ucharco)//写ds1302单字节{uchari;B=co;for(i=0;i8;i++){IO=B0;//原来是使用ACC寄存器,但不行,后改使用B寄存器后才正常运行???SCLK=1;SCLK=0;B=1;}}voidw(uchara,uchard)//寻址,写数{RST=0;SCLK=0;RST=1;w1302(a);w1302(d);SCLK=1;RST=0;}ucharr(uchara)//寻址,读数{ucharr;RST=0;SCLK=0;RST=1;w1302(a);r=r1302();SCLK=1;RST=0;returnr;}voidwclo(uchar*p)//写多字节ds1302{uchari;w(0x8e,0x00);//写允许RST=0;SCLK=0;RST=1;w1302(0xbe);//写多字节命令for(i=0;i8;i++)w1302(*(p+i));//写时钟数据w(0x00,0x50);//???启动定时器SCLK=1;RST=0;}voidrclo(uchar*p)//读出多字节ds1302{uchari;RST=0;SCLK=0;RST=1;w1302(0xbf);for(i=0;i7;i++)*(p+i)=r1302();//读出时钟数据SCLK=1;RST=0;}//***************************************//voidSFG_getimage()//录入指纹图像{uchari;SBUF=0xef;while(TI==0);TI=0;SBUF=0X01;while(TI==0);TI=0;SBUF=0XFF;while(TI==0);TI=0;SBUF=0XFF;while(TI==0);TI=0;SBUF=0XFF;while(TI==0);TI=0;SBUF=0XFF;while(TI==0);TI=0;SBUF=0X01;while(TI==0);TI=0;SBUF=0X00;while(T
本文标题:指纹识别模块程序及原理图(DOC34页)
链接地址:https://www.777doc.com/doc-29366 .html