Professional Documents
Culture Documents
11-Module 4 - I - O Ports-02-02-2024
11-Module 4 - I - O Ports-02-02-2024
11-Module 4 - I - O Ports-02-02-2024
Dr. Shelja
VIT Vellore
I/O PORT
• 8051 microcontrollers have 4 I/O ports each of
8-bit, which can be configured as input or
output.
• Hence, total 32 input/output pins allow the
microcontroller to be connected with the
peripheral devices.
• All the ports upon RESET configured as input
ports.
• Pin configuration, i.e. the pin can be configured
as 1 for input and 0 for output as per the logic
state.
SJMP BACK
Module 4, Microprocessor & Microcontroller, SENSE VIT
PORT 0 AS
INPUT • In order to make port 0 as input port , the port
must be programmed by writing 1 to all the
bits.
• Example:
MOV A, #0FFH
MOV P0,A ; make P0 an input port
BACK: MOV A, P0 ; get data from port 0
MOV P1, A ;send it to P1
SJMP BACK
BACK:MOV P1,A
ACALL DELAY
CPL A
SJMP BACK
(a) The 50% duty cycle means that the “on” and “off” states (or the high and low portions of the pulse) have the same
length. Therefore, we toggle P1.0 with a time delay in between each state.
HERE: SETB P1.0 ;set to high bit 0 of port 1
LCALL DELAY ;call the delay subroutine
CLR P1.0 ;P1.0=0
LCALL DELAY
SJMP HERE ;keep doing it