Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/15/10 18:14
Read: times


 
#175066 - Problem with succesive memory locations
I have a problem saving 4 valuew that i get from a keypad.

When i press a button from the keypad, it appears on the second line of the lcd a *. That's happening until i press 4 buttons. After i press the last button and the 4th * appears, the program waits until i press the * button of the keypad. Then it compares the keys i've pressed with 4 values stated at the beginning of the program. If the password is correct it has to appear the string text "ALARM ON". If the password is wrong it has to appear the string text "WRONG PASS".

I have declared 40h to 43h with 00h in the beginning of the program. The button of the keypad that has zero 0 for code is button 1. The problem is that i press 4 times the 1 buttonm but i get the "WRONG PASS" message, instead of "ALARM ON".

Here is the part of the code



mov R1,#90h
PSIFIO2:
DELAY10: MOV R6,#0C3h ; delay for the keys to be pressed
DELAY11: MOV R7,#0FFh
DELAY21: NOP
NOP
DJNZ R7,DELAY21
DJNZ R6,DELAY11



mov A,#0h
call SCAN2 ; scan2 is the routine that scans the keypad
MOV A,R5
CJNE A,#0FFh,ELEGXOSPSIFIOU2 ; check if any key has been pressed and jump to ELEGXOSPSIFIOU2
JMP PSIFIO2 ; ;if no key has been pressed jump to psifio2 and scan again.



ELEGXOSPSIFIOU2:
MOV 96h,R5 ; Put the code of the key that has benn pressed, at memory location 96h

MOV A,34h ; Put in A 04h (has been declared before). A counter to check if it's the 4th digit of the password
CJNE A,#04h,GRAPSE2 ; Check if it's the 4th key that has been pressed. Go to Grapse 2
TELOS2: JMP ENTER2 ; OR ENTER2


GRAPSE2:      INC CURSPOS ;move cursor one position
              CALL POSIT_CURSOR   ; on the lcd
              MOV A,#2Ah		
              CALL LCDCHAR ; Show  * character on the lcd
	      INC 34h ; increase the pressed key counter
	      INC R1 ; show the next memory location, in which the code of the next pressed key will be saved 
	      
	      MOV @R1,96h ; put the code of the pressed key in the memory location that is in R1
	      JMP PSIFIO2 ; Go back to scan again

ENTER2:

		CALL SCAN2 ; call the scan keypad routine
		mov A, R5       ; put the code of the pressed key to A
	        CJNE A,#03h,ENTER2 ; wait until * key is pressed
		
ELEGXOSCODE1:    

		MOV A,91h ; put in A the code of the first pressed key
		CJNE A,40h,WRONGPASS ; if it isn't 0, go to wrongpass routine
		MOV A,92h ; if it is 0 continue and compare the next pressed key with 0
		CJNE A,41h,WRONGPASS ; if it isn't 0, go to wrongpass routine
		MOV A,93h ;if it is 0 continue and compare the next pressed key with 0
		CJNE A,42h,WRONGPASS ;if it isn't 0, go to wrongpass routine
		MOV A,94h ;if it is 0 continue and compare the next pressed key with 0
		CJNE A,43H,WRONGPASS  ;if it isn't 0, go to wrongpass routine
		CALL LCDCLS	;CLEAR SCREEN
                MOV CURSPOS,#4 ;put cursor in the first row of the lcd
                CALL POSIT_CURSOR   
		MOV DPTR,#STRING4	; show ALARM ON message
		CALL LCDSTR
JMP HALT

WRONGPASS: 
		CALL LCDCLS	;clear screen
		MOV CURSPOS,#4 ;put cursor in the first row of the lcd
		CALL POSIT_CURSOR   ; 
		MOV DPTR,#STRING5	;show wrong pass message
		CALL LCDSTR	



HALT: JMP HALT


STRING1:
DB ' ALARM OFF ' ,0

STRING2:
DB ' GIVE PASS ' ,0

STRING3:
DB ' GIVE OLD PASS ' ,0

STRING4:
DB ' ALARM ON ' ,0

STRING5:
DB ' WRONG PASS ' ,0
END
 
 



Can anybody help?

List of 12 messages in thread
TopicAuthorDate
Problem with succesive memory locations            01/01/70 00:00      
   Debugging            01/01/70 00:00      
      How can i see the code of pressed key            01/01/70 00:00      
         Turn them into ASCII            01/01/70 00:00      
         Or use 2 characters            01/01/70 00:00      
   direct access to >80h => SFR            01/01/70 00:00      
   incorrect addressing method            01/01/70 00:00      
      (back to) basics - "bible" time            01/01/70 00:00      
      Hal Albach's way            01/01/70 00:00      
         It works            01/01/70 00:00      
         You are not showing enough            01/01/70 00:00      
   the danger of uniformity            01/01/70 00:00      

Back to Subject List