Microcontroller › 8051 › Assembly Language oF ELECRTONIC CODE LOCK PROJECT
- This topic has 5 replies, 2 voices, and was last updated 13 years, 7 months ago by dagakshay.
-
AuthorPosts
-
April 27, 2011 at 2:01 pm #886SaLMAN Ahmed KhanParticipant
HELLOO BROS !!! I HAVE A BIG BUGS IN MY PROGRAMING RELATED TO ELECTRONIC CODE LOCK THAT IS ALSO HERE IN WEBSITE BUT I HAVE MADE WITH ASSEMBLY LANG.PLZ FINDOUT MY BUGS SPECIALLY ON KEYPAD PROGRAM
BECAUSE AT THERE IM FACING PROBLEM..
;SALMAN AHMED KHAN 019LCD DATA P2 ;define LCD data port on port 2KEYPAD DATA P0 ;define KEYPAD dataport on port 1ORG 00HMOV DPTR,#MYCOMSALMAN:CLR AMOVC A,@A+DPTRJZ SEND_DATAACALL COMNWRT ; ////CALL COMMAND FOR LCDACALL DELAYINC DPTRSJMP SALMANSEND_DATA:MOV DPTR,#MYDATAD1: CLR AMOVC A,@A+DPTRACALL DATAWORDACALL DELAYINC DPTRJZ AGAINSJMP D1AGAIN: SJMP AGAINCOMNWRT:MOV LCD,ACLR P1.0 ;//////////RS=0 FOR COMMANDCLR P1.1 ;//////////R/W=O FOR WRITESETB P1.2;//////////E=1 FOR HIGH PULSECLR P1.2;/////////// E=0 H TO LACALL DELAYRETDATAWORD:MOV LCD,ASETB P1.0 ;//////////RS=0 FOR COMMAND//CLR P1.0 ;//////////R/W=O FOR WRITESETB P1.2;//////////E=1 FOR HIGH PULSECLR P1.2;////////// enable is to set & then cleard when data/command to be WRITTEN! i.e H-to-L pulse to be given.ACALL DELAYRETDELAY:MOV R6,#100DL1: MOV R7,#10DJNZ R7,$DJNZ R6,DL1RET;======SAVING PASSWORD IN MEMORY 0RG 200H======mov DPTR,#MYPASSsak:clr amovc A,@A+DPTRinc dptrjz keypad1sjmp sak;========Interfacing Keypad====================keypad1:mov KEYPAD,#0FFH ;make P1 an input portSAK2: mov keypad,#00h ;ground all rows at onnceMOV A,KEYPAD ;read all col. (ensure all keys open)ANL A,00001111B ;masked unused bitsCJNE A,#00001111B,SAK2 ;check til all keys releasedSAK3: ACALL DELAY ;call 20 msec delayMOV A,KEYPAD ;see if any key is pressedANL A,#00001111B ;mask unused bitsCJNE A,#00001111B,OVER ;key pressed, await closureSJMP SAK3 ;check il key pressedOVER: ACALL DELAY ;wait 20 msec debounce timeMOV A,KEYPAD ;check key closureANL A,#00001111B ;mask unused bitsCJNE A,#00001111B,OVER1;key pressed, find rowSJMP SAK3 ;if none, keep pollingOVER1: MOV KEYPAD,#11111110B ;gound row 0ANL A,#00001111B ;mask unused bitsCJNE A,#00001111B,ROW_0;key row 0, find the col.MOV KEYPAD,#11111101B ;ground row 1ANL A,#00001111B ;mask unused bitsCJNE A,#00001111B,ROW_1;keyrow 1, find the col.MOV KEYPAD,#11111011B ;ground row 2ANL A,#00001111B ;mask unused bitsCJNE A,#00001111B,ROW_2;key row 2, find the col.MOV P1,#11110111B ;ground row 3ANL A,#00001111B ;mask unused bitsCJNE A,#00001111B,ROW_3;keyrow 3, find the col.LJMP SAK3 ;if none, false input, repeatROW_0: MOV DPTR,#KCODE0 ;set DPTR=start of row 0SJMP FIND ;find col. key belongs toROW_1: MOV DPTR,#KCODE1 ;set DPTR=start of row 1SJMP FIND ;find col. key belongs toROW_2: MOV DPTR,#KCODE2 ;set DPTR=start of row 2SJMP FIND ;find col. key belongs toROW_3: MOV DPTR,#KCODE3 ;set DPTR=start of row 3FIND: RRC A ;see if any CY bit lowJNC MATCH ;if zero, get the ASCII codeINC DPTR ;point to next col. addressSJMP FIND ;keep searchingMATCH: CLR A ;set A=0 (match is found)MOVC A,@A+DPTR ;get ASCII code from tableMOV P2,A ;display pressed keyACALL COMNWRT ; ////CALL COMMAND FOR LCD for displaying keypadACALL DATAWORD;LJMP SAK2JZ MATCHPASSSMATCHPASSS:CJNE A,#2431,X1SEND_PASS:MOV DPTR,#MSG1D4:CLR A // ‘D1’ was written in thee previous line, making the dptr load with default value, thus error in commnad valuesMOVC A,@A+DPTRACALL DATAWORDACALL DELAYINC DPTRJZ AGAIN2sjmp D4AGAIN2: SJMP AGAIN2RETX1:MOV DPTR,#MSG2D5:CLR A // ‘D1’ was written in thee previous line, making the dptr load with default value, thus error in commnad valuesMOVC A,@A+DPTRACALL DATAWORDACALL DELAYINC DPTRSJMP D5AGAIN1: SJMP AGAIN1RETACALL COMNWRTACALL DATAWORDRET;ASCII LOOK-UP TABLE FOR EACH ROWORG 400HKCODE0: DB ‘1’,’2′,’3′ ;ROW 0KCODE1: DB ‘4’,’5′,’6′ ;ROW 1KCODE2: DB ‘7’,’8′,’9′ ;ROW 2KCODE3: DB ‘*’,’0′,’#’ ;ROW 3ORG 100HMYCOM: DB 38H,0FH,06H,02H,01H,0MYDATA: DB “ENTER PASSWORD”,0MYCOM1: DB 38H,0C0H,0FH,06H,01H,0ORG 200HMYPASS: DB “2431”,0org 500HMSG1: DB “CORRECT”MSG2: DB “WRONG”ENDApril 28, 2011 at 5:59 am #6052dagakshayParticipanthello salman…
please do past the error you getting…
i always feel c to be very easy language then the asm. but ya of effiency of code you can switch for asm.
if you have a c code for the program just go to the link it might help you out…
http://www.engineersgarage.com/forums/8051/c-code-assembly-code
April 28, 2011 at 11:02 am #6056SaLMAN Ahmed KhanParticipanthelloo dagakshay
well there is no errror in this prog when u run it on keil there is no error only bugsss because when i run this on PROTEUS it doesnt work accordin to theme…..if u could tell me in assembly that will be easy because the task given to me is to do programing iN aSSEMBLY……..
April 29, 2011 at 5:12 am #6057dagakshayParticipanthello salman,
i don’t know asm code much…
April 29, 2011 at 5:41 pm #6061SaLMAN Ahmed KhanParticipantOK, HOW MUCH DELAY HAVE U GIVEN IN THIS TO LCD AND KEYPAD IN C LANG???
April 30, 2011 at 6:51 am #6063dagakshayParticipanthello salman these are not mine codes…
do send the link i will lok at code and let you know
i am a EG labs fan like you….
-
AuthorPosts
- You must be logged in to reply to this topic.