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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/20/06 19:16
Read: times


 
#120714 - code workin partially
Responding to: ???'s previous message
A few alterations and it's workin. but the second row i.e 4,5,6,7 are not being displayed.


ks_main:    mov p1,#0ffh
            acall s9k_main
ks_main1:   mov p1,#0f0h                            ;all columns high n rows low
            mov a,p1
            anl a,#11110000b                ;consider only columns
            cjne a,#11110000b,ks_main1       ;initially check for all keys released
;-------------------------------------------------------------------                      
ks_loop1:   acall delay_20ms
            mov a,p1
            anl a,#11110000b                            ;scan columns
            cjne a,#11110000b,debounce         ;if key pressed, check debounce
            sjmp ks_loop1                       ;if not, keep checking for key pressed
;-------------------------------------------------------------------
debounce:   acall delay_20ms
            mov a,p1
            anl a,#11110000b 
            cjne a,#11110000b,check_row
            sjmp ks_loop1
;--------------------------------------------------------------------
check_row:  clr ROW0
	    setb ROW1
	    setb ROW2
	    setb ROW3

	    mov a,p1
            anl a,#11111110b 			 ;test row zero
            cjne a,#11111110b,row_0
;--------------------------------------------------------------------			
 	    setb ROW0
	    clr ROW1
	    setb ROW2
	    setb ROW3
			
            mov a,p1
            anl a,#11111101b 			 ;test row one
            cjne a,#11111101b,row_1
;---------------------------------------------------------------------
            setb ROW0
	    setb ROW1
	    clr ROW2
	    setb ROW3
			
            mov a,p1
            anl a,#11111011b			 ;test row two
            cjne a,#11111011b,row_2
;--------------------------------------------------------------------- 			
	    setb ROW0
            setb ROW1
            setb ROW2
	    clr ROW3
			
            mov a,p1
            anl a,#11110111b  		    ;test row three
            cjne a,#11110111b,row_3
;----------------------------------------------------------------------
            sjmp ks_loop1
;----------------------------------------------------------------------
row_0:      mov dptr,#disp_kcode0
             sjmp find_num

row_1:      mov dptr,#disp_kcode1
             sjmp find_num

row_2:      mov dptr,#disp_kcode2
             sjmp find_num
			
row_3:      mov dptr,#disp_kcode3
             sjmp find_num
;----------------------------------------------------------------------
find_num:   rlc a
            jnc found_num                   ;which column is pressed/grounded
            inc dptr
            sjmp find_num
;----------------------------------------------------------------------
found_num:  clr a
            movc a,@a+dptr
	    acall tx_main                   ;send pressed button to serial port
;-----------------------------------------------------------------------
            jmp ks_main1
;-----------------------------------------------------------------------
disp_kcode0:DB'0','1','2','3'
disp_kcode1:DB'4','5','6','7' 
disp_kcode2:DB'8','9','A','B' 
disp_kcode3:DB'C','D','E','F' 
;-----------------------------------------------------------------------

end                


List of 27 messages in thread
TopicAuthorDate
hex key pad code not working            01/01/70 00:00      
   Explanation            01/01/70 00:00      
   what, how            01/01/70 00:00      
      each line of code must be justified            01/01/70 00:00      
         correction made, still not workin            01/01/70 00:00      
            Lookup table            01/01/70 00:00      
               hyperlink            01/01/70 00:00      
            of course not,            01/01/70 00:00      
      shall I spoil the fun?            01/01/70 00:00      
         code workin partially            01/01/70 00:00      
            be specific            01/01/70 00:00      
               specific            01/01/70 00:00      
                  check it in the simulator            01/01/70 00:00      
            Use serial port for debugging            01/01/70 00:00      
            confidence            01/01/70 00:00      
         I wouldn't do that            01/01/70 00:00      
   problem with find_num subroutine?            01/01/70 00:00      
   Code presentation            01/01/70 00:00      
   sorry it's 'hyper terminal'            01/01/70 00:00      
   Problem solved            01/01/70 00:00      
      which conclusion, please tell            01/01/70 00:00      
      Problem is NOT solved.            01/01/70 00:00      
         Post the solution please            01/01/70 00:00      
            solution            01/01/70 00:00      
               a 'killer solution'            01/01/70 00:00      
                  killer????            01/01/70 00:00      
                     you 'eat' the main            01/01/70 00:00      

Back to Subject List