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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/23/04 17:55
Read: times


 
#78027 - RE: Defining debouncing
Responding to: ???'s previous message
Hi Craig,
I think I've got it, here's the new code and it appears to be working. The next thing I want to work on is this part:

When it comes to debouncing the human or "throttling" the input what you can do is first wait for a valid signal. That means you debounce for 50-100ms and if the signal indicates the button was pressed the whole time then you assume you have a valid input. Once you have a valid input you toggle your LED. Then you execute a loop which does nothing more than wait for the button to be released. As long as the button is still pressed you keep looping. As soon as the button is released you go back to your main "DELAY" section of the code which will wait for the next keypress.


.ORG 2000H
MOV A,#9FH ;SET UP
MOV DPTR,#0F803H ; PORT A
MOVX @DPTR,A ; AS AN INPUT
MOV A,#89H ;SET UP
MOV DPTR,#0F903H ; PORT E
MOVX @DPTR,A ; AS AN OUTPUT
MOV 40H,#00 ;CLEAR FLAG-IS LED ON/OFF
MOV A,#0FFH ;TURN OFF
MOV DPTR,#0F901H ; ALL LEDS
MOVX @DPTR,A ; TO PORT E
RESET1:MOV R6,#10 ;OUTER LOOP TO DET. VALID STATE
RESET:MOV R7,#00 ;INNER LOOP TO DET. VALID STATE
MOV DPTR,#0F800H ;POINT TO PORT A
MOVX A,@DPTR ; TO READ SWITCH
MOV 50H,A ;SAVE RESULT OF SWITCH READ
READ:MOV DPTR,#0F800H ;POINT TO PORT A
MOVX A,@DPTR ;READ SWITCH AGAIN
CJNE A,50H,RESET1 ;COMPARE SAVED TO NEW
DJNZ R7,READ ;DECREMENT INNER LOOP
DJNZ R6,READ ;DECREMENT OUTER LOOP
MOV A,50H ;IS SWITCH OPEN/CLOSED
JNZ RESET1 ;IF SWITCH OPEN (A=NOT ZERO)
MOV A,40H ;MONITOR FLAG
JNZ CLEAR
SET:INC 40H ;SET FLAG
MOV DPTR,#0F901H ;POINT TO PORT E
MOV A,#0FFH
MOVX @DPTR,A ;TURN ON LED
SJMP RESET
CLEAR:DEC 40H ;CLEAR FLAG
MOV DPTR,#0F901H ;POINT TO PORT E
MOV A,#0FEH
MOVX @DPTR,A ;TURN OFF LED
SJMP RESET

I hope to post the final product tonight. Thanks-Lisa



List of 55 messages in thread
TopicAuthorDate
Problem with my code            01/01/70 00:00      
   RE: Problem with my code            01/01/70 00:00      
      RE: Problem with my code            01/01/70 00:00      
   RE: Problem with my code            01/01/70 00:00      
      RE: Problem with my code            01/01/70 00:00      
   RE: Problem with my code            01/01/70 00:00      
      RE: Problem with my code            01/01/70 00:00      
         RE: Problem with my code            01/01/70 00:00      
            RE: Problem with my code            01/01/70 00:00      
               RE: Problem with my code            01/01/70 00:00      
               RE: Problem with my code            01/01/70 00:00      
                  RE: Antiques            01/01/70 00:00      
                  RE: Problem with my code            01/01/70 00:00      
                     can't count            01/01/70 00:00      
                        RE: can't count            01/01/70 00:00      
                  RE: Problem with my code            01/01/70 00:00      
                     Validity of state            01/01/70 00:00      
                        RE: Validity of state            01/01/70 00:00      
                           RE: Validity of state            01/01/70 00:00      
                        RE: Validity of state            01/01/70 00:00      
            RE: Problem with my code            01/01/70 00:00      
               Another for the teacher            01/01/70 00:00      
               Fighting academia            01/01/70 00:00      
                  RE: Fighting academia            01/01/70 00:00      
                     RE: Fighting academia            01/01/70 00:00      
                  RE: Fighting academia more            01/01/70 00:00      
                  RE: Fighting academia            01/01/70 00:00      
               RE: Problem with my code            01/01/70 00:00      
                  RE: Problem with my code            01/01/70 00:00      
   RE: Problem with my code            01/01/70 00:00      
      RE: Problem with my code            01/01/70 00:00      
   RE: Replacing school hardware            01/01/70 00:00      
      RE: Replacing school hardware            01/01/70 00:00      
         RE: Replacing school hardware            01/01/70 00:00      
      RE: Replacing school hardware            01/01/70 00:00      
         RE: Replacing school hardware            01/01/70 00:00      
            RE: Replacing school hardware            01/01/70 00:00      
               RE: Replacing school hardware            01/01/70 00:00      
                  RE: Lisas problem            01/01/70 00:00      
                  Debounce, and define current problem            01/01/70 00:00      
                     RE: Debounce, and define current problem            01/01/70 00:00      
                        Defining debouncing            01/01/70 00:00      
                           RE: Defining debouncing            01/01/70 00:00      
                              You got it            01/01/70 00:00      
            RE: good old 6809            01/01/70 00:00      
      RE: Replacing school hardware            01/01/70 00:00      
         RE: Replacing school hardware            01/01/70 00:00      
            STUPID marketing policy            01/01/70 00:00      
               Possibly not entirely stupid...?            01/01/70 00:00      
                  RE: Possibly not entirely stupid...?            01/01/70 00:00      
            RE: Replacing school hardware            01/01/70 00:00      
               RE: Replacing school hardware            01/01/70 00:00      
   C.Steiner, Atari and dev. systems..            01/01/70 00:00      
   RE: Problem with my code            01/01/70 00:00      
      RE: Problem with my code            01/01/70 00:00      

Back to Subject List