指纹识别模块程序及原理图.docx
- 文档编号:23329214
- 上传时间:2023-05-16
- 格式:DOCX
- 页数:52
- 大小:149.18KB
指纹识别模块程序及原理图.docx
《指纹识别模块程序及原理图.docx》由会员分享,可在线阅读,更多相关《指纹识别模块程序及原理图.docx(52页珍藏版)》请在冰豆网上搜索。
指纹识别模块程序及原理图
程序:
#include
#include
#defineucharunsignedchar
#defineuintunsignedint
#defineDbusP0
#definebuffer1ID0x01
#definebuffer2ID0x02
#definequeren0x88
#definetuichu0x84
#defineshanchu0x82
sbitB0=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;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;//启动定时器
}
{
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));//返回键编码
}
else
rcode=(rcode<<1)|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=shuazhiwen
case0x28:
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;
}
//清屏函数清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;i<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);
for(i=0;i<2;i++)WriteData(nian[i]);
y1=a[4]>>4;y2=a[4]&0x0f;
WriteData(0x30+y1);WriteData(0x30+y2);
for(i=0;i<2;i++)WriteData(yue[i]);
r1=a[3]>>4;r2=a[3]&0x0f;
WriteData(0x30+r1);WriteData(0x30+r2);
for(i=0;i<2;i++)WriteData(ri[i]);
WriteCommand(0x88);//指定第三行显示位置
for(i=0;i<4;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;i<8;i++)
{
B>>=1;
B7=IO;
SCLK=1;
SCLK=0;
}
returnB;
}
voidw1302(ucharco)//写ds1302单字节
{
uchari;
B=co;
for(i=0;i<8;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;i<8;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;i<7;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(TI==0);
TI=0;
SBUF=0X03;
while(TI==0);
TI=0;
SBUF=0X01;
while(TI==0);
TI=0;
SBUF=0X00;
while(TI==0);
TI=0;
summaf=0x05;
SBUF=summaf;
while(TI==0);
TI=0;
for(i=0;i<9;i++)
{
while(RI==0);
RI=0;}
while(RI==0);
RI=0;
querenma=SBUF;
while(RI==0);
RI=0;
sum[1]=SBUF;
while(RI==0);
RI=0;
sum[0]=SBUF;
summas=(sum[1]<<8)+sum[0];
}
voidSFG_genchar(ucharbufferID)//生成特征并存于charbuffer1/2调用后单片机波特率变化@@@
{
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(TI==0);
TI=0;
SBUF=0X04;
while(TI==0);
TI=0;
SBUF=0X02;
while(TI==0);
TI=0;
SBUF=bufferID;
while(TI==0);
TI=0;
summaf=0x07+bufferID;
sum[0]=summaf;
sum[1]=summaf>>8;
SBUF=sum[1];
while(TI==0)
TI=0;
SBUF=sum[0];
while(TI==0)
TI=0;
for(i=0;i<9;i++)
{
while(RI==0);
RI=0;}
while(RI==0);
RI=0;
querenma=SBUF;
while(RI==0);
RI=0;
sum[1]=SBUF;
while(RI==0);
RI=0;
sum[0]=SBUF;
summas=(sum[1]<<8)+sum[0];
}
voidSFG_regmodel()//合并生成模板
{
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(TI==0);
TI=0;
SBUF=0X03;
while(TI==0);
TI=0;
SBUF=0X05;
while(TI==0);
TI=0;
SBUF=0X00;
while(TI==0);
TI=0;
summaf=0x09;
SBUF=summaf;//校验和
while(TI==0);
TI=0;
for(i=0;i<9;i++)
{
while(RI==0);
RI=0;}
while(RI==0);
RI=0;
querenma=SBUF;
while(RI==0);
RI=0;
sum[1]=SBUF;
while(RI==0);
RI=0;
sum[0]=SBUF;
summas=(sum[1]<<8)+sum[0];
}
voidSFG_storechar(uintpageID)//储存模板ID=1010也储存成功ID>=1011querenma=0x18?
@@@
{
uchari,ID1,ID2;
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(TI==0);
TI=0;
SBUF=0X06;
while(TI==0);
TI=0;
SBUF=0X06;
while(TI==0);
TI=0;
SBUF=0X01;
while(TI==0);
TI=0;
ID1=pageID;ID2=pageID>>8;
SBUF=ID2;
while(TI==0);
TI=0;
SBUF=ID1;
while(TI==0);
TI=0;
summaf=0x0e+ID1+ID2;
sum[0]=summaf;
sum[1]=summaf>>8;
SBUF=sum[1];
while(TI==0);
TI=0;
SBUF=sum[0];
while(TI==0);
TI=0;
for(i=0;i<9;i++)
{
while(RI==0);
RI=0;}
while(RI==0);
RI=0;
querenma=SBUF;
while(RI==0);
RI=0;
sum[1]=SBUF;
while(RI==0);
RI=0;
sum[0]=SBUF;
summas=(sum[1]<<8)+sum[0];
}
voidSFG_empty()//清空指纹库
{
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(TI==0);
TI=0;
SBUF=0X03;
while(TI==0);
TI=0;
SBUF=0X0d;
while(TI==0);
TI=0;
SBUF=0X00;
while(TI==0);
TI=0;
summaf=0x11;
SBUF=summaf;
while(TI==0);
TI=0;
for(i=0;i<9;i++)
{
while(RI==0);
RI=0;}
while(RI==0);
RI=0;
querenma=SBUF;
while(RI==0);
RI=0;
sum[1]=SBUF;
while(RI==0);
RI=0;
sum[0]=SBUF;
summas=(sum[1]<<8)+sum[0];
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 指纹识别 模块 程序 原理图