'Assembly 2 digit 7 segment display
I have got a little problem of understanding how is suppose to work. Basically all what I need is to light up a led on each side of 7 segment display. They overlapping each other or only showing on left or right side. If someone can put me on right track will be nice. Thank you.
Something like this
;Port Addresses
.equ DDRA =$1A ;Port A Data Direction Register Address
.equ PORTA =$1B ;Port A Output Address
.equ PINB =$16 ;Port B Input Address
.equ DDRB =$17 ;Port B Data Direction Register Address
.equ PINC =$13 ;Port C Input Address
.equ DDRC =$14 ;Port C Data Direction Register Address
.equ PORTD =$12 ;Port D Output Address
.equ DDRD =$11 ;Port D Dara Direction Register Address
;Register Definitions
.def temp =r16 ;Temporary storage register
;Program Initialisation
;Initialise Input Ports
ldi temp,$00
out DDRB,temp
out DDRC, temp
;Initialise output ports
ldi temp,$FF
out DDRA,temp
out DDRD,temp
loop: ldi r17,$7f ; left side
out PORTA,r17
ldi r18, $ff ; right side
out PORTA,r18
rjmp loop
Solution 1:[1]
There are two types of 7 segment LED displays. The difference is whether the segments turn on when a 1 is applied to the input, or a zero. You have to determine which kind you have, and how the pins of PORTA are connected to the leads of the display.
Other than that, the principle of operation is the same. There are seven segments of the number 8 and a dot. These are controlled by the bits of the number you are sending out PORTA.
$7f is either turning on one segment, or all but one. $ff is turning off all the segments or turning them all on.
You have to determine which segments you want to turn on, and which bits of PORTA controls those segments. You will find that numbers other than $7f and $ff are the numbers you need.
Do you want to be able to see the segments alternating? If so, you will need to include some sort of delay loop. The code right now changes the display too fast for the eye to see.
Solution 2:[2]
Port Addresses
.equ DDRA =$1A ;Port A Data Direction Register Address
.equ PORTA =$1B ;Port A Output Address
.equ PINB =$16 ;Port B Input Address
.equ DDRB =$17 ;Port B Data Direction Register Address
.equ PINC =$13 ;Port C Input Address
.equ DDRC =$14 ;Port C Data Direction Register Address
.equ PORTD =$12 ;Port D Output Address
.equ DDRD =$11 ;Port D Dara Direction Register Address
;Register Definitions
.def temp =r16 ;Temporary storage register
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | uncleO |
Solution 2 | Peter Cordes |