my question is about the power on / reset values of the 8051 ports: at power on /reset, the port latches are loaded with FFh hence there are configured as inputs or outputs.
The 8051 Microcontroller and Embedded System Using assembly and c by MUHAMMAD ALI MAZIDI JANICE GILLISPIE MAZDI ROLIN D. McKINLAY second edition PEARSON EDUCATION mentions that they are configured as inputs.
But most websites mention that,at power on /reset the port are configured as outputs . which is correct?
**************** also look at the following code that monitors a switch connected to P1.5 and sets P1.7 if P1.5 is high
SETB P1.5 ; set P1.5 as input L1:JNB P1.5 ,L1 ; continuously poll P1.5,exit the loop if P1.5 SETB P1.7 ; set P1.7 will not the first instruction, SETB P1.5 itself produce an erroneous output since the port 1.5 pin has already been set high by the instn. SETB P1.5.
Thank you
"the port latches are loaded with FFh hence there are configured as inputs or outputs."
The correct term, as used in the so-called "bible" for the 8051, is "quasi-bidirectional"
"MAZIDI ... mentions that they are configured as inputs ... websites mention that, at power on /reset the port are configured as outputs ."
These are common and unhelpful statements!
Again, there is nothing in a standard 8051 to configure the ports as either "inputs" or "outputs" - they are always quasi-bidirectional
Never rely on anything you just happen to read on a website; always confirm it with a reliable source - in this case, the so-called "bible" for the 8051:
Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer's Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Chapter 3 - 80C51 Family Hardware Description: www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
http://www.8052.com/faqs.phtml
In particular, see: www.8052.com/faqs.phtml
MAZIDI ... mentions that they are configured as inputs
There is NO SUCH THING as configuring '51 ports, whatever you do they are quasi-bidirectional
any author of a '51 book that mention "ports configured as as inputs" is in my opinion totally incompetent.
When you write a '1' to a port it will output a '1' which makes it possible to input to that pin, but, how do you explain "output '1' to a port" when that configures the port as input.
The links Andy gave above punch holes as large as a barndoor through that utterly stupid expression.
the ports of a 'plain vanills' '51 are quasi-bidirectional NEVER 'configured' as either input or output.
Erik
PS some very modern derivatives have ports that may be configured as output (push-pull)(, but still the default is quasi-bidirectional
"some ... modern derivatives have ports that may be configured as output (push-pull)"
In fact, some modern drivatives have all sorts of configuration optionss on their port pins...!
Thank you very much
Thank you,very much
This book is recommended quite often - but maybe that just goes to show how so many people perpetuate this misunderstanding of the 8051's quasi-bidirectional port architecture...?
I haven't read it myself - so I can't say whether this is typical, or just one slip in an otherwise excellent book...
Please answer to the second part of my question: also look at the following code that monitors a switch connected to P1.5 and sets P1.7 if P1.5 is high
SETB P1.5 ; set P1.5 as input L1:JNB P1.5 ,L1 ; continuously poll P1.5,exit the loop if P1.5 is high SETB P1.7 ; set P1.7
my question is,will not the first instruction, SETB P1.5 itself produce an erroneous output since the port 1.5 pin has already been set high by the instn. SETB P1.5.
my question is,will not the first instruction, SETB P1.5 itself produce an erroneous output since the port 1.5 pin has already been set high by the instn. SETB P1.5. the short answer: NO
the long answer: why would it?
you REALLY need to get this thing about 'input mode' out of your head.
read up in ch3 of "the bible" about ports.
another issue SETB P1.7 ; set P1.7 that is NOT a comment, comments are supposed to say "why", not "what"
Erik here are the links to "the bible" Chapter 1 - 80C51 Family Architecture: www.nxp.com/.../80C51_FAM_ARCH_1.pdf
Chapter 2 - 80C51 Family Programmer’s Guide and Instruction Set: www.nxp.com/.../80C51_FAM_PROG_GUIDE_1.pdf
Thank you, Ecik The 8051 hardware manual says " All the port latches in 80C51 have 1's written to them by the reset function.If a 0 is subsequently written to the port latch,it can be reconfigured as an input by writing a 1 to it"
JIM
many wrongs do not make a right.
I know this old wifes tale is one of the most popular misconceptions and permeates all '51 litterature.
One way that would be correct would be "when connecting other signals to a '51 the configuration is a "wire OR' between the '51 port pin and the other device(s) connected. Thus if any device (the '51 or external) pull the line low all devices reading the wire OR line will read a low.
Note: this fully explains everything and there is not a word about "input mode" or "output mode".
as you see an 'output pin' is also an 'input pin' (most of us has had inputs happen to an output with a prototype) just as an 'input pin ' also is an 'output pin'