Write an ALP to read port 2 and write to port1 of  8051 micro controller.

Aim:

Write an ALP to read port 2 and write to port1 of  8051 micro controller.

Apparatus/software:

1. 8051 microcontrollerkit /keil evaluation 
version/sdcc —1
2. C.R.O
3. Connecting wires. --1

Algorithm:

Step1: Write 0FF hex to make port2 as input port.
Step2: Read port 2 into reg A
Step3: complement regA
Step3: Write reg A to port1
Step4: Repeat step 2 to step3

Program:

      MOV A, #0FFH     ;A=FF hex
      MOV P
      2, A             ;make P0 an i/p port by writing it all 1s
BACK: MOV A, P2        ;get data from P2
      CPL A
      MOV P0, A         ;send it to port 1
      SJMP BACK         ;keep doing it

Procedure: 

1. Compile the program in keil compiler.
2. Down load program into micro controller.
3. set input in port 2
4. verify output in port 1

Expected results:

 The values set to port 2 are read and send to port1.

Hex file generated:

:0B00000074FFF5A0E5A0F4F59080F976
:00000001FF

Result:

Viva-voce questions:

1) How many no. of ports available for 8051?
2) Which instructions are used for reading & writing data from/to ports of 8051?
3) What is an ISR and IVT?
4) What is the difference between software and hardware interrupt?
5) What is the vector address for serial communication interrupt?