Embedded Systems EasyAVR help You will write one program that must do the follow
ID: 2082069 • Letter: E
Question
Embedded Systems EasyAVR help
You will write one program that must do the following:
• Monitor the buttons attached to PORTB and PORTD and use them to represent 4 BCD numbers (0-9). o A button press sh
ould represent logic one (set properly SW1) in the corresponding bit in the BCD number. So, when all buttons are un-pressed the BCD number should be zero (set pull-downs on all bits on Port B and Port D) o Pins PB3-PB0 (MSB – LSB) represent BCD Digit 1 (BCD1)
Pins PB7-PB4 (MSB – LSB) represent BCD Digit 2 (BCD2)
o Pins PD3-PD0 (MSB – LSB) represent BCD Digit 3 (BCD3)
o Pins PD7-PD4 (MSB – LSB) represent BCD Digit 4 (BCD4)
• Display the 4 BCD digits on the 4 seven-segment displays
o BCD1 digit should be shown on DIS1
o BCD2 digit should be shown on DIS2
o BCD3 digit should be shown on DIS3
o BCD4 digit should be shown on DIS4
• Pressing any invalid combination should display nothing (no segment lighted)
• Create a look-up table for your conversion from BCD to 7-seg display digit. • Create a Macro to send the information to Port C and to turn on and off the corresponding Port A pin to address the proper 7-seg block.
Explanation / Answer
Program:
.MODEL SMALL
.DATA
TABLE DB 3FH ; 0
DB 06H ;1
DB 5BH ;2
DB 4FH ;3
DB 66H ;4
DB 6DH ;5
DB 7DH ;6
DB 07H ;7
DB 7FH ;8
DB 6FH ;9
.CODE
START:
MOV AX, @DATA ; For initialization of Data Segment
MOV DS, AX
MOV AL,08H ; Convert to 7 segment code
MOV BX, OFFSET TABLE
XLAT TABLE
MOV AH, 4CH
INT 21H
END START
END
BCD to 7-Segment display digit:
ORG 1000
MAIN:
MOV P2,#0FEH
LCALL DELAY %LCALL
MOV P2,#0FDH %Mov instruction
LCALL DELAY %LCALL
MOV P2,#0FBH %Mov instruction
LCALL DELAY %LCALL
MOV P2,#0F7H %Mov instruction
LCALL DELAY %LCALL
MOV P2,#0EFH %Mov instruction
LCALL DELAY %LCALL
MOV P2,#0DFH %Mov instruction
LCALL DELAY %LCALL
MOV P2,#0BFH %Mov instruction
LCALL DELAY %LCALL
MOV P2,#7FH %Mov instruction
LCALL DELAY %LCALL
LJMP MAIN;
S
ubro
utine for some delay generation, to
view ;LED blinking
DELAY:
MOV R0,#0FFH
LOOP1:
MOV R1,#05H
LOOP2:
MOV A,#05H
LOOP3:
DEC A
JNZ LOOP3
DJNZ R1,LOOP2
DJNZ R0,LOOP1
RET
END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.