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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/30/09 22:18
Read: times


 
#172050 - Err
Responding to: ???'s previous message
;//THIS IS A PRGRAM THAT DISPLAYS THE NUMBER THAT IS PRESSED ON THE KEYPAD ON THE LCD
;//***********************************************************************************

;//==========================================
;	LCD IS USING PORT 1 & 2
;	KEYPAD IS USING PORT 3
;//==========================================
               			
	         ORG 0
		 LJMP MAIN	;BYPASS INTERRUPT VECTOR TABLE
		
		;///MAIN PROGRAM///
		
		ORG 100H
		
		RS EQU P2.0
		RW EQU P2.1
		EN EQU P2.2

				
MAIN:		MOV SP,#256-32	;DEFINE STACK 32BYTES
		MOV P3,#0FFh	; CONFIGURE LOWER NIBBLE OF P3
				
		;INITIALIZATION START FOR LCD
		MOV A,#038H             
                LCALL COMW
                MOV A,#00CH
                LCALL COMW
                MOV A,#001H
                LCALL COMW
                MOV A,#006H
                LCALL COMW
                MOV A,#083H
                LCALL COMW		      	
				;INITIALIZATION END FOR LCD

;=============================================================
;	KEYPAD PROGRAM
;=============================================================				
							
K1:		;TO ENSURE THAT ALL SWITCHES ARE OPEN
		MOV P3,#0											;%
		MOV A,P3
		ANL A,#00001111B	;DISABLE UPPER NIBBLE
		CJNE A,#00001111B, K1
		;
K2:		;CHECK SWITCHES TO SEE IF ONE IS CLOSED
		ACALL DELAY
		MOV A,P3
		ANL A,#00001111B
		CJNE A,#00001111B,OVER
		SJMP K2
		;
OVER:		ACALL DELAY
		MOV A,P3
		ANL A,#00001111B
		CJNE A,#00001111B,OVER1
		SJMP K2
		;
OVER1:		MOV P3,#11111110B								
		MOV A,P3
		ANL A,#00001111B
		CJNE A,#00001111B,ROW_0
		;
		MOV P3,#11111101B								
		MOV A,P3
		ANL A,#00001111B
		CJNE A,#00001111B,ROW_1
		;
		MOV P3,#11111011B								
		MOV A,P3
		ANL A,#00001111B
		CJNE A,#00001111B,ROW_2
		;
		MOV P3,#11110111B							
		MOV A,P3
		ANL A,#00001111B
		CJNE A,#00001111B,ROW_3
		;
		LJMP K2
		;
ROW_0:		MOV DPTR,#KCODE0
		SJMP FIND
		;
ROW_1:		MOV DPTR,#KCODE1
		SJMP FIND
		;
ROW_2:		MOV DPTR,#KCODE2
		SJMP FIND
		;		
ROW_3:		MOV DPTR,#KCODE3
		SJMP FIND
		;
		;
FIND:		RRC A
		JNC MATCH
		INC DPTR
		SJMP FIND
MATCH:		CLR A
		MOVC A,@A+DPTR
		ACALL DATAW, A 				;//ACALL DATAWRITE,A  TO SEND DATA FROM ACCUMULATOR TO LCD
		LJMP K1
		;
		;///DELAY SUB-ROUTINE///
		;
DELAY:		MOV R2,#5
HERE:		NOP
		DJNZ R3,HERE
		RET
		;
		;
KCODE0:		DB '7','8','9'
KCODE1:		DB '4','5','6'
KCODE2:		DB '1','2','3'
KCODE3:		DB ' ','0','='
								
				
				
;===========================================
;	LCD PROGRAM
;===========================================
				
		
		MOV      A,#0C1H
		ACALL    DISP_STRING
HAWN:  		SJMP     HAWN       

AGAIN:          SJMP AGAIN    	;endless loop
COMW:           MOV P1,A   		;command write sequence
                CLR RS			;RS=0 for command
                CLR RW			;R/W=0 to write to LCD
                SETB EN			;E=1 for H-to-L pulse
		CLR EN			;E=0 ,latch in
		LCALL DELAY2
                RET
				
DATAW:          MOV P1,A   		;data write sequence
                SETB RS			;RS=1 for data
                CLR RW			;R/W=0 to write to LCD
                SETB EN			;E=1 for H-to-L pulse
                CLR EN			;E=0 ,latch in
		LCALL DELAY2
                RET
				
DISP_STRING:	CLR      A                     ;A=0
		MOV      R5,#00H               ;R5=0
NEXT_CHAR:	INC      R5		       		   ;R5+1
		MOVC     A,@A+DPTR
		ACALL    DATAW
		MOV      A,R5
		CJNE     R5,#0EH,NEXT_CHAR
		RET

			
DELAY2:         MOV R6,#50    		;simple delay routine
HERE2:          MOV R7,#255  		;for 0.0124S or 124ms
HERE3:          DJNZ R7,HERE3
                DJNZ R6,HERE2
                RET
				
;=============================================================

				
                END


;=============================================================


 


It looks to me like you have just pushed together two separate subroutines from a book, one for a display, one for a keyboard, and you haven't given any thought to how they should be called. You HAVE two infinite loops, which you HAVE identified as infinite loops. So how are you supposed to get out of them, if and when you hit them ?

Where is there a call TO your keyscan routine, to get a character, and then to your display routine to place it ?

What happens after the first time ?

I don't recognise "ACALL DATAW, A " as legal '52 assembler. What are you using ? Are you sure that what you have already actually, really works ??


Steve


List of 8 messages in thread
TopicAuthorDate
keypad and lcd with 8952            01/01/70 00:00      
   One thing at a time            01/01/70 00:00      
   Err            01/01/70 00:00      
   eh            01/01/70 00:00      
      most of us do            01/01/70 00:00      
      Assembler.            01/01/70 00:00      
   Literature            01/01/70 00:00      
      only if you understand what you are doing            01/01/70 00:00      

Back to Subject List