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.
I'm curious - how many relays do you have? And how much current do each relay require. Another thing - are there any flywheel diodes connected? You sink the relay current directly with the processor pins? Any other interesting information you have about your design?
24 DPDT relays connected via 74HCT541 and ULN2003A. 10k resistors on Port 0 pins.
And how have you designed the power supply so the supply voltage stays stable and the ground plane doesn't bounce when a larger number of relays gets activated at the same time?
Have you tried to just activate one or two relays at a time?
By the way - why do you want to activate the relays before reaching main()? Because the port pins in reset state have the wrong logic state relative to what you need the relays to do directly on power-on?
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.
Maybe replace the 74HCT541 with a 74HCT540?
View all questions in Keil forum