PG1995
Active Member
Hi,
I wrote this code years ago and at that time I used MCU 8051 IDE. I also have a screenshot when this code was implemented as is shown below.
Now the problem is that I don't remember how this code was implemented using 7-segment display and numeric keypad. I can no longer make it work. I needed to help someone but I don't know how 7-segment display and numeric keypad should be interfaced. Could you please help me?
Ian Rogers , if you don't mind my tagging, could you also please give it a look?
Screenshot taken many years ago:
I wrote this code years ago and at that time I used MCU 8051 IDE. I also have a screenshot when this code was implemented as is shown below.
Now the problem is that I don't remember how this code was implemented using 7-segment display and numeric keypad. I can no longer make it work. I needed to help someone but I don't know how 7-segment display and numeric keypad should be interfaced. Could you please help me?
Ian Rogers , if you don't mind my tagging, could you also please give it a look?
Code:
; Interface a numeric keypad to PORT 0 and display the entered decimal digits
; ,1-9, on a 7-segment display connected to PORT 1
org 0x0
Repeat:
mov P1, #11000000B ; "0" is displayed on the display
mov P0, #0x0FF ;Port 0 is now an input port
mov A, P0
KeepChecking:
mov A, P0
cpl A
JZ KeepChecking
cpl A
CJNE A, #11111110B, DigitIz2
mov P1, #11111001B ;this will diplay "1" on 7-segment display
SJMP Repeat ;execution of the program repeats
DigitIz2:
CJNE A, #11111101B, DigitIz3
mov P1, #10100100B
SJMP Repeat
DigitIz3:
CJNE A, #11111011B, DigitIz4
mov P1, #10110000B
SJMP Repeat
DigitIz4:
CJNE A, #11110111B, DigitIz5
mov P1, #10011001B
SJMP Repeat
DigitIz5:
CJNE A, #11101111B, DigitIz6
mov P1, #10010010B
SJMP Repeat
DigitIz6:
CJNE A, #11011111B, DigitIz7
mov P1, #10000010B
SJMP Repeat
DigitIz7:
CJNE A, #10111111B, DigitIz8
mov P1, #11111000B
SJMP Repeat
DigitIz8:
CJNE A, #01111111B, Error
mov P1, #10000000B
SJMP Repeat
Error:
;CJNE A, #, DigitIz0 ;here digit "0" stands for an error
mov P1, #01111111B ;dot will denote error
SJMP Repeat
end
Screenshot taken many years ago: