Experiment No.06: Aim-Apparatus Used
Experiment No.06: Aim-Apparatus Used
06
AIM- Write a program for Geometric Progression using 8051
Microcontrollers.
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)
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
n-1
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
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)
Comments
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
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.
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
Hex Code
Machine Cycle
Comments
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:
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
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
Memory Address
Mnemoni cs
Hex Code
Machine Cycle
Comments
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
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.
PIN 1 2 3 4
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
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
74 11
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
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.