Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

configure ports of AT89S51 as input output

Status
Not open for further replies.

saurabheda

Junior Member level 3
Joined
Oct 16, 2011
Messages
25
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,460
AT89S51 microcontroller..

FACT 1 : power ON reset IMPLIES that all the 4 ports are
configured as output by default initially..
FACT 2 : to make a port an input port it is given 0xFF and to make it an output port it is given 0x00..

NOW, take the following scenario-

the microcontroller is powered ON.
now since all the ports are by default OUTPUT , i use P2 to serve some LEDs ..
now i want to make all the 8 LEDs to glow..
i would probably write-
P2=0xFF; <<----

now the DOUBT is, wheather the LEDs will be served or the port P2 will be configured as an input port..?

i.e. the arrowed statement would be considered as a data or a command to configure port..?
 

no,

actually P2 = 0xFF; configured as output and it serves high at the pin,

P2 |= 0xFF; as input
 

@saurabheda--bro, i think you are getting little confused here..

when you apply high and low to ports,, that doesnt strictly mean ki you cant use it for your purposes(i.e. lighting up led's,buzzers etc..)
if the port is high(irrespective it is treated as an input port) u can use it for your work..
if the port is low(irrespective it is treated as an output port), u can still use it for your work...

and the point of making a port as input or output is just as simple as:
these microcontrollers(i dont know about others) work good for active low components i.e. your led should be connected with voltage already and shorter leg to the controller pin and on making the controller pin low led glows up..
i.e. these controllers have good sinking capacity as compared to their sourcing capacity...
and this concept is served for treating it as input or outport port...

u may use their values any time without considering their state(input or output)...

hope it helps..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top