| ??? 06/22/02 10:23 Read: times |
#24758 - RE: LED+Switch trouble |
The IO ping I am using for the switch is 2.6, pulled high through a 10K resistor, and set to VCC when the switch is pushed.
If it is pulled high, it is already at Vcc. CLR A CLR P2.6 SETB P2.0 The CLR P2.6 instruction will set the pin as output and pull it 'hard' to GND. You want to SETB P2.6 which will set it high through an internal pull-up and have your switch pull it to GND. Loop: mov P2, A ORL A, 20h JZ restart jmp loop 1. You have switched P2 and A in the MOV instruction (as Pranav already pointed out). 2. The ORL will give an indetermined result, because you are ORing with the content of memory location 20h. It should have been ORL A,#20h. 3. If you want to determine the value of only one bit in a byte you should use the ANL instruction, instead. Remember that after a reset all I/O pins read '1'. 4. The value 20h masks P2.5, not P2.6 5. the whole "MOV .... JZ" thing can be done with: JNB P2.6,restart Enough suggestions, methinks :o) Good luck, Rob. |
| Topic | Author | Date |
| LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble | 01/01/70 00:00 | |
| RE: LED+Switch trouble - thanks rob! | 01/01/70 00:00 | |
RE: LED+Switch trouble - thanks rob! | 01/01/70 00:00 |



