【正文】
MOV IP, 02H 。PT0=1, Timer039。s interrupt high priority SETB LOOP: DJNZ R5,$Y2:DJNZ R4 ,LOOP DJNZ 30H, Y2 CLR SETB 。close before out CLR EX1 CLR TR0 SJMP LOOGETKEY: 。 interrupt 2 send out the key PUSH ACC PUSH PSW CLR EX1AG: CALL DELAY MOV A,P1。 ANL A ,3cH 。keey the bit of 2,3,4and5 CJNE A,3cH,READKEY 。 test the press key is a dithering or the true LJMP EXITREADKEY: CPL A ANL A,3CH SETB TR0 MOV R0,0ffH MOV SBUF,R0 JNB TI,$ CLR TI MOV R1,0aaH MOV SBUF,R1 JNB TI,$ CLR TI MOV R2,55H MOV SBUF,R2 JNB TI,$ CLR TI MOV R3,03H MOV SBUF,R3 JNB TI,$ CLR TI MOV SBUF,A JNB TI,$ CLR TI MOV A,P1 ANL A ,3cH CJNE A,3cH,AG 。until there are no keys press downEXIT: SETB EX1 POP PSW POP ACC RETIS38KHz: 。interrupt 1 produce 38KHz carrier wave signal CPL RETI dactylogram: 。 interrupt 0 fingerprint the same as teh wave decode PUSH ACC PUSH PSW CLR EA 。hereinafter is the begining of dactylogram decode program CLR EA 。close all the interrupt for a while MOV R6,10CHECKLOW13ms: ACALL DELAY1 JB ,EXIT 。 after delay to check the footprint change to 。high voltage or not,if change exit the decode program DJNZ R6, CHECKLOW13ms 。repeat tenth hereinbefore step JNB , $ 。waiting change to high voltage to escape the low voltage MOV R7,8 。neglect the begining 8 bit system identify codeADDRESSCODE: JNB ,$ 。waiting the first bit of the addresscode change to 1 LCALL DELAY2 。after 1 delay and then check 39。s estate MOV C, 。move footpint39。s estate into memory C JNC AGAIN 。if check the 0 jump to AGAIN LCALL DELAY3 。if check the 1,delay ,until the 1 endAGAIN: DJNZ R7,ADDRESSCODE MOV R1,70H 。made the 70H as RAM MOV R3,4 。every group data is 4 bitDATACODE: JNB ,$ 。waiting the first bit of the datacode change to high voltage LCALL DELAY2 。after high voltage delay and then check 39。s estate MOV C, 。move footpint39。s estate into memory C JNC AGAIN1 。if C is 0 jump to AGAIN1 LCALL DELAY3 。if C is 1,delay ,until the 1 endAGAIN1: MOV A,@R1 。move R139。s address to A RRC A 。move the code 0 or 1 in the C to the A39。s low bit MOV @R1,A 。the code in A briefly keep in the data of R139。s memory DJNZ R3,DATACODE 。receive 4 bit send the code MOV A,70H CJNE A,01H,T1 。 if nit equal meaning there is not the right code SETB EX1 SJMP EXIT1T1:CJNE A,02H,EXIT1 SETB 。 this is the end of dactylogram decode program SETB EX1 MOV 30H,80H MOV R4,255 MOV R5,255EXIT1: SETB EA POP PSW POP ACC RETI DELAY: MOV R6 ,10D0:MOV R7,255 DJNZ R7,$ DJNZ R6,D0 RETDELAY1: 。accurately DELAY (in fact is ms) MOV R4,6D1: MOV R5,104 DJNZ R5,$ DJNZ R4,D2 RETDELAY2: 。accurately DELAY (in fact is ) MOV R4,7D2: MOV R5,235 DJNZ R5,$ DJNZ R4,D2 RETDELAY3: 。accurately DELAY 900us (in fact is 897us ) MOV R4,2 D3: MOV R5,205 DJNZ R5,$ DJNZ R4,D3 RETEND。******************** **********************2 接收程序。******************** **********************include include define Tick 54000 // 54000 x = 15sdefine T277us (2560) // time constant ()unsigned int C15s。 // 15s counting unildefine uchar unsigned charinclude include uchar password。 //define password memory unilunsigned int tt。 //定時(shí)中斷次數(shù)define interrupt timebit write=0。 //the flag of write 24C02 uchar R0。 uchar R1。 uchar R2。 uchar R3。 uchar ch。sbit P1_2=P1^2。sbit P1_3=P1^3。sbit P1_4=P1^4。sbit P1_5=P1^5。sbit scl=P1^6。 // 24c02 SCLsbit sda=P1^7。 // 24c02 SDA void delay(){ uchar i。 for(i=0。i55。i++) { _nop_()。 _nop_()。 }} /////////the beginning driver of 24C02 ////////////////////void delay1(unsigned char x){ unsigned int i。 for(i=0。ix。i++)。 。}void flash() //延時(shí)2us{ 。 。 }void x24c02_init() // the initialization of 24C02{ scl=1。 flash()。 sda=1。 flash()。}void start() // start the I2C bus{ sda=1。 flash()。 scl=1。 flash()。 sda=0。 flash()。 scl=0。 flash()。}void stop() // stop the I2C bus{ sda=0。 flash()。 scl=1。 flash()。 sda=1。 flash()。}void writex(unsigned char j) // write a byte{ unsigned char i,temp。 temp=j。 for (i=0。i8。i++) { temp=temp1。 scl=0。 flash()。 sda=CY。 flash()。 scl=1。 flash()。 } scl=0。 flash()。 sda=1。 flash()。}uchar readx() // read a byte{ unsigned char i,j,k=0。 scl=0。 flash()。 sda=1。 for (i=0。i8。i++) { flash()。 scl=1。 flash()。 if (sda==1) j=1。 else j=0。 k=(k1)|j。 scl=0。 } flash()。 return(k)。}void clock() // I2Cbus clock{ unsigned char i=0。 scl=1。 flash()。 while ((sda==1)amp。amp。(i255))i++。 scl=0。 flash()。}//////// Read a byte data from the address of 24C02/////unsigned char x24c02_read(unsigned char address){ unsigned char i。 start()。 writex(0xa0)。 clock()。 writex(address)。 clock()。 start()。 writex(0xa1)。 clock()。 i=readx()。 stop()。 delay1(10)。 return(i)。}////// write a byte data “info” to the address of 24C02/////void x24c02_write(unsigned char address,unsigned char info){ EA=0。 start()。 writex(0xa0)。 clock()。 writex(address)。 clock()。 writex(inf