ARM Technical Support Knowledge Articles

READING FROM AN INPUT PORT

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

How do I read from one of the I/O ports on the 8051?

ANSWER

To read an I/O port on the 8051, you must ensure that the internal latch state is at a high level. To ensure that the port bit is high, write a 1 to it. Then you may simply read the port or port bit.

For example:

sbit P1_1 = 0x91;

P1_1 = 1;    // Set port for input
var = P1_1;  // Read P1_1 into var

SEE ALSO

Article last edited on: 2000-06-24 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential