I was writing code in c language for 8051 micro controller. In my application, a switch ( when pressed)connects P3^0 (which is initialized as an input port by writing a 1 to it in the start of the code) to ground. Then my code continuously checks for the switch status and whenever pressed it will make P2^0 high for 1 second time. To P2^0, an LED is connected. in the start of the code i have made P2^0 =0 to avoid the LED blinking before the switch is pressed. I have checked my code and found working fine except for a minor problem. Whenever power is made ON (or controller is reset), the P2^0 becomes high for a moment AND LED also blinks for a moment. This is something i don't want to happen in my application.I am not getting any idea to tackle this problem. kindly help me..
thanking you satish kumar mumbai, india.
Lots of processors are much better at sinking current than sourcing current. So it's quite common to connect the LED so it turns on when the processor pin is held low.
Obviously, the smart thing to do is to make sure you understand what a processor does with the pins before your program gets in control, and design the hardware based on actual processor behaviour.