Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

EEE 4620

Course Teacher:

Dr. Golam Sarowar


Md. Mehedi Hassan Galib

Section: A2 Group: 1

Name Student ID
Nazmus Sakib 142443
Mahmudul Hasan 142445
Md. Faisal Kabir 142447
Ehsan- ul- Islam Abir 142461
Mohammad Dehan Rahman 142463
Abdul Kadiri 142323

Islamic University of Technology (IUT)


A subsidiary organ of OIC
Boardbazar, Gazipur-1704, Bangladesh
LAB 1
Task 1(LED blinking)
ORG 00H
MOV PSW,#00H
MOV SP,#70H
MOV P1,#00H

AGAIN: SETB P1.7


LCALL DELAY
CLR P1.7
LCALL DELAY
LJMP AGAIN
DELAY: MOV R7,#10
L3: MOV R6,#100
L2: MOV R5,#100
L1: DJNZ R5,L1
DJNZ R6,L2
DJNZ R7,L3
RET

END
Discussion:
Our objective was to create a program to blink the LED.
1. At first, we have assigned PSW, SP, P1.
2. We set the bit of P1.7 and then called DELAY subroutine.
3. Then we cleared P1.7 and again called DELAY subroutine.
4. We created a loop so that this operation will continue itself.
LAB 2
TASK 1(consecutive blinking on LED)
SETB P3.0
LCALL DELAY
CLR P3.0
HERE: SETB P3.1
LCALL DELAY
CLR P3.1
SETB P3.2
LCALL DELAY
CLR P3.2
SETB P3.3
LCALL DELAY
CLR P3.3
SETB P3.4
LCALL DELAY
CLR P3.4
SETB P3.5
LCALL DELAY
CLR P3.5
SETB P3.6
LCALL DELAY
CLR P3.6
SETB P3.7
LCALL DELAY
CLR P3.7
SETB P3.6
LCALL DELAY
CLR P3.6
SETB P3.5
LCALL DELAY
CLR P3.5
SETB P3.4
LCALL DELAY
CLR P3.4
SETB P3.3
LCALL DELAY
CLR P3.3
SETB P3.2
LCALL DELAY
CLR P3.2
SETB P3.1
LCALL DELAY
CLR P3.1
SETB P3.0
LCALL DELAY
CLR P3.0
LJMP HERE
DELAY:
MOV R1, #240
MOV R2, #240
HERE1:
AA:
DJNZ R2, AA
DJNZ R1, HERE1
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
RET
END
Discussions:
Task 1:
 In this task we had to blink the leds in this sequence D1 ,D2 ,D3 ,D4, D5, D6 ,D7 ,D8 ,D7 ,
D6 , D5,D4 ,D3, D2, D1.

 P3 wsa connected to the leds accordingly such as P3.0=D1 , P3.1=D2, P3.2=D3, P3.3=D4,
P3.4=D5, P3.5=D6, P3.6=D7, P3.7=D8.
 P3.0 was set, sufficient Delay was given and then it was cleared.
 This procedure was followed sequentially to get the desired result.
TASK 2(Showing 1 to 75 on LED)
ORG 00H

AGAIN: MOV P1,#0H

MOV R0,#4BH

MOV R1,#1H

LOOP1: MOV P1,R1

LCALL DELAY

LCALL DELAY

INC R1

DJNZ R0,LOOP1

MOV R0,#4BH

MOV R1,#4BH

LOOP2: MOV P1,R1

LCALL DELAY

LCALL DELAY

DEC R1

DJNZ R0,LOOP2

LJMP AGAIN

DELAY:

MOV R3,#240

HERE: MOV R2,#240

AA: NOP

NOP

NOP

NOP

NOP

DJNZ R2,AA

DJNZ R3,HERE
RET

END

Discussion
Task 2:
 In this task we had to increment and decrement numbers 1~75 , which will be
represented in 8 leds
 We connected port 1(P1) to the leds
 We cleared P1
 Firstly, we incremented numbers 1-75
 We assigned R0=75 and R1=1
 We created a loop in which P1 gets the value of R1 and before the end of the loop R1
was incremented and the loop would go on until R0 is 0. So, P1 is incremented from 1 to
75.
 Secondly, we decremented numbers 75-1
 We assigned R0=75 and R1=75
 We created a loop in which P1 gets the value of R1 and before the end of the loop R1 was
decremented and the loop would go on until R0 is 0. So, P1 is decremented from 75 to 1
 Convenient Time Delay was given in both loops for us to see the changes in the leds.

TASK 3(blinking patterned LED)


ORG 100h

HERE: MOV P3,#0FFH

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV P3,#0

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV P3,#0FFH

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV P3,#0

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV P3,#0FFH

LCALL DELAY

LCALL DELAY

LCALL DELAY

MOV P3,#0

SETB P3.3

SETB P3.4

LCALL DELAY
CLR P3.3

CLR P3.4

SETB P3.2

SETB P3.5

LCALL DELAY

CLR P3.2

CLR P3.5

SETB P3.1

SETB P3.6

LCALL DELAY

CLR P3.1

CLR P3.6

SETB P3.0

SETB P3.7

LCALL DELAY

CLR P3.0

CLR P3.7

SETB P3.1

SETB P3.6

LCALL DELAY

CLR P3.1

CLR P3.6

SETB P3.2

SETB P3.5

LCALL DELAY

CLR P3.2

CLR P3.5

SETB P3.3

SETB P3.4
LCALL DELAY

CLR P3.3

CLR P3.4

LJMP HERE

DELAY:

MOV R1,#240

MOV R2,#240

HERE1:

AA:

DJNZ R2,AA

DJNZ R1,HERE1

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

NOP

RET

END
Discussion
Task 3:
 In this task was divide into two parts

 P3 wsa connected to the leds accordingly such as P3.0=D1 , P3.1=D2, P3.2=D3, P3.3=D4,
P3.4=D5, P3.5=D6, P3.6=D7, P3.7=D8.
 P3 was cleared

Part1:
 In this part we had to turn ON and OFF the 8 leds a total of 6 times.
 So, P1 was given 0FFH so all the leds were ON
 Convenient Time Delay was given .
 Then, P1 was cleared so all the leds were OFF
 Convenient Time Delay was given .
 This procedure was done 2 more times. So, leds were turned On and OFF a total of 6 times.

Part2:
 In this part we had to turn ON D4 and D5 at the same time by giving 1 to P3.3 and P3.4 ,delay
was given and then P3.3 and P3.4 were cleared.
 And then we had to turn ON D3 and D6 at the same time by giving 1 to P3.2 and P3.5 ,delay was
given and then P3.2 and P3.5 were cleared.
 This way when led D1 and D8 were turned on reverse approach was taken until D4 and D5 were
again tarned ON.

LAB 3
Task 1(showing GROUP number; #EEE 01)
RS BIT P2.0

RW BIT P2.1

E BIT P2.2

MOV A,#38H

LCALL CMDWRT

NOP

MOV A,#0FH

LCALL CMDWRT

NOP

MOV A,#01H

LCALL CMDWRT

NOP

MOV A,#06H

LCALL CMDWRT

NOP

MOV A,#80H

LCALL CMDWRT

NOP

MOV A,#'E'

LCALL DATWRT

NOP

MOV A,#'E'

LCALL DATWRT
NOP

MOV A,#'E'

LCALL DATWRT

NOP

MOV A,#' '

LCALL DATWRT

NOP

MOV A,#'#'

LCALL DATWRT

NOP

MOV A,#'0'

LCALL DATWRT

NOP

MOV A,#'1'

LCALL DATWRT

NOP

HERE: SJMP HERE

BUSYCHK:SETB P1.7

CLR RS

SETB RW

AGAIN: CLR E

NOP

SETB E

JB P1.7, AGAIN

RET

CMDWRT: LCALL BUSYCHK

MOV P1,A

CLR RS

CLR RW
SETB E

NOP

CLR E

RET

DATWRT: LCALL BUSYCHK

MOV P1,A

SETB RS

CLR RW

SETB E

NOP

CLR E

RET

END
Discussion
TASK 1
In the first task we had to show EEE #01. For this we first initialised the LCD with command write CMDWRT
subroutine. This subroutine does all the necessary tasks that is needed to pass a data to the LCD. Then the
characters ‘E’,’ ’,’#’,’0’,’1’ were were displayed to the LCD with the help of the data write DATWRT
command. This command basically displays what has been passed to the LCD.

Task 2(up counter)


ORG 00H

RS BIT P2.0

RW BIT P2.1

E BIT P2.2

U BIT P2.3

SETB U

MOV R6, #30H

MOV R7, #30H

MOV DPTR, #NUM

MOV 51H, #9

MOV A, #38H

LCALL CMDWRT

LCALL DELAY

MOV A, #0FH

LCALL CMDWRT

LCALL DELAY

MOV A, #01H

LCALL CMDWRT

LCALL DELAY

MOV A, #06H
LCALL CMDWRT

LCALL DELAY

MOV A, #80H

LCALL CMDWRT

LCALL DELAY

START: MOV A, #01H

LCALL CMDWRT

CLR A

MOVC A, @A+DPTR

LCALL DATWRT

LCALL DELAY

LCALL DATWRT

CL: JB U, CL

MOV A, #01H

LCALL CMDWRT

INC R7

MOV A, R6

LCALL DATWRT

MOV A, R7

LCALL DATWRT

DG2: JNB U, DG2

CJNE R7, #39H, CL

INC R6

MOV R7, #2FH

CJNE R6, #39H, CL

SJMP START

NUM: DB "0123456789"

CMDWRT: LCALL BUSYCHK

MOV P1,A
CLR RS

CLR RW

SETB E

LCALL DELAY

CLR E

RET

DATWRT: LCALL BUSYCHK

MOV P1, A

SETB RS

CLR RW

SETB E

LCALL DELAY

CLR E

RET

BUSYCHK: SETB P1.7

CLR RS

SETB RW

AGAIN: CLR E

LCALL DELAY

SETB E

JB P1.7, AGAIN

RET

DELAY: MOV 40H, #200

L2: MOV 41H, #200

L1: DJNZ 41H, L1

DJNZ 40H, L2

RET

EXIT: SJMP $

END
Discussion
TASK 2
In this task we used the up counter. Every time the switch was pressed the number increased. This has
been done from 0 to 99. Two registers were used for this task. Register R7 is the LSB and register R6 is
the MSB. Every time the switch has been pressed R7 is increased. Whenever R7 becomes 9, the ascii
value before 0 is moved to R7 so that upon next increment the value becomes 0. R6 is increased. This
process is repeated till 99.

LAB 4
TASK 1 (SHOWING 0 TO 9 IN 7SEGMENT)
ORG 00H

SW1 BIT P2.0

MOV P1,#00
MOV P1,#3FH

LCALL DELAY

MOV P1,#06H

LCALL DELAY

MOV P1,#5BH

LCALL DELAY

MOV P1,#4FH

LCALL DELAY

MOV P1,#66H

LCALL DELAY

MOV P1,#6DH

LCALL DELAY

MOV P1,#7DH

LCALL DELAY

MOV P1,#07H

LCALL DELAY

MOV P1,#7FH

LCALL DELAY

MOV P1,#6FH

LCALL DELAY

SJMP $

DELAY:

MOV R3,#240

HERE: MOV R2,#240

AA: NOP

NOP

NOP

NOP

NOP
DJNZ R2,AA

DJNZ R3,HERE

RET

END
Discussion
TASK 1
In this task we counted from 0 to 9 and displayed it in a 7 segment. To do this we connected the
7 segment to port 1 and via coding transferred data to 7 segment. We gave a delay so that we
can observe the digits.

TASK 2(showing two different digits in 7segment)


ORG 00H

BACK:

SETB P2.1

CLR P2.0

MOV P1,#07H

ACALL DELAY

SETB P2.0

CLR P2.1

MOV P1,#06H

ACALL DELAY

SJMP BACK

DELAY: MOV R5,#7

L2: MOV R7,#255

L1: DJNZ R7,L1

DJNZ R5,L2

RET

END
Discussion
TASK 2
In this task we showed 2 different digits in the 7 segments, e.g. 23, 45 and so on. We used P2.0
and P2.1 as switches. Via coding we displayed the first digit in the 7 segment. Then we give a
small delay that the human eye cannot detect. Then we show the next digit in the 7 segment.
For e.g we show 5 first, small delay, then show 4. Using a short jump at the end we continue
this process.
TASK 3 (SHOWING 0 TO 99 IN 7SEGMENT)
ORG 0H

D3 BIT P2.2

D4 BIT P2.3

MOV R4,#0

MOV DPTR,#MYDATA

HERE1:

MOV R3,#10

HERE:

MOV A,R4

LCALL CONV

MOV A,R2

MOVC A,@A+DPTR

MOV P1,A

LCALL D3_ON

LCALL DELAY

MOV A,R1

MOVC A,@A+DPTR

MOV P1,A

LCALL D4_ON

LCALL DELAY

DJNZ R3,HERE

INC R4

CJNE R4,#100,HERE1

SJMP $

DELAY:

MOV TMOD,#01 ;TIMER 0 MODE 1


MOV R0,#45

AGAIN: MOV TL0,#65H

MOV TH0,#0FCH

SETB TR0 ;START THE TIMER

BACK: JNB TF0,BACK ;WAIT FOR ROLL-OVER

CLR TR0 ;STOP THE TIMER

CLR TF0 ;CLEAR THE OVERFLOW FLAG

DJNZ R0,AGAIN

RET

D3_ON:

CLR D3

SETB D4

RET

D4_ON:

SETB D3

CLR D4

RET

MYDATA: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH

END
Discussion
TASK 3
In this task we counted from 0 to 99. We set a counter to 100, so that we can count from 0 to 100. By
setting R3 to 10 we count upto 9. After that we increment R4 which is our MSD and the process
continues upto 99. By using Lcall D3_On and Lcall D4_On on and off the switches. The values are stored
in the look up table and by using DPTR we access them.

LAB 5
TASK 2(show voltage difference on LCD)
ORG 00H

MOV A,#255

MOV 40H,A

MOV 41H,A

RS BIT P2.0

RW BIT P2.1

E BIT P2.2

MOV P3,#0FFH ; INPUT

START:

MOV R0,P3

ACALL DELAY

BIN_DEC_CONV:

MOV A,P3

MOV B,#19D

MUL AB

MOV R7,A

MOV R6,B

BIN2BCD:

MOV R1,#00D ;#!Clear R1

MOV R2,#00D ;#!Clear R2


MOV R3,#00D ;#!Clear R3

MOV R4,#00D ;#!Clear R4

MOV R5,#00D ;#!Clear R5

MOV B,#10D

MOV A,R7 ;#!Get the low data byte

DIV AB ;#!Divide it by 10

MOV R1,B ;#!Save the first digit in R1

MOV B,#10

DIV AB ;#!Divide by 10 once

MOV R2,B ;#!Save the next digit in R2

MOV R3,A ;#!Save the last digit in R3

MOV A,R6 ;#!Get the high data byte

CJNE A,#0H,NEXT ;#!Check on it

LJMP PRINT ;#!If it contains nothing, Jump to print output

NEXT: MOV A,#6D ;#!If there was Value at DB1, Decrement and.

ADD A,R1 ;#!Add 265 to corresponding digits on R1, R2 & R3

MOV B,#10D

DIV AB

MOV R1,B ;#!Save remainder after adding 6 on R1

ADD A,#5D

ADD A,R2

MOV B,#10D

DIV AB

MOV R2,B ;#!Save remainder after adding 5 on R2

ADD A,#2D

ADD A,R3

MOV B,#10D

DIV AB

MOV R3,B ;#!Save remainder after adding 6 on R3


ADD A,R4

MOV R4,A

DJNZ R6,NEXT ;#!Decrement DB1 and do process if it still not zero

MOV B,#10D ;#!If zero stop looping and add remainder to R4 & R5

MOV A,R4

DIV AB

MOV R4,B

MOV R5,A

PRINT:

DISPLAY_IN_LCD:

MOV DPTR,#MYCOM

C1:

CLR A

MOVC A,@A+DPTR

ACALL COMNWRT

ACALL DELAY

JZ SEND_DATA

INC DPTR

SJMP C1

SEND_DATA:

D1:

MOV A,R5

ORL A,#30H

ACALL DATAWRT

ACALL DELAY

MOV A,R4

ORL A,#30H

ACALL DATAWRT

ACALL DELAY
MOV A,R3

ORL A,#30H

ACALL DATAWRT

ACALL DELAY

MOV A,R2

ORL A,#30H

ACALL DATAWRT

ACALL DELAY

MOV A,R1

ORL A,#30H

ACALL DATAWRT

ACALL DELAY

MOV A,#' '

ACALL DATAWRT

ACALL DELAY

MOV A,#'m'

ACALL DATAWRT

ACALL DELAY

MOV A,#'v'

ACALL DATAWRT

ACALL DELAY

MOV A,R0

BACK: CJNE A,P3,L_LOOP

SJMP BACK

L_LOOP:

LJMP START

COMNWRT:

MOV P1,A

CLR RS
CLR RW

SETB E

ACALL DELAY

CLR E

RET

DATAWRT:

MOV P1,A

SETB RS

CLR RW

SETB E

ACALL DELAY

CLR E

RET

DELAY:

AGAIN3: NOP

AGAIN4: DJNZ 40H,AGAIN4

DJNZ 41H ,AGAIN3

RET

ORG 300H

MYCOM:

DB 38H,0EH,01H,06H,80H,0

END

You might also like