MPMC Programs
MPMC Programs
CYCLE -1
1. 16 bit Addition [immediate addressing mode]
AIM:-
To write an ALP for Addition operation of two 16-bit numbers using immediate
addressing mode
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,1234h
mov bx,5678h
add ax,bx
mov ah,4ch
int 21h
end
Result:-
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,5678h
mov bx,1234h
sub ax,bx
mov ah,4ch
int 21h
end
Result:-
1
3. 16 bit Multiplication [immediate addressing mode]
AIM:-
To write an ALP for Multiplication operation of two 16-bit numbers using immediate
addressing mode
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,5000h
mov
bx,1100h mul
bx
mov ah,4ch
int 21h
end
Result:-
Program:-
.8086
.model small
.code
mov ax,5000h
mov bx,0000h
mov bx,0055h
div bx
mov ah,4ch
int 21h
end
Result:-
2
5. 16-bit Addition [direct addressing mode]
AIM:-
To write an ALP for Addition operation of two 16-bit numbers
using direct addressing mode
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
addend dw 1234h
augend dw 5678h
sumL dw?
sumH dw?
.code
mov ax,@data
mov ds,ax
mov ax,addend
mov bx,augend
add ax,bx
mov sumL,al
mov sumH,ah
mov ah,4ch
int 21h
end
RESULT:-
2
SCITS ECE MICROCONTROLLER LAB
.8086
.model small
.data
subtrahend dw 5678h
minuend dw 1234h
diffL dw?
diffH dw?
.code
mov ax,@data
mov ds,ax
mov ax,subtrahend
mov bx,minuend
sub ax,bx
mov diffL,al
mov diffH,ah
mov ah,4ch
int 21h
end
RESULT:-
3
SCITS ECE MICROCONTROLLER LAB
.8086
.model small
.data
multiplicand dw 5000h
multiplexer dw 1100h
productL dw?
productH dw?
.code
mov ax,@data
mov ds,ax
mov ax,mutliplicand
mov bx,mutliplexer
mul bx
mov productL,dx
mov productH,dx
mov ah,4ch
int 21h
end
RESULT:-
4
SCITS ECE MICROCONTROLLER LAB
.8086
.model small
.data
dividend dw 5000h
division dw 0055h
quotient dw?
remainder dw?
.code
mov ax,@data
mov ds,dx
mov ax,dividend
mov dx,divison
div dx
mov quotient,ax
mov
remainder,dx
mov ah,4ch
int 21h
end
RESULT:-
5
SCITS ECE MICROCONTROLLER LAB
AIM:-
To write an ALP for Logical AND operation of two 16-bit numbers.
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,1234h
mov bx,5678h
AND ax,bx
mov ah,4ch
int 21h
end
Result:-
AIM:-
To write an ALP for Logical OR operation of two 16-bit numbers.
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,1234h
mov bx,5678h
OR ax,bx
mov ah,4ch
int 21h
end
Result:-
6
SCITS ECE MICROCONTROLLER LAB
AIM:-
To write an ALP for Logical EXCLUSIVE-OR operation of two 16-bit numbers
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,1234h
mov bx,5678h
XOR ax,bx
mov ah,4ch
int 21h
end
Result:-
AIM:-
To write an ALP for Logical NOT operation of two 16-bit numbers
APPARATUS:-
MASM software
Program:-
.8086
.model small
.code
mov ax,5678h
NOT ax
mov ah,4ch
int 21h
end
Result:-
7
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for Interchange the data in the two locations
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
d1 db 01h,02h,03h,04h,05h
d2 db 11h,22h,33h,44h,55h
.code
mov ax,@data
mov ds,ax
mov si,offset d1
mov di,offset d2
up: mov al,[si]
mov bl,[di]
mov [si],bl
inc si
inc di
dec cl
jmp up
mov ah,4ch
int 21h
end
Result:-
8
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for Length of the given String
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
d1 db ‘mpmc $’
len db?
.code
mov ax,@data
mov ds,ax
mov al, ’$’
mov cl,00h
mov si,offset d1
back: cmp al,[si]
jz go
inc cl
inc si
jmp back
go:mov len,cl
mov ax,4ch
int 21h
end
Result:-
9
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for Display the given String
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
mystr db ‘prashanth’
.code
mov ax,@data
mov ds,ax
lea dx,mystr
mov ah,08h
int 21h
mov ah,4ch
int 21h
end
Result:-
10
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for Interchange the data in the two locations
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
data1 db 1ch,2ch,3ch,4ch,5ch
data2 db 5dup(?)
.code
mov ax,@data
mov ds,ax
mov cl,05h
mov si,offset data1
mov di,offset
data2 add si,04h
up: mov al,[si]
mov [di],al
dec si
inc di
jnz up
mov ah,4ch
int 21h
end
Result:-
11
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for swapping of two 16-bit numbers
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
num1 dw 1234h
num2 dw 5678h
.code
mov
ax,@data
mov ds,ax
mov ax,num1
mov bx,ax
mov ax,num2
mov num1,ax
mov num2,bx
mov ah,4ch
int 21h
end
Result:-
12
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for searching for a character in the given string
APPARATUS:-
MASM software
Program:-
.8086
.model small
.data
d1 db ‘grace $’
slen EQU d1+1
letter db ‘a’
result db ‘a’
.code
mov ax,@data
mov ds,ax
mov al,letter
mov si,offset d1
mov bl,0000h
cld
mov cl,slen
count: repne scasb
jcxz display
inc bl
jmp count
display:mov result,bl
mov ah,4ch
int 21h
RESULT:-
13
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for 8-bit Rotate Left Operation
APPARATUS:-
MASM Software
Program:-
.8086
.model small
.code
mov al,49h
mov cl,04h
ROL al,cl
mov ah,4ch
int 21h
end
Result:-
AIM:-
To Write an ALP for 8-bit Rotate Right Operation
APPARATUS:-
MASM Software
Program:-
.8086
.model small
.code
mov al,51h
mov cl,03h
ROR al,cl
mov ah,4ch
int 21h
end
Result:-
14
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for 8-bit Circular Rotate Left Operation
APPARATUS:-
MASM Software
Program:-
.8086
.model small
.code
mov al,28h
mov cl,04h
RCL al,cl
mov ah,4ch
int 21h
end
Result:-
AIM:-
To Write an ALP for 8-bit Circular Rotate Right Operation
APPARATUS:-
MASM Software
Program:-
.8086
.model small
.code
mov al,87h
mov cl,03h
RCR al,cl
mov ah,4ch
int 21h
end
Result:-
15
SCITS ECE MICROCONTROLLER LAB
AIM:-
To Write an ALP for 8-bit Shift Left Operation
APPARATUS:-
MASM Software
Program:-
.8086
.model small
.code
mov al,53h
mov cl,04h
SHL al,cl
mov ah,4ch
int 21h
end
Result:-
AIM:-
To Write an ALP for 8-bit Shift Right Operation
APPARATUS:-
MASM Software
Program:-
.8086
.model small
.code
mov al,96h
mov cl,03h
SHR al,cl
mov ah,4ch
int 21h
end
Result:-
16
SCITS ECE MICROCONTROLLER LAB
17
SCITS ECE MICROCONTROLLER LAB
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Opcode Mnemonics Comment
Location operand
RESULT:-
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Opcode Mnemonics Comment
Location operand
RESULT:-
18
SCITS ECE MICROCONTROLLER LAB
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Opcode Mnemonics Comment
Location operand
RESULT:-
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Opcode Mnemonics Comment
Location operand
RESULT:-
19
SCITS ECE MICROCONTROLLER LAB
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Opcode Mnemonics Comment
Location operand
RESULT:-
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Opcode Mnemonics Comment
Location operand
RESULT:-
20
SCITS ECE MICROCONTROLLER LAB
Apparatus:- ASM-SDA-51-MEL
Program:-
RESULT:-
Apparatus:- ASM-SDA-51-MEL
Program:-
RESULT:-
21
SCITS ECE MICROCONTROLLER LAB
Apparatus:- ASM-SDA-51-MEL
Program:-
RESULT:-
Apparatus:- ASM-SDA-51-MEL
Program:-
RESULT:-
22
SCITS ECE MICROCONTROLLER LAB
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Operand Mnemonics Comment
Location operand
RESULT:-
Apparatus:- ASM-SDA-51-MEL
Program:-
Memory Operand Mnemonics Comment
Location operand
RESULT:-
23
SCITS ECE MICROCONTROLLER LAB
CYCLE -2
24
SCITS ECE MICROCONTROLLER LAB
TIMER1 TIMER0
TMOD
RESULT: With the help of Timer1 we can generate different time delays in
mode1 and mode 2 configurations.
ORG 0x0000
MOV TMOD, #20H ; Timer1 mode2 (8-bit auto-reload) for baud rate
generation
MOV TH1, #0FDH ; Load Timer1 for 9600 baudrate
SETB TR1 ; Start Timer1
MOV SCON, #50H ; Mode1, 8-bit UART, enable receiver
MAIN:
; Send data from microcontroller to external device (Arduino IDE serial
monitor)
MOV A, #65 ; Example: ASCII 'A'
MOV SBUF, A ; Send data over serial
ACALL WAIT_FOR_TX_COMPLETE
25
SCITS ECE MICROCONTROLLER LAB
ORG 0x0030
SJMP MAIN ; Jump to main program
END
UART operation in 8051
Transmit mode:
1.Give power supply to ESA 51E kit Transmitter module
2. In ESA 51E kit make DIP switches 5 and 8 ON and short the 2 and 3 pins of
jumpers J2,J6 and J8 to work kit in serial mode.
3.Select My computer on windows right click on it select properties in that select
Hard ware in that select Device manager click on ports verify USB Serial port
(com6/com5)
4. Press RESET key on ESA 51E module ,”SERIAL” will be display on ESA 51E
kit
6. Click START on windows and select Term 51E
5. Press RESET key on ESA 51 E module kit then ESA 51E serial monitor v1.1
will be displayed on PC monitor.
6.Select Settings from the toolbar a window will be display in that verify Baud rate
9600 ,Data bits 8,stop bits 1,parity bits none and select port com6
7. Select download from tool bar Browse for the file SEND.hex click on open
{Down load Browse communication between 2 kitsESA51ESEND.hex}
8. A small window will be displayed in that at memory [P] [D] double click on ‘P’
program will be down loaded from 8000 memory location
26
SCITS ECE MICROCONTROLLER LAB
9.Make DIP switch 5 OFF then press RESET .ESA-51E will be displayed on kit
display.
10.Short the 1 and 2 pins of Jumpers J2,J6,J8 for keyboard mode.
11. Connect the keyboard to the ESA 51E trainer kit.
12. For execution press G8000 from keyboard press ENTER key .
Receive mode:
1.Give power supply to ESA 51E kit Receiver module
2. In ESA 51E kit make DIP switches 5 and 8 ON and short the 2 and 3 pins of
jumpers J2,J6 and J8 to work kit in serial mode.
3.Select My computer on windows right click on it select properties in that select
Hard ware in that select Device manager click on ports verify USB Serial port
(com5)
{My computer properties
HardwareDevice ManagerPortsUSB Serial
port(com5)}
4. Press RESET key on ESA 51E module ,”SERIAL” will be display on ESA 51E
kit
6. Click START on windows and select Term 51E
5. Press RESET key on ESA 51 E module kit then ESA 51E serial monitor v1.1
will be displayed on PC monitor.
6.Select Settings from the toolbar a window will be display in that verify Baud rate
9600 ,Data bits 8,stop bits 1,parity bits none and select port com5
7. Select download from tool bar Browse for the file RECIEVE.hex click on open
{Down load Browse
Communication between 2
kitsESA51ERECIEVE.hex}
8. A small window will be displayed in that at memory [P] [D] double click on ‘P’
program will be down loaded from 8000 memory location
9.Make DIP switch 5 OFF then press RESET .ESA-51E will be displayed on
ESA51E kit display.
10.Short the 1 and 2 pins of Jumpers J2,J6,J8 for keyboard mode.
11. Connect the keyboard to the ESA 51E trainer kit.
12. For execution press G8000 from keyboard press ENTER key .
13. Remove keyboard plug from ESA51E kit.
Communication:
14. Connect RS232 cable between ESA51E transmitter and Receiver.
15. Type any character on the keyboard key will be displayed on ESA51E
Receiver display.
27
SCITS ECE MICROCONTROLLER LAB
28
SCITS ECE MICROCONTROLLER LAB
ADDITION
N1:4555H
N2:6575H
Address Opcode Label Mnemonics Comments
8000 74,55 MOV A,#55H ; Load 55H in A
8002 24,75 ADD A,#75H ;add 75H with A
8004 F5,41 MOV 41,A ; Load A in 41
8006 74,45 MOV A,#45 ; Load 45H in A
8008 34,65 ADD C,#65 ; ADD 65H with C
800A F5,42 MOV 42,A ; Load A in 42
808E 02,0f,00 LJMP ;Long jump
RESULT:
41: CAH
42: AAH
SUBTRACTION
Address Opcode Label Mnemonics Comments
8000 74,55 MOV A,#55H ; Load 55H in A
8002 94,75 SUBB A,#75H ;sub 75H with A
8004 F5,41 MOV 41,A ; Load A in 41
8006 74,45 MOV A,#45 ; Load 45H in A
8008 94,65 SUBB C,#65 ; sub 65H in A
800A F5,42 MOV 42,A ; Load A in 42
808E 02,0f,00 LJMP ;Long jump
N1:4555H
N2:6575H
RESULT:
41: EOH 42: DFH
29
SCITS ECE MICROCONTROLLER LAB
MULTIPLICATION:
Address Opcode Label Mnemonics Comments
8000 74,02 MOV A,#02H ; Load 02h in A
8002 75,F0,04 MOV B,#04H ; Load 04h in B
8005 A4 MUL AB ;Multiply A and B
8006 F5,41 MOV 41,A ;Move content of A into 40 location
8008 E5,F0 MOV A,B ;Move the content of B into A
800A F5,42 MOV 42,A ;Move the content A into 42
800C 74,03 MOV A,#03H location
800E 75,F0,04 MOV B,#04H ; Load 03h in A
8011 A4 MUL AB ; Load 04h in B
8012 25,42 ADD A,42 ; Multiply A and B
8014 F5,42 MOV 42,A ;Add A with content of 42 location
8016 50,02 JNC L ; Move content of A into 42
8018 05,F0 INC B location
801A E5,F0 L: MOV A,B :Jump if No carry
801C F5,43 MOV 43,A ;Increment B
801E 74,02 MOV A,#02H ; Move the content of B into A
8021 75,F0,05 MOV B,#05H ; Move content of A into 43
8024 A4 MUL AB location
8025 25,42 ADD A,42H ;Load 02h in A
8027 F5,42 MOV 42,A ; Load 05h in B
8029 50,02 JNC L1 ; Multiply A and B
802B 05,F0 INC B ; Add A with content of 42 location
802D E5,F0 L1: MOV A,B ; Move content of A into 42
802F F5,43 MOV 43,A location
8032 74,03 MOV A,#03 ; Jump if no carry
8034 75,F0,05 MOV B,#05 ;Increment B
8037 A4 MUL AB ; Move the content of B into A
8038 25,43 ADD A,43 ; Move content of A into 43
803A F5,43 MOV 43,A location
803C 50,02 JNC L2 ;Load 03h in A
803E 05,F0 INC B ; Load 05h in B
8031 E5,FO L2: MOV A,B ; Multiply A and B
8033 F5,44 MOV44,A ; Add A with content of 43 location
8035 02,0F,00 LJMP ; Move content of A into 43
location
; Jump if no carry
;Increment B
; Move the content of B into A
; Move content of A into 44
location
;Long Jump
30
SCITS ECE MICROCONTROLLER LAB
Result:
41 42 43 44
08 16 0F 00
AND OPERATION:
Address Opcode Label Mnemonic Comments
8000 90,12,34 MOV ;DPTR-1234
8003 E5,83 DPTR,#1234 ;Move lower data into A
8005 54,FF MOVA,DPH ;A register data anded with FF
8007 F5,83 ANL A,#FFH ;Move result into DPH
8009 E5,82 MOV DPH,A ;Move DPL data into A
800A 54,00 MOV A,DPL ; A register data andede with FF
800C F5,82 ANL A,#00H ;Move the result into DPL
800E 02,0F,00 MOV DPL,A :End
LJMP
OR Operation
Address Opcode Label Mnemonic Comments
8000 90,12,34 MOV ;DPTR-1234
8003 E5,83 DPTR,#1234 ;Move lower data into A
8005 54,FF MOVA,DPH ;A register data OR with FF
8007 F5,83 ORL A,#FFH ;Move result into DPH
8009 E5,82 MOV DPH,A ;Move DPL data into A
800A 54,00 MOV A,DPL ; A register data andede with FF
800C F5,82 ORL A,#00H ;Move the result into DPL
800E 02,0F,00 MOV DPL,A :End
LJMP
31
SCITS ECE MICROCONTROLLER LAB
XOR Operation
Address Opcode Label Mnemonic Comments
8000 90,12,34 MOV ;DPTR-1234
8003 E5,83 DPTR,#1234 ;Move lower data into A
8005 54,FF MOVA,DPH ;A register data anded with FF
8007 F5,83 XRL A,#FFH ;Move result into DPH
8009 E5,82 MOV DPH,A ;Move DPL data into A
800A 54,00 MOV A,DPL ; A register data andede with FF
800C F5,82 XRL A,#00H ;Move the result into DPL
800E 02,0F,00 MOV DPL,A :End
LJMP
32
SCITS ECE MICROCONTROLLER LAB
SWAP OPERATION
33
SCITS ECE MICROCONTROLLER LAB
CYCLE – 3
PROCEDURE
1) OPEN KEIL UVISION3
2) CLICK ON PROJECT
3) SELECT NEW UVISION PROJECT
4) SAVE WITH PROGRAM NAME
5) CLICK ON FILE
6) SELECT NEW
7) WRITTEN THE PROGRAM
8) SAVE THE PROGRAM WITH ASM EXTENTION
9) TARGET CREATED
10) CLICK ON SOURCE PROJECT
11) ADD FILES TO SOURCE
12) SAVE ALL AND BUILD ALL
13) RIGHT CLICK ON TARGET
14) ADD SOURCE TO TARGET
15) CLICK ON OUTPUT
16) CLICK ON HEX FILE
17) MAKE CONNECTIONS ON 8051 MICRO CONTROLLER KIT
18) SELECT NUVOTON SOFTWARE
19) SELECT BY IC
20) SELECT PORT
21) LOAD FILE( HEX FILE)
22) UPDATE CHIP
23) CLICK ON RESET BUTTON
24) FAIL CLICK K
25) SUCCESS CLICK OK
34
SCITS ECE MICROCONTROLLER LAB
APPARATUES REQUIRED:
i) 8051 microcontroller
ii) keil 3 software
iii) Nuvoton software
PROGRAM:
;P2.0-P2.3 CONNECT TO ROW--> O/P
;P2.4-P2.7 CONNECT TO COLUMNS --> I/O
/*
Port P1 to P5
Port P2 to P6
Port P4 to P7
*/
ORG 0000H
MOV P0,#00H
MOV P1,#00H
SETB P2.4
SETB P2.5
SETB P2.6
SETB P2.7
K1: MOV P2,#0F0H ;MAKE PORT 2 AN OUTPUT PORT
MOV A,P2 ;READ ALL COL.ENSURE ALL KEY ARE
OPEN
ANL A,#11110000B ;MASKED UNUSED BITS
CJNE A,#1111000B,K2 ;CHECK TILL ALL KEYS RELEASED
35
SCITS ECE MICROCONTROLLER LAB
DELAY:
MOV R5,#0
36
SCITS ECE MICROCONTROLLER LAB
END
RESULT:
APPARATUES REQUIRED:
i) 8051 microcontroller
ii) keil 3 software
iii) Nuvoton software
PROGRAM:
;P2.0-P2.3 CONNECT TO ROW--> O/P
;P2.4-P2.7 CONNECT TO COLUMNS --> I/O
/*
Port P1 to P5
Port P2 to P6
Port P4 to P7
*/
ORG 0000H
MOV P0,#00H
MOV P1,#00H
37
SCITS ECE MICROCONTROLLER LAB
SETB P2.4
SETB P2.5
SETB P2.6
SETB P2.7
K1: MOV P2,#0F0H ;MAKE PORT 2 AN OUTPUT PORT
MOV A,P2 ;READ ALL COL.ENSURE ALL KEY ARE
OPEN
ANL A,#11110000B ;MASKED UNUSED BITS
CJNE A,#1111000B,K2 ;CHECK TILL ALL KEYS RELEASED
38
SCITS ECE MICROCONTROLLER LAB
DELAY:
MOV R5,#0
HERE1: MOV R4,#1
HERE2: MOV R3,#255
HERE3: DJNZ R3,HERE3
DJNZ R4,HERE2
DJNZ R2,HERE1
RET
END
RESULT:
39
SCITS ECE MICROCONTROLLER LAB
APPARATUES REQUIRED:
i) 8051 microcontroller
ii) keil 3 software
iii) Nuvoton software
PROGRAM:
ORG 0x0000
MOV TMOD, #20H ; Timer1 mode2 (8-bit auto-reload) for baud rate
generation
MOV TH1, #0FDH ; Load Timer1 for 9600 baudrate
SETB TR1 ; Start Timer1
MOV SCON, #50H ; Mode1, 8-bit UART, enable receiver
MAIN:
MOV R1, #0 ; Initialize counter
SEND_SEQUENCE:
MOV A, R1 ; Load counter value to accumulator
ADD A, #30H ; Convert counter value to ASCII
MOV SBUF, A ; Send ASCII character over serial
ACALL DELAY ; Delay for a while
INC R1 ; Increment counter
CJNE R1, #10, SEND_SEQUENCE ; Repeat until counter reaches 10
40
SCITS ECE MICROCONTROLLER LAB
ORG 0x0030
SJMP MAIN ; Jump to main program
END
RESULT
APPARATUES REQUIRED:
i) 8051 microcontroller
ii) keil 3 software
iii) Nuvoton software
PROGRAM:
ORG 000H
RS BIT P0.4;RS=P0.4
RW BIT P0.5 ;RW=P0.5
E BIT P0.6 ;E=P0.6
41
SCITS ECE MICROCONTROLLER LAB
HERE:
42
SCITS ECE MICROCONTROLLER LAB
ACALL READ_ADC
ACALL DATA_CONVERTION
MOV A,42H
ADD A,#30H
ACALL DATA_DISPLAY
MOV A,41H
ADD A,#30H
ACALL DATA_DISPLAY
MOV A,40H
ADD A,#30H
ACALL DATA_DISPLAY
COMMAND:
MOV LCD_DATABUS,A ;ISSUE COMMAND CODE
CLR RS ;RS=0,FOR COMMAND
CLR RW ;RW=0,TO WRITE THE LCD
SETB E ;E=1,FOR H-L PULSE
ACALL DELAY ;GIVE LCD SOME TIME
NOP
CLR E ;E=0,LATCH IN
RET
DATA_DISPLAY:
MOV LCD_DATABUS,A ;ISSUE DATA
SETB RS ;RS=1 FOR DATA
CLR RW ;R/W=0,TO WRITE TO LCD
SETB E ;E=1 FOR H-L PULSE
ACALL DELAY1 ;GIVE LCD SOME TIME
CLR E ;E=0,LATCH IN
RET
READ_ADC:
MOV 30H,ADC_DATABUS
RET
43
SCITS ECE MICROCONTROLLER LAB
DATA_CONVERTION:
MOV A,30H
MOV B,#10
DIV AB
MOV 40H,B ;LSB BIT
MOV B,#10
DIV AB
MOV 41H,B
MOV 42H,A
RET
DELAY:
MOV R3,#250 ;R3=250
HERE2: MOV R4,#255 ;R4=255
HERE1: DJNZ R4,HERE1 ;STAY UNTIL R4 BECOME 0
DJNZ R3,HERE2
RET ;RETURN TO MAIN PROGRAM
DELAY1:
MOV R1,#50 ;R3=50
HERE4: MOV R2,#55 ;R4=55
HERE3: DJNZ R2,HERE3 ;STAY UNTIL R4 BECOME 0
DJNZ R1,HERE4
RET ;RETURN TO MAIN PROGRAM
RESULT:
APPARATUS REQUIRED:
i) 8051 microcontroller
ii) keil 3 software
iii) Nuvoton software
PROGRAM:
44
SCITS ECE MICROCONTROLLER LAB
RESULT:
CYCLE -4
45
SCITS ECE MICROCONTROLLER LAB
Procedure
46
SCITS ECE MICROCONTROLLER LAB
APPARATUS REQUIRED :
1) LPC1768 cortex M3 Development Board.
2) Female to Female Jumper wires.
3) 12v/1.2 Ah Adaptor.
4) RS232 to USB converter for programming Cortex M3.
5) Power Jack.
6) KEIL 4 SOFTWARE
7) FLASH MAGIC
PROGRAMME:
#include <LPC17xx.h>
/*******STCTRL bits*******/
#define SBIT_ENABLE 0
#define SBIT_TICKINT 1
#define SBIT_CLKSOURCE 2
47
SCITS ECE MICROCONTROLLER LAB
/* Enable the Systick, Systick Interrup and select CPU Clock Source */
STCTRL = (1<<SBIT_ENABLE) | (1<<SBIT_TICKINT) |
(1<<SBIT_CLKSOURCE);
while(1)
{
//do nothing
}
}
void SysTick_Handler(void)
{
LPC_GPIO2->FIOPIN ^= (1<<LED); /* Toggle the LED1 (P2_0) */
}
RESULT:
APPARATUS REQUIRED :
1) LPC1768 cortex M3 Development Board.
2) Female to Female Jumper wires.
3) 12v/1.2 Ah Adaptor.
4) RS232 to USB converter for programming Cortex M3.
5) Power Jack.
6) KEIL 4 SOFTWARE
7) FLASH MAGIC
48
SCITS ECE MICROCONTROLLER LAB
PROGRAMME:
#include "uart.h"
#include "rtc.h"
#include "delay.h"
int main()
{
uint16_t year;
uint8_t hour, min, sec, date, month;
SystemInit();
while(1)
{
/* Read Time */
hour = LPC_RTC->HOUR;
min = LPC_RTC->MIN;
sec = LPC_RTC->SEC;
/* Read Date */
date = LPC_RTC->DOM;
month = LPC_RTC->MONTH;
49
SCITS ECE MICROCONTROLLER LAB
year = LPC_RTC->YEAR;
/*UARTx_Printf, where suffix "x" specifies the UART channel(0-3)*/
UART0_Printf("Time: %2d:%2d:%2d",hour,min,sec);
UART0_Printf(" Date: %2d/%2d/%4u",date,month,year);
DELAY_ms(1000);
UART_TxChar(0,0x0D); // Carriage return
UART_TxChar(0,0x0A); // New line
}
}
RESULT:
PROGRAMME:
#include <lpc17xx.h>
#include "pwm.h"
#include "delay.h"
50
SCITS ECE MICROCONTROLLER LAB
while(1)
{
for(dutyCycle=0;dutyCycle<CYCLE_TIME;dutyCycle++) /* Increase the
Brightness of the Leds */
{
PWM_SetDutyCycle(PWM_1,dutyCycle); //P2_0
DELAY_ms(30);
}
DELAY_ms(2000);
for(dutyCycle=CYCLE_TIME;dutyCycle>0;dutyCycle--) /* Decrease the
Brightness of the Leds */
{
PWM_SetDutyCycle(PWM_1,dutyCycle); //P2_0
DELAY_ms(30);
}
DELAY_ms(2000);
}
}
RESULT:
APPARATUS REQUIRED :
1) LPC1768 cortex M3 Development Board.
2) Female to Female Jumper wires.
3) 12v/1.2 Ah Adaptor.
4) RS232 to USB converter for programming Cortex M3.
5) Power Jack.
6) KEIL 4 SOFTWARE
7) FLASH MAGIC
51
SCITS ECE MICROCONTROLLER LAB
PROGRAM:
#include <lpc17xx.h>
#include "stdutils.h"
#include "gpio.h"
#include "extintr.h"
void myExtIntrIsr_0(void)
{
GPIO_PinToggle(LED1); /* Toggle the LED1 (P2_0) */
}
void myExtIntrIsr_1(void)
{
GPIO_PinToggle(LED2); /* Toggle the LED2 (P2_1) */
}
EINT_AttachInterrupt(EINT0,myExtIntrIsr_0,FALLING); /* myExtIntrIsr_0
will be called by EINT0_IRQHandler */
EINT_AttachInterrupt(EINT1,myExtIntrIsr_1,FALLING); /* myExtIntrIsr_1
will be called by EINT1_IRQHandler */
while(1)
{
//do nothing
}
}
RESULT:
52
SCITS ECE MICROCONTROLLER LAB
53