??? 02/27/04 21:40 Read: times |
#65652 - re: hyperterminal Responding to: ???'s previous message |
Before you take my comments too seriously, check your documentation. I am no where near as knowlegable about these µ-controllers as either Michael or Oleg. With that disclaimer/caveat in mind, I'm not sure that you need the pull up resistors on either P2 or P3. In at least the derivative I am working with (Atmel T89C51RC2) P0 has open drain pins (which would need external pull ups),but P1, P2 and P3 all have internal pull up resistors.
That being the case, you still need to write a 1 to the bit you want to monitor, regardless of the port it's tied to. When it's pulled low by the switch it will read as a 0, even though it had a 1 written to it. Once the switch is opened the pull up resistor (internal or external) will pull it back to a 1 state. The way your code is written you are writing a 0 to the bit and trying to have a switch pull it to a 1 state. In the best case this will do nothing (assuming you are trying to pull it high through a resistor), and in the worst case will fry stuff (if the switch ties your pin directly to Vcc). (It just occurs to me, is this perhaps why you changed your SWT to P2, because P3 stopped working?) I am assuming you understand about the importance of debouncing as discussed by Oleg. If not, say so. Michael and Oleg, what about the internal architecture? Is this standard for all 8051/8052 derivatives or is it variant dependent? |