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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/03/03 16:57
Read: times


 
#57747 - RE: toggle function
Responding to: ???'s previous message
Hi,
I think you may find such examples anywhere.
If you need to copy the state of one port to another then the simplest way is just connect them together (=
By software it is done with two commands:
	SETB	P3.7		; set pin as input one
CYCLE:
	MOV	C,P3.7		; image input
	MOV	P1.1,C		;	     to output
	JMP	CYCLE
If you need to toggle output on each button action then you must know something about signal debounce:
	SETB	P3.7		; set pin as input one
CYCLE:
	JB	P3.7,$		; wait for button pushed
	MOV	R0,#40
PUSHED:
	JB	P3.7,CYCLE	; debounce
	DJNZ	R1,$		;	  negative
	DJNZ	R0,PUSHED	;		  edge
	CPL	P1.1		; toggle output
RELEASE:
	JNB	P3.7,$		; wait for button poped
	MOV	R0,#40
POPED:
	JNB	P3.7,RELEASE	; debounce
	DJNZ	R1,$		;	  positive
	DJNZ	R0,POPED	;		  edge
	JMP	CYCLE
Here the DJNZ is used as debounce cycle. Please understand that it is not a good idea. Probably you should use timed intervals to not be depended on OSC frequence used.
Good days!

List of 28 messages in thread
TopicAuthorDate
toggle function            01/01/70 00:00      
   RE: toggle function            01/01/70 00:00      
   RE: toggle function            01/01/70 00:00      
   RE: toggle function            01/01/70 00:00      
   RE: toggle function            01/01/70 00:00      
      RE: toggle function            01/01/70 00:00      
         Hardware De-bounce            01/01/70 00:00      
            De-bouncing is more complex!            01/01/70 00:00      
            RE: Hardware De-bounce            01/01/70 00:00      
               RE: Hardware De-bounce            01/01/70 00:00      
                  RE: Hardware De-bounce            01/01/70 00:00      
                     RE: Classic Hardware De-bounce            01/01/70 00:00      
                        RE: Classic Hardware De-bounce            01/01/70 00:00      
            RE: Hardware De-bounce            01/01/70 00:00      
               RE: Hardware De-bounce            01/01/70 00:00      
   Switch bounce - Scope plots            01/01/70 00:00      
      RE: Switch bounce - Scope plots            01/01/70 00:00      
      APOLOGIES... :(            01/01/70 00:00      
         RE: Note            01/01/70 00:00      
             Resistor for capacitor dischar            01/01/70 00:00      
               RE: Resistor for capacitor dischar            01/01/70 00:00      
               RE: Added Resistor            01/01/70 00:00      
                  RE: Added Resistor            01/01/70 00:00      
                     RE: Added Resistor            01/01/70 00:00      
                     Did you read my last reply?            01/01/70 00:00      
      RC + Schmitt-trigger - Scope plots            01/01/70 00:00      
   RE: toggle function            01/01/70 00:00      
      RE: toggle function            01/01/70 00:00      

Back to Subject List