Back to the 2023 paper

Module 2: The 8051 Architecture

20237m

Explain the special function registers associated with the I/O Ports. How to configure an I/O port as an input pin?

Worked SolutionAI Assisted

SFRs Associated with I/O Ports & Input Configuration

  • Port Latches: P0 (80H), P1 (90H), P2 (A0H), P3 (B0H) – each bit latch + driver with pull-up (P0 open-drain).

Input Configuration: 8051 ports are quasi-bidirectional. To configure pin as input:

  1. Write 1 to latch: MOV P1,#0FFH or SETB P1.3 makes FET off, pull-up holds high, external can drive low/high.
  2. Read pin: MOV A,P1 reads pin state (not latch). If alternative function enabled, direction auto.

Example:

MOV P1,#0FFH ; P1 input
MOV A,P1 ; read
ANL A,#01H
JNZ NOT_PRESSED

Alternative functions selected via SFR controls (SCon, TCon etc.) override I/O.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.