指纹识别模块程序及原理图DOC34页文档格式.docx
《指纹识别模块程序及原理图DOC34页文档格式.docx》由会员分享,可在线阅读,更多相关《指纹识别模块程序及原理图DOC34页文档格式.docx(51页珍藏版)》请在冰豆网上搜索。
![指纹识别模块程序及原理图DOC34页文档格式.docx](https://file1.bdocx.com/fileroot1/2023-2/4/5af5fb98-0ac4-4ad7-a0d4-0ac27facbb40/5af5fb98-0ac4-4ad7-a0d4-0ac27facbb401.gif)
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;
i<
125;
i++);
}
}
voidinitialize51()
{
SCON=0x50;
//串口方式1//REN=1;
允许接收
PCON=0x80;
//SMOD=1
TMOD=0x20;
//定时器1定时方式2
TH1=0xff;
//11.0592MHz模块默认波特率为57600bps
TL1=0xff;
TR1=1;
//启动定时器
unsignedcharKeycan(void)//按键扫描程序P1.0--P1.3为行线P1.4--P1.7为列线
unsignedcharrcode,ccode;
P1=0xF0;
//发全0行扫描码,列线输入
if((P1&
0xF0)!
=0xF0)//若有键按下
delay
(1);
//延时去抖动
=0xF0)
{rcode=0xFE;
//逐行扫描初值
while((rcode&
0x10)!
=0)
P1=rcode;
//输出行扫描码
=0xF0)//本行有键按下
ccode=(P1&
0xF0)|0x0F;
//do{;
while((P1&
=0xF0);
//等待键释放
return((~rcode)+(~ccode));
//返回键编码
else
rcode=(rcode<
<
1)|0x01;
//行扫描码左移一位
}
return0;
//无键按下,返回值为0
voidKeyDeal(unsignedcharKey)
{//unsignedcharn;
if(Key!
=0)
switch(Key)
case0x11:
K=1;
break;
case0x21:
K=2;
case0x41:
K=3;
case0x81:
//K=funguanliyuan;
case0x12:
K=4;
case0x22:
K=5;
case0x42:
K=6;
case0x82:
K=34;
break;
//K=funshanchu;
case0x14:
K=7;
case0x24:
K=8;
case0x44:
K=9;
case0x84:
//K=funtuichu;
case0x18:
//K=shuazhiwen
case0x28:
K=0;
case0x48:
case0x88:
//K=funqueren;
default:
//*************************************//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;
//向LCD写数据
voidWriteData(ucharLcd_data)
RS=1;
Dbus=Lcd_data;
//清屏函数清DDRAM
voidClrram(void)
WriteCommand(0x01);
//LCD12864初始化程序
voidLcd_int()
WriteCommand(0x30);
//30---基本指令动作
WriteCommand(0x0c);
//开显示,关游标
WriteCommand(0x01);
//清屏,地址指针指向00H
WriteCommand(0x02);
//LCD12864显示时间
voidplaytime()
uchari,n3,n4,y1,y2,r1,r2,s1,s2,f1,f2,m1,m2;
WriteCommand(0x80);
//指定第一行显示位置
for(i=0;
16;
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);
2;
i++)WriteData(nian[i]);
y1=a[4]>
y2=a[4]&
WriteData(0x30+y1);
WriteData(0x30+y2);
i++)WriteData(yue[i]);
r1=a[3]>
r2=a[3]&
WriteData(0x30+r1);
WriteData(0x30+r2);
i++)WriteData(ri[i]);
WriteCommand(0x88);
//指定第三行显示位置
i++)WriteData(xinqi[i]);
WriteData(a[5]+0x30);
s1=a[2]>
s2=a[2]&
f1=a[1]>
f2=a[1]&
m1=a[0]>
m2=a[0]&
WriteCommand(0x98);
//指定第四行显示位置
WriteData(0x30+s1);
WriteData(0x30+s2);
WriteData(mao);
WriteData(0x30+f1);
WriteData(0x30+f2);
WriteData(0x30+m1);
WriteData(0x30+m2);
//*********************************//ds1302控制
ucharr1302()//读数据ds1302
{uchari;
8;
B>
=1;
B7=IO;
SCLK=1;
SCLK=0;
returnB;
voidw1302(ucharco)//写ds1302单字节
{
uchari;
B=co;
IO=B0;
//原来是使用ACC寄存器,但不行,后改使用B寄存器后才正常运行?
?
voidw(uchara,uchard)//寻址,写数
RST=0;
SCLK=0;
RST=1;
w1302(a);
w1302(d);
SCLK=1;
ucharr(uchara)//寻址,读数
ucharr;
r=r1302();
returnr;
voidwclo(uchar*p)//写多字节ds1302
uchari;
w(0x8e,0x00);
//写允许
RST=0;
RST=1;
w1302(0xbe);
//写多字节命令
w1302(*(p+i));
//写时钟数据
w(0x00,0x50);
//?
启动定时器
SCLK=1;
RST=0;
voidrclo(uchar*p)//读出多字节ds1302
w1302(0xbf);
7;
*(p+i)=r1302();
//读出时钟数据
//***************************************//
voidSFG_getimage()//录入指纹图像
SBUF=0xef;
while(TI==0);
TI=0;
SBUF=0X01;
SBUF=0XFF;
SBUF=0X00;
SBUF=0X03;
summaf=0x05;
SBUF=summaf;
9;
while(RI==0);
RI=0;
querenma=SBUF;
sum[1]=SBUF;
sum[0]=SBUF;
summas=(sum[1]<
8)+sum[0];
voidSFG_genchar(ucharbufferID)//生成特征并存于charbuffer1/2调用后单片机波特率变化@@@
SBUF=0X04;
SBUF=0X02;
SBUF=bufferID;
summaf=0x07+bufferID;
sum[0]=summaf;
sum[1]=summaf>
SBUF=sum[1];
while(TI==0)
SBUF=sum[0];
voidSFG_regmodel()//合并生成模板
SBUF=0X05;
summaf=0x09;
//校验和
voidSFG_storechar(uintpageID)//储存模板ID=1010也储存成功ID>
=1011querenma=0x18?
@@@
uchari,ID1,ID2;
SBUF=0X06;
ID1=pageID;
ID2=pageID>
SBUF=ID2;
SBUF=ID1;
summaf=0x0e+ID1+ID2;
voidSFG_empty()//清空指纹库
SBUF=0X0d;
summaf=0x11;
voidSFG_fastsearch(ucharbufferID)//搜索指纹返回指纹ID号sum、pagenum>
255都会使程序卡@@@