| Oleg Sergeev 11/03/03 09:57 Read: 647 times St. Petersburg Russia |
#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 CYCLEIf 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 CYCLEHere 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! |
| Topic | Author | Date |
| toggle function | Rik Slosse | 11/03/03 07:15 |
| RE: toggle function | Donald Catto | 11/03/03 07:50 |
| RE: toggle function | Paul Hopkinson | 11/03/03 09:17 |
| RE: toggle function | Enrique Viseras | 11/03/03 09:54 |
| RE: toggle function | Oleg Sergeev | 11/03/03 09:57 |
| RE: toggle function | Oleg Sergeev | 11/03/03 14:18 |
| Hardware De-bounce | Sriharsha Vedurmudi | 11/03/03 23:31 |
| De-bouncing is more complex! | Kai Klaas | 11/04/03 02:12 |
| RE: Hardware De-bounce | Oleg Sergeev | 11/04/03 04:07 |
| RE: Hardware De-bounce | Steve M. Taylor | 11/04/03 04:12 |
| RE: Hardware De-bounce | Erik Malund | 11/04/03 07:09 |
| RE: Classic Hardware De-bounce | Michael Karas | 11/04/03 08:23 |
| RE: Classic Hardware De-bounce | Charles Bannister | 11/04/03 17:08 |
| RE: Hardware De-bounce | Raghunathan R | 11/05/03 00:44 |
| RE: Hardware De-bounce | Sjoerd Toonstra | 11/05/03 02:44 |
| Switch bounce - Scope plots | Kai Klaas | 11/04/03 23:39 |
| RE: Switch bounce - Scope plots | Oleg Sergeev | 11/05/03 01:57 |
| APOLOGIES... :( | Sriharsha Vedurmudi | 11/05/03 04:16 |
| RE: Note | Michael Karas | 11/05/03 06:21 |
| Resistor for capacitor dischar | Raghunathan R | 11/05/03 07:39 |
| RE: Resistor for capacitor dischar | Erik Malund | 11/05/03 07:54 |
| RE: Added Resistor | Michael Karas | 11/05/03 07:58 |
| RE: Added Resistor | Sriharsha Vedurmudi | 11/06/03 01:03 |
| RE: Added Resistor | Michael Karas | 11/06/03 06:29 |
| Did you read my last reply? | Kai Klaas | 11/06/03 11:46 |
| RC + Schmitt-trigger - Scope plots | Kai Klaas | 11/05/03 22:15 |
| RE: toggle function | Jacob Boyce | 11/06/03 12:32 |
RE: toggle function | Kai Klaas | 11/06/03 12:44 |



