experiment 2
DESCRIPTION
Embedded lab experiment 2TRANSCRIPT
Experiment No. 1
Aim: Write C language program to a) Read data from port P2 and P3. Add data and display result on port P0.Glow LED connected at port pinP1.1 if carry flag set after addition.
b) Read data from port P2 and P3. Multiply data and display result on port P0 and P1
c) Write program to read switch connected at port pin P1.0, toggle it and send to port pin P2.1
Circuit Diagram:
Fig. 1 Circuit diagram of switch interfacing with 8051(c)
Worksheet 1
1) Write C language program to continuously toggle pin P1.0 without disturbing other port pins.
2) Write C language program to perform OR operation between port pin P1.0 and P1.1. Display result on port pin P1.2.
3) Write C language program to read port P1, Compare content of port P1 with data 80h. If data at port P1 is greater than 80h, make port P0=0x00 and if data at port P1 is less than or equal to 80h, make port P0=0xFF.4) Write a program to sense lift door switch connected at port pin P2.0.Switch on the alarm connected at port pin P2.1 if lift door is open. Write program in C language.5) Write a program to design a calculator which performs addition, subtraction and multiplication. Of 2 digit. If :Sw1Sw2
00
01
10
6) Write a program to toggle the p1 port continuously with some delay
7) What is the difference between sbit and bit data type.
_1425450376.vsdP2.2
P0.0
P2.1
39
P2.0
P0.7
P0.6
P0.5
P0.4
P0.3
P0.2
P0.1
PSEN
P2.7
P2.6
P2.5
P2.4
P2.3
P3.7/ RD
P3.6/ WR
ALE
P1.0
P1.1
P3.0/RXD
36
37
38
35
P1.7
P1.6
P1.5
P1.4
P1.3
P1.2
P3.1/TXD
P3.5/T1
P3.4/T0
P3.3/INT1
P3.2/INT0
21
32
33
34
28
GND
26
27
22
23
24
30
29
16
17
20
RST
X2
X1
9
19
18
31
10
11
2
4
1
3
15
12
13
14
8
7
5
6
VCC
EA/ VPP
89s51
GND
GND
10K
10 uF
30 pF
30 pF
11.06MHz
P3.5/T1
GND
VCC
SW1
VCC
40
VCC
1K
LED
25