Implemented signal a, wrote Makefile and some gdb config
This commit is contained in:
parent
b68b15d201
commit
6b696180d2
|
@ -0,0 +1,11 @@
|
|||
# Connect to simavr server
|
||||
target remote :1234
|
||||
|
||||
# Print the registers and code at each step
|
||||
def hook-stop
|
||||
i r
|
||||
disass
|
||||
end
|
||||
|
||||
# Here you can put a breakpoint to skip some code
|
||||
b ENCODE
|
|
@ -3,14 +3,17 @@ BINARY=segment
|
|||
AS=avr-as
|
||||
LD=avr-ld
|
||||
OBJCOPY=avr-objcopy
|
||||
AVRDUDE=avrdude
|
||||
GDB=avr-gdb
|
||||
|
||||
AVRDUDE=avrdude
|
||||
AVRDUDE_CONFIG=/etc/avrdude.conf
|
||||
|
||||
TTY=/dev/ttyACM0
|
||||
|
||||
ARCH=atmega328p
|
||||
|
||||
SIMAVR=simavr
|
||||
|
||||
build:
|
||||
$(AS) -g -mmcu=$(ARCH) -o $(BINARY).o $(BINARY).s
|
||||
$(LD) -o $(BINARY).elf $(BINARY).o
|
||||
|
@ -19,6 +22,13 @@ build:
|
|||
upload:
|
||||
$(AVRDUDE) -C $(AVRDUDE_CONFIG) -p $(ARCH) -c arduino -P $(TTY) -b 115200 -D -U flash:w:$(BINARY).hex:i
|
||||
|
||||
sim:
|
||||
$(SIMAVR) -m $(ARCH) $(BINARY).elf -g
|
||||
|
||||
debug:
|
||||
$(GDB) $(BINARY).elf
|
||||
|
||||
|
||||
run: build upload
|
||||
|
||||
clean:
|
||||
|
|
|
@ -13,6 +13,23 @@
|
|||
.equ PORTD, 0x0B
|
||||
.equ DDRD, 0x0A
|
||||
|
||||
; Aliases for registers. It is easier to develop the logic this way.
|
||||
|
||||
.equiv ABIT, 17
|
||||
.equiv BBIT, 18
|
||||
.equiv CBIT, 19
|
||||
.equiv DBIT, 20
|
||||
.equiv RESULT, 21
|
||||
.equiv TEMP1, 22
|
||||
.equiv TEMP2, 23
|
||||
|
||||
; Aliases for PINs connected to the 7 segment display. These are the
|
||||
; values written in PORTD. DIGITAL PINs 0-6 are connected to PINs a-g
|
||||
; of the 7 segment display.
|
||||
|
||||
; TO BE IMPLEMENTED
|
||||
|
||||
|
||||
.org 0x0000
|
||||
|
||||
rjmp INIT
|
||||
|
@ -65,6 +82,68 @@ COUNTER:
|
|||
|
||||
ENCODE:
|
||||
|
||||
; Description:
|
||||
; -----------
|
||||
;
|
||||
; To represent a digit we will use a 4 bit number looking like this DCBA
|
||||
; (A is the LSB and D is the MSB). The equations for the 7 segment display
|
||||
; PINs are the following, they can be easily computed using Karnaugh
|
||||
; Diagrams:
|
||||
;
|
||||
; a = A + C + BD + !B!D
|
||||
; b = !B + !C!D + CD
|
||||
; c = B + !C + D
|
||||
; d = !B!D + C!D + B!CD + !BC + A
|
||||
; e = !b!d + C!D
|
||||
; f = A + !C!D + B!C + B!D
|
||||
; g = A + B!C + !BC + C!D
|
||||
;
|
||||
; Each PIN equation will be computed in r21 and sent to its corresponding
|
||||
; PIN. Other registers will be used to extract the bits from the binary
|
||||
; number and to perform logic operations.
|
||||
|
||||
mov ABIT, r24
|
||||
andi ABIT, 0x01
|
||||
|
||||
mov BBIT, r24
|
||||
asr BBIT
|
||||
andi BBIT, 0x01
|
||||
|
||||
mov CBIT, r24
|
||||
asr CBIT
|
||||
asr CBIT
|
||||
andi CBIT, 0x01
|
||||
|
||||
mov DBIT, r24
|
||||
asr DBIT
|
||||
asr DBIT
|
||||
asr DBIT
|
||||
|
||||
; Compute a. Steps:
|
||||
;
|
||||
; 1. Move A in RESULT and perform OR with C
|
||||
; 2. Move B in TEMP1 and perform AND with B
|
||||
; 3. Perform OR between (A + C) and BD
|
||||
; 4. Move B in TEMP1, perform or with D and negate the result (!B!D = !(B + D))
|
||||
; (to negate all the bits we will use exclusive or between the register
|
||||
; and the value 0xFF)
|
||||
; 5. Perform OR between (A + C + BD) and !B!D
|
||||
|
||||
mov RESULT, ABIT
|
||||
|
||||
or RESULT, CBIT
|
||||
|
||||
mov TEMP1, BBIT
|
||||
and TEMP1, DBIT
|
||||
or RESULT, TEMP1
|
||||
|
||||
mov TEMP1, BBIT
|
||||
or TEMP1, DBIT
|
||||
ldi TEMP2, 0xFF
|
||||
eor TEMP1, TEMP2
|
||||
andi TEMP1, 0x01
|
||||
and RESULT, TEMP1
|
||||
|
||||
ret
|
||||
|
||||
WAIT:
|
||||
|
|
Loading…
Reference in New Issue