Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

How could I take input in 8051 without sending a '1' to the port latch?

Status
Not open for further replies.

jayanthyk192

Full Member level 3
Joined
Sep 17, 2010
Messages
179
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,580
Hi,

while taking input to 8051,in C,i used to never send a '1' to the port latch.now i know the architecture and realized that i had to send a 1 to the latch.but even when i did'nt do this the inputs used to be proper external inputs.how is this possible?does the compiler put an extra instruction wherever the inputs are taken?

thank you.
 

rhaynes

Member level 5
Joined
Feb 8, 2011
Messages
84
Helped
37
Reputation
74
Reaction score
37
Trophy points
1,298
Location
Oceanside, CA, USA
Activity points
1,996
Re: taking input in 8051

I don't believe compilers set it to a 1 before an input. More likely you are just forcing the I/O to a specific level. The input buffer is always active and will read the actual level of the pin regardless of the output buffer setting. Setting the output buffer high or tristate allows the input to override the output level and be read correctly. If the output is left set to 0 and a 1 is forced externally, the output buffer will be stressed and generate some heat but the input buffer will read the level correctly.

Ray
 

memarian

Full Member level 5
Joined
Aug 11, 2004
Messages
257
Helped
57
Reputation
114
Reaction score
34
Trophy points
1,308
Activity points
2,011
Re: taking input in 8051

Hi,

When a 8051 restarts (or Power up) it loads all ports with 0xff (like when you want to use it as input). if you don't use a Pin as a bi-directional Pin (for both Input and output) , you usually don't need to reload it every time with 1 to act as input.
 

jayanthyk192

Full Member level 3
Joined
Sep 17, 2010
Messages
179
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,580
Re: taking input in 8051

Hi,

When a 8051 restarts (or Power up) it loads all ports with 0xff (like when you want to use it as input). if you don't use a Pin as a bi-directional Pin (for both Input and output) , you usually don't need to reload it every time with 1 to act as input.

I clearly remember that i never used to give 1's or 0's for i/o.i used to directly use the pins as input or output.i think rhaynes is right.
 

microlab

Full Member level 5
Joined
Mar 4, 2006
Messages
309
Helped
44
Reputation
88
Reaction score
35
Trophy points
1,308
Activity points
3,253
Re: taking input in 8051

hi

normally there will not be any problem,and it's a good practice to pull up the port pins as most of the us do.
when you are using the same pins as Input and output, without any IC's in between, there could be a problem.in such cases you have to write a 1 to the pin which you have to read.

ml
 

jayanthyk192

Full Member level 3
Joined
Sep 17, 2010
Messages
179
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
2,580
Re: taking input in 8051

hi

normally there will not be any problem,and it's a good practice to pull up the port pins as most of the us do.
when you are using the same pins as Input and output, without any IC's in between, there could be a problem.in such cases you have to write a 1 to the pin which you have to read.

ml

thank you for the reply.i never used any port pull ups except for P0.i realize now the reason for my MC burning(actually 4).as you said using pull ups is a good practice.i studied that in MC book by Mazidi.

thanks again,all of you.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top