0% found this document useful (0 votes)
92 views20 pages

Experiment No.06: Aim-Apparatus Used

The document describes experiments conducted using an 8051 microcontroller. It discusses generating a square wave, creating a delay of 5ms, and implementing serial and parallel communication. The square wave is generated by calling a subroutine that complements the output port. A delay of 5ms is achieved by decrementing registers over multiple machine cycles. Serial communication transmits ASCII characters by initializing timers and moving data to ports. Parallel communication interfaces the microcontroller to an LCD by defining display properties and sending data to the LCD data bus pins.

Uploaded by

rahulkrsingh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views20 pages

Experiment No.06: Aim-Apparatus Used

The document describes experiments conducted using an 8051 microcontroller. It discusses generating a square wave, creating a delay of 5ms, and implementing serial and parallel communication. The square wave is generated by calling a subroutine that complements the output port. A delay of 5ms is achieved by decrementing registers over multiple machine cycles. Serial communication transmits ASCII characters by initializing timers and moving data to ports. Parallel communication interfaces the microcontroller to an LCD by defining display properties and sending data to the LCD data bus pins.

Uploaded by

rahulkrsingh
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 20

EXPERIMENT NO.

06
AIM- Write a program for Geometric Progression using 8051
Microcontrollers.

APPARATUS USED:1. 8051 Trainer Kit 2. Keyboard 3. SMPS

THEORY:1. First operand is moved to address 0F0H, which is further stored in register R0. 2. The second operand is moved to Accumulator through register Indirect Addressing mode. 3. The two operands are multiplied by the instruction MUL and the result is stored in the accumulator. 4. Stop.

PROCEDURE:Switch on the power supply and press reset button on the kit. Thereafter follow the following steps: 1. Press G (Enter) 2. Address 6000 (Enter) 3. Wait done 4. Press S (Enter) 5. Exit memory 6. Press any key 7. Register(Enter) 8. General (Enter)

9. Name (Enter) 10.Press A (Enter)

PROGRAM:MEMORY ADDRESS 7001 7004 7005 7006 7007 7008 7009 700A 700B 700C 700D 700E 700F 7010 7011 7012 7013 7014 7015 7016 7019 MACHINE CODE 90,40,40 E0 F8 A3 E0 F9 A3 E0 FA A3 F0 18 E8 60 EA 89 A4 A3 F0 D8 70 12 22 MNEMONICS MOV MOVX MOV INC MOVX MOV INC MOVX MOV INC MOVX DEC MOV JZ MOV LOOP MOV MUL INC MOV DJNZ RET OPERANDS DPTR,#4040 @,DPTR R0,A DPTR A,@DPTR R1,A DPTR A,@ DPTR RZ,A DPTR @DPTR R0 A,R0 END A,RZ F0,R1 AB DPTR @DPTR,A R0,LOOP

RESULTS AND DISCUSSION:


Firstly move the data 4040 to DPTR. Move the contents of A to R0.After his we increment the DPTR and move the contents located at the address stored in DPTR to A. Move the contents of A to address in locations in DPTR decrement R0 and move the contents of R0 to A. Move the contents of RZ to A and move the contents of R1 to B.

INPUT NUMBER: An=a.r

n-1

RESULT:3,18,108,648is a G.P with common ratio 6.

PRECAUTIONS:
1. The hex code of each instruction must be carefully noted from the instruction set table. 2. The microcontroller kit must be handled with care and the power supply should be turned off when the kit is not in use.

EXPERIMENT NO. 7

Aim :

To generate a square wave using 8051 microcontroller . 8051 microcontroller kit, Power supply, keyboard

Apparatus Required: Theory:

here, the square wave generation is based on the use of subroutine. Subroutine is called in the main program and upon calling a subroutine, the stack keeps track of where the CPU should return after completing the subroutine. The rule is that the number of push and pop instructions must always match in any called subroutine.In other words for every push , there must be a pop.

Procedure:

Switch on the power supply and press reset button on the kit. Thereafter follow the following steps: 1. Press G (Enter) 2. Address 6000 (Enter) 3. Wait done

4. Press S (Enter) 5. Exit memory 6. Press any key 7. Register (Enter) 8. General (Enter) 9. Name (Enter) 10. Press A (Enter)

Square Wave Generation


Memory Address Mnemoni cs Opcode & Operand Hex Code Machine Cycle

Comments

6000 6003 6006 6009

MOV LCALL MOV LCALL

90,#00 6020 90,#FF 6020

75 22 75 75

1 2 1 2

It moves data 00 to I/P and O/P port P1. It calls subroutine located at address 6020 within 64 kb program memory space. Move the data FF to I/O port P1.. Repeat step 2 to call subroutine.

600C 600D

LJMP RET

6000

02 22

2 2

Jump the address 6000 located within the 64 kb program memory space. Stop

Steps of subroutine at address 6020

6020 6022 6023 6024 6025 6026 6027

MOV CPLA CPLA CPLA CPLA CPLA RET

A,90

E5 F4 F4 F4 F4 F4 22

1 1 1 1 1 1 2

Copy the data at port P1 to the accumulator. Complement the contents in the accumulator . Complement the contents in the accumulator . Complement the contents in the accumulator . Complement the contents in the accumulator . Complement the contents in the accumulator .

For Dissambler:
1. Press E (Enter) 2. Line ass/disass C= 3. Press U

Result:
The Square Wave was generated.

Precautions:

1. The hex code of each instruction must be carefully noted from the instruction set table. 2. The microcontroller kit must be handled with care and the power supply should be turned off when the kit is not in use.

EXPERIMENT NO. 8
Aim :
To generate a delay of 5ms using a microcontroller

Apparatus Required:
8051 microcontroller kit, Power supply, keyboard

Theory:

To execute any instruction in 8051 microcontroller takes certain no. of clock cycles to execute an instruction. In 8051 microcontroller family, the length of machine cycle depends upon the frequency of crystal oscillator which provides clock source for the microcontroller. The frequency of crystal oscillator is 11.0592 MHz. One machine cycle is 1/12 of crystal frequency. Thus, I machine cycle lasts for 1.085 microsecond.

Time period of 1 machine cycle= 12/ 11.0592 MHz = 1.085 microsecond

Procedure:
Switch on the power supply and press reset button on the kit. Thereafter follow the following steps: 1. 1Press G (Enter) 2. Address 6000 (Enter) 3. Wait done 4. Press S (Enter) 5. Exit memory 6. Press any key 7. Register (Enter) 8. General (Enter) 9. Name (Enter) 10. Press A (Enter)

For Dissambler: 1. Press E (Enter) 2. Line ass/disass C= 3. Press U Delay of 5 ms using microcontroller

Memory Address

Mnemoni cs

Opcode & Operand

Hex Code

Machine Cycle

Comments

7000 7001 7002 7004 7006

MOV L1:MOV L2:DJNZ DJNZ NOP

R3,#0X8H R2,#0XFFH R2,L2 R3,L1

7B 7A DA DB 22

1 1 2 2 1

Move 8 in register R3. Move 265 in register R2. Decrement R2 & jump when 0 Decrement R3 & jump when 0 Repeat B terms

Calculation:

OPERATION TIME TAKEN

MOV R3,#0X08 0X09 1.085 x 1 microsecond L2: MOV R2,#0XFF 1.085 x 2 microsecond L1: DJNZ R2, L2 1.085 x 2 x 255 microsecond DJNZ R3,L1 1.085 x 2 x 19 microsecond

Total Time= 1.085 + 9 x 1.085 x 1+ [ 1.085 x 2 x 255 ] 9 + 1.085 x 2 x 9 = 4990 microsecond

= 5 ms approx. Result and Discussion : The delay of 5 ms has been generated.

Precautions:
1. The hex code of each instruction must be carefully noted from the instruction set table. 2. The microcontroller kit must be handled with care and the power supply should be turned off when the kit is not in use.

EXPERIMENT NO. 9

Aim :
To study and implement serial communication by interfacing microcontroller with a computer.

Apparatus Required:
8051 microcontroller kit, Power supply, keyboard

Theory:
Serial Communication : Serial communication is used for transferring data between two systems located at distance of hundreds of feet to millions of miles apart . Serial communication uses a single data instead of the 8 bit data. Line of parallel communication not only makes it much cheaper but also enables to computers located in two different cities to communicate over the telephone.

Procedure:
Baud rate gives the rate of data transfer. RS232 is the most widely used Serial I/O interfacing standard. It is commonly referred to as DB-25 connector. The serial control register stores the start bit, stop bit and data bits of data framing for serial transfer. For Dissembler: 1. Press E (Enter) 2. Line ass/disass C= 3. Press U

Implementation of serial communication

Memory Address

Mnemoni cs

Opcode & Operand

Hex Code

Machine Cycle

Comments

7000 7003 7006 7009 700B 700E 7018 7020 7028

MOV MOV MOV SET B MOV IN8 CLR MOV SJMP

89 H,#20 H ADH,#FD 98 H,#50 H 8 EH 99 H,#59 H 99 H, 700 E 99 H 80 H, #4EH 7011

75 75 75 D2 75 30 C2 75 80

2 2 2 1 2 1 1 2 2

Use timer 1, Mode 2(autoreload). Baud rate= 9600 stored in TH1= -3(decimal) 50 H is moved to SCONREN enabled. Start timer 1 Move the letter Y serially. Wait for transmission to be over. Clear T1 for next transmission. Move N to port 0 Go to 7011

Result :
Interfacing is done properly. The letter Y and N are transmitted serially.

Precautions:
1. The hex code of each instruction must be carefully noted from the instruction set table. 2. The microcontroller kit must be handled with care and the power supply should be turned off when the kit is not in use.

EXPERIMENT NO.10
AIM- to study and Implement parallel data communication by interfacing
microcontroller with LCD

APPARATUS USED:1. 8051 Trainer Kit 2. Keyboard 3. SMPS

THEORY:1. LCD interfacing with microcontroller is widely spreading. The reasons for this are: 2. The declining prices of LCD. 3. The ability to display members; characters and graphics. 4. Incorporation of a refreshing controller into the LCD thereby relieving the CPU of the task of refreshing the LCD. 5. The ease of programming for character and graphics.

LCD has 14 pins as follows:

PIN 1 2 3 4

SYMBOL Vss Vcc Vee RS

I/O I

DESCRIPTION Ground +5V Power supply to control contrast RS=0 to select command register RS=1 to select data register

5 6 7-14

R/W E DB0-DB7

I I/O I/O

0 for write, 1 for read Enable 8-bit data bus.

PROCEDURE:Switch on the power supply and press reset button on the kit. Thereafter follow the following steps: 1. Press G (Enter) 2. Address 6000 (Enter) 3. Wait done 4. Press S (Enter) 5. Exit memory 6. Press any key 7. Register(Enter) 8. General (Enter) 9. Name (Enter)

10.

Press A (Enter)

PROGRAM:MEMORY ADDRESS 7000 7002 7004 7006 7008 700A 700C 700E MNEMONICS MOV A, #38 H ACALL 7050 MOV A, #01 H ACALL 7050 MOV A,#06 H ACALL 7050 MOV A ,#0E H ACALL 7050 HEXCODE 74 11 74 11 74 11 74 11 DESCRIPTION Define LCD 2 lines, 5x7 matrix Go to 7050 Clear LCD Memory Go To 7050 Move cursor in right direction Go to 7050 Display on , cursor blinking Go to 7050

7010 7012

MOV A,#81 H ACALL 7050

74 11

Decide from where display start Go to 7050

To display data MEMORY ADDRESS 7050 7052 7054 7056 7058 705A 705C 705E 7060 7062 7064 7066 7068 706A 706C 706D 706F 7071 7073 7075 7077 7079 MNEMONICS MOV A, #65 H ACALL 7064 MOV A, #66 H ACALL 7064 MOV A,#67 H ACALL 7064 MOV A ,#68 H ACALL 7064 MOV 80 H,A CLR A2H CLR A1 H SETB A0 H ACALL 7078 CLR A0 H RET MOV 80 H,A CLR A2H CLR A1H SET B A0H ACALL 7078 CLR A0H RET HEXCODE 74 11 74 11 74 11 74 11 F5 C2 C2 D2 11 C2 22 F5 C2 C2 D2 11 C2 22 DESCRIPTION Display A Go to 7064 Display B Go to 7064 Display C Go to 7064 Display D Go to 7064 Move A to P0 Clear P2.2 Clear P2.1 SET P2.0 Go to 7078 Clear P2.0 Go back to where called Move A to P0 Clear P2.2 Clear P2.0 SET P2.0 Goto 7078 Clear P2.0 Go back where called

Delay

7080 7082 7084 7086 7088 7089

MOV R0,#28 H MOV R1,#28 H DJNZ R1,7082 DJNZ R0,7080 RET RET

78 79 D9 D8 22 22

Move R0-28 Move 28-R1 If R1 not equal to 0,goto 7082 If R0 not equal to 0,goto 7081 Go back End

RESULTS
The LCD interfacing has been done.

PRECAUTIONS:
1. The hex code of each instruction must be carefully noted from the instruction set table. 2. The microcontroller kit must be handled with care and the power supply should be turned off when the kit is not in use.

You might also like