Welcome to the
Course-Microprocessors and Microcontrollers
Code-BECE204L
Dr Arun Dev Dhar Dwivedi
Associate Professor (Sr.), Department of Micro and Nano Electronics
School of Electronics Engineering (SENSE)
Email: arundevdhar.dwivedi@vit.ac.in, adddwivedi@gmail.com
Phone: 8209517661, 9450547267 (WhatsApp)
Cabin-SJT313A11A
MODULE-4 :Microcontroller 8051 Peripherals
Port programming: Implementation of Digital Circuits
1
Port programming
Implementation of Digital Circuits
Parallel Ports
• Initialize the Input Ports
8 bit port
eg. MOV P1, #0FFH
1 bit port
eg. SETB P1.5
NOTE:
OUTPUT PORTS ARE NOT INITALIZED
• Transfering 8 bit data
• MOV A, P1 ; transfering data from P1 to A
• Transfering 1 bit data
• MOV C, P1.5 ;Transfering 1 bit from P1.5 to
carry flag
• MOV A, P1.3 ; not a valid instruction
Digital circuit
6
Digital circuit
• Assume
• INPUT
A=P1.0
B=P1.1
C=P1.2
• OUTPUT
Q=P2.0
7
Digital circuit
• Org 0000h
• SETB P1.0
• SETB P1.1
• SETB P1.2
• MOV C,P1.0
• ANL C, P1.1
• MOV ACC.7,C
• MOV C, P1.1
• ORL C, P1.2
• MOV ACC.6,C
• MOV C,P1.2
• ANL C,P1.1
• ANL C,ACC.6
• ORL C,ACC.7
• MOV P2.0,C
• END
8
Digital circuit Program
• Org 0000h
• SETB P1.0;INITIALIZE
• SETB P1.1;INITIALIZE
• SETB P1.2;INITALIZE
• MOV C,P1.0
• ANL C,P1.1
• MOV ACC.7,C
• MOV C,P1.1
• ORL C,P1.2
• MOV ACC.6,C
• MOV C, P1.2
• ANL C,P1.1
• ANL C, ACC.6
• ORL C,ACC.7
• MOV P2.0,C
• END
9
TASK 1: Implementation of digital circuits using KEIL
for an 8051 Microcontroller
ORG 0000H Objective: To develop an assembly code for 8051 Microcontroller,
SETB ACC.0; input A to implement the given digital circuit using KEIL development
SETB ACC.1; input B tool.
CLR ACC.2; input C
SETB ACC.3; input D
MOV C, ACC.0
ANL C, ACC.1
ORL C, ACC.2
CPL C
MOV ACC.7, C
MOV C, ACC.2
CPL C
ANL C, ACC.3
CPL C
ANL C, ACC.7; Final output (F)
HALT: SJMP HALT
END
10
11
RESULT:
S.NO A B C D Output (F)
1 0 0 0 0
2 0 0 0 1
3 0 0 1 0
4 0 0 1 1
5 0 1 0 0
6 0 1 0 1
7 0 1 1 0
8 0 1 1 1
9 1 0 0 0
10 1 0 0 1
11 1 0 1 0
12 1 0 1 1
13 1 1 0 0
14 1 1 0 1
15 1 1 1 0 12
16 1 1 1 1
DIGITAL CIRCUIT PROGRAM 2
ORG 0000H
SETB ACC.0; Input A
SETB ACC.1; Input B
MOV C, ACC.1
CPL C
ANL C, ACC.0
MOV ACC.2, C; Output C
MOV C, ACC.0
ANL C, ACC.1
MOV ACC.3, C; Output D
H: SJMP H
END
13
RESULT:
S.NO A B Output (C) Output(D)
1 0 0
2 0 1
3 1 0
4 1 1
14