HW6

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

Code:

ORG 0000H //student number is 41075043


MOV DPTR, #LOOK
MOV R0, #3 //so the cycle count is 3

LOOP:
MOV R5, #4 //first four digits
MOV R4, #1
MOV R3, #0
MOV R2, #7
ACALL UPDATE

MOV R5, #1 //shift left


MOV R4, #0
MOV R3, #7
MOV R2, #5
ACALL UPDATE

MOV R5, #0 //shift left


MOV R4, #7
MOV R3, #5
MOV R2, #0
ACALL UPDATE

MOV R5, #7 //shift left


MOV R4, #5
MOV R3, #0
MOV R2, #4
ACALL UPDATE

MOV R5, #5 //shift left


MOV R4, #0
MOV R3, #4
MOV R2, #3
ACALL UPDATE
DJNZ R0, CONTI //In order to show just until the
last digit, a stop condition is
SETB P2.3 added here
SETB P2.2
SETB P2.1
SETB P2.0
STOP: SJMP STOP

CONTI: //continue if haven’t cycle 3 time


MOV R5, #0 //shift left
MOV R4, #4
MOV R3, #3
MOV R2, #4
ACALL UPDATE

MOV R5, #4 //shift left


MOV R4, #3
MOV R3, #4
MOV R2, #1
ACALL UPDATE

MOV R5, #3 //shift left


MOV R4, #4
MOV R3, #1
MOV R2, #0
ACALL UPDATE

LJMP LOOP
UPDATE: //update the 7-segment display
MOV 40H, #10 //use 40H, 41H to set delay time
MEDIUM: MOV 41H, #10
AGAIN:
CLR P2.3 //set first digit
SETB P2.2
SETB P2.1
SETB P2.0
MOV A, R5
MOVC A, @A+DPTR
MOV P1, A
ACALL SHORT

SETB P2.3 //set second digit


CLR P2.2
SETB P2.1
SETB P2.0
MOV A, R4
MOVC A, @A+DPTR
MOV P1, A
ACALL SHORT

SETB P2.3 //set third digit


SETB P2.2
CLR P2.1
SETB P2.0
MOV A, R3
MOVC A, @A+DPTR
MOV P1, A
ACALL SHORT

SETB P2.3 //set last digit


SETB P2.2
SETB P2.1
CLR P2.0
MOV A, R2
MOVC A, @A+DPTR
MOV P1, A
ACALL SHORT
DJNZ 41H, AGAIN
DJNZ 40H, MEDIUM
RET

SHORT: //short delay between two digits


MOV R6, #20
SHERE: MOV R7, #35
SHERE2: DJNZ R7, SHERE2
DJNZ R6, SHERE
RET

LOOK: //decimal 0~9 of 7-segment display


DB 11000000B, 11111001B, 10100100B, 10110000B,
10011001B, 10010010B, 10000010B, 11111000B, 10000000B,
10010000B
END //end program

Breadboard Circuit Layout:

Video:

https://youtube.com/shorts/wlERE0SGwX4?feature=share

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy