Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HAve to implement this task : Lab Assignment 5 - Microcontroller Points: 10 Brea

ID: 2085808 • Letter: H

Question

HAve to implement this task :

Lab Assignment 5 - Microcontroller Points: 10 Breadboard Power supply with cable Wires, resistors, pushbuttons, 7-segment display Arduino Nano EQUIPMENT Build a Decision Circuit using a Microcontroller EXPERIMENT 1 (4 points) Which button was pressed first? it put it is run GND PCd7RINT12AD@ SDA 7 oes! PCINT2/ T1 ADS ~:@ ocaA PCINT22 Anw PD6~:@ o IICP1| PCINTeCLKO PB0E- :@ (8 PC1] PCINT9 AD@ The task is to re-implement the same functionality as done before in hardware, but now using a microcontroller instead

Explanation / Answer

;*************************************************
;
;Program: Driving seven segment display
;Author: Srikanth
;Website: http://shree-electronics.com/
;Description: Displays numbers 0 to 9 on
;the LED seven segment display continuously
;
;*************************************************

;Declarations
port equ P0

;*************************************************

;Main program
org 0000h
ljmp main
org 30h

main:mov r0,#08h
mov a,#00000001b      ;test all segments of disp
up: rr a
mov port,a
acall delay
djnz r0,up
again:mov port,#11111100b ;'0'
acall delay
mov port,#01100000b   ;'1'
acall delay
mov port,#11011010b   ;'2'
acall delay
mov port,#11110010b   ;'3'
acall delay
mov port,#01100110b   ;'4'
acall delay
mov port,#10110110b   ;'5'
acall delay
mov port,#10111110b   ;'6'
acall delay
mov port,#11100000b   ;'7'
acall delay
mov port,#11111110b   ;'8'
acall delay
mov port,#11110110b   ;'9'
acall delay
sjmp again

;*************************************************

delay:mov r2,#0ffh         ;delay subroutine
up3: mov r4,#03fh
up2: mov r3,#0fh
up1: djnz r3,up1
djnz r4,up2
djnz r2,up3
ret

;*************************************************

end

Program.

ORG 000H //initial starting address
START: MOV A,#00001001B // initial value of accumulator
MOV B,A
MOV R0,#0AH //Register R0 initialized as counter which counts from 10 to 0
LABEL: MOV A,B
INC A
MOV B,A
MOVC A,@A+PC // adds the byte in A to the program counters address
MOV P1,A
ACALL DELAY // calls the delay of the timer
DEC R0//Counter R0 decremented by 1
MOV A,R0 // R0 moved to accumulator to check if it is zero in next instruction.
JZ START //Checks accumulator for zero and jumps to START. Done to check if counting has been finished.
SJMP LABEL
DB 3FH // digit drive pattern for 0
DB 06H // digit drive pattern for 1
DB 5BH // digit drive pattern for 2
DB 4FH // digit drive pattern for 3
DB 66H // digit drive pattern for 4
DB 6DH // digit drive pattern for 5
DB 7DH // digit drive pattern for 6
DB 07H // digit drive pattern for 7
DB 7FH // digit drive pattern for 8
DB 6FH // digit drive pattern for 9
DELAY: MOV R4,#05H // subroutine for delay
WAIT1: MOV R3,#00H
WAIT2: MOV R2,#00H
WAIT3: DJNZ R2,WAIT3
DJNZ R3,WAIT2
DJNZ R4,WAIT1
RET
END

or

ORG 000H // initial starting address
MOV P1,#00000000B // clears port 1
MOV R6,#1H // stores "1"
MOV R7,#6H // stores "6"
MOV P3,#00000000B // clears port 3
MOV DPTR,#LABEL1 // loads the adress of line 29 to DPTR
MAIN: MOV A,R6 // "1" is moved to accumulator
SETB P3.0 // activates 1st display
ACALL DISPLAY // calls the display sub routine for getting the pattern for "1"
MOV P1,A // moves the pattern for "1" into port 1
ACALL DELAY // calls the 1ms delay
CLR P3.0 // deactivates the 1st display
MOV A,R7 // "2" is moved to accumulator
SETB P3.1 // activates 2nd display
ACALL DISPLAY // calls the display sub routine for getting the pattern for "2"
MOV P1,A // moves the pattern for "2" into port 1
ACALL DELAY // calls the 1ms delay
CLR P3.1 // deactivates the 2nd display
SJMP MAIN // jumps back to main and cycle is repeated
DELAY: MOV R3,#02H
DEL1: MOV R2,#0FAH
DEL2: DJNZ R2,DEL2
DJNZ R3,DEL1
RET
DISPLAY: MOVC A,@A+DPTR // adds the byte in A to the address in DPTR and loads A with data present in the resultant address
RET
LABEL1:DB 3FH
DB 06H
DB 5BH
DB 4FH
DB 66H
DB 6DH
DB 7DH
DB 07H
DB 7FH
DB 6FH

END