This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Initializing Port 0 and Port 2 with 0x00 value

The hardware that I am working on has Relays connected on Port 0 and Port 2 pins of AT89S52 uc. I would like to know if it is possible to initialize the port pins with 0x00 values before the main application starts. I tried doing this:

P0 = P2 = 0xFF;
P0 = P2 = 0x00;

but in this case the relay stops to respond. The uc does not communicate after doing this.

Please advice.

Parents
  • The port pins are all high (1) on power on. In this state all the relays are energized. I need them all to be low (0), so that i can switch on the relays that i want.

    And how is that different from just switching off all relays you don't want? What's the purpose of switching those that you want on twice, in rapid succession?

    Anyway, the above indicates you're trying solve the wrong end of the problem. The problem is with the hardware design, and that means you have to fix your hardware to solve it. It has to change such that port pin low causes the relay to be energized.

    If doing the initialization at the beginning of main() is too late, then no change to the software will have any useful effect. The time from the end of reset to the start of main() is just way too short for a relay to notice the difference.

Reply
  • The port pins are all high (1) on power on. In this state all the relays are energized. I need them all to be low (0), so that i can switch on the relays that i want.

    And how is that different from just switching off all relays you don't want? What's the purpose of switching those that you want on twice, in rapid succession?

    Anyway, the above indicates you're trying solve the wrong end of the problem. The problem is with the hardware design, and that means you have to fix your hardware to solve it. It has to change such that port pin low causes the relay to be energized.

    If doing the initialization at the beginning of main() is too late, then no change to the software will have any useful effect. The time from the end of reset to the start of main() is just way too short for a relay to notice the difference.

Children
No data