[First construction]
This commit is contained in:
commit
fd1f7eb731
5 changed files with 60 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
*.elf
|
||||||
|
*.hex
|
||||||
|
*.o
|
4
build.sh
Executable file
4
build.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/zsh
|
||||||
|
avr-as -mmcu=atmega328p -o main.o main.s
|
||||||
|
avr-ld -o main.elf main.o
|
||||||
|
avr-objcopy -O ihex main.elf main.hex
|
3
flash.sh
Executable file
3
flash.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/zsh
|
||||||
|
DEVICE=/dev/ttyACM0
|
||||||
|
sudo avrdude -p m328p -c arduino -P $DEVICE -U flash:w:main.hex
|
38
main.s
Normal file
38
main.s
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
.equ DDRB, 0x04
|
||||||
|
.equ PORTB, 0x05
|
||||||
|
|
||||||
|
.global main
|
||||||
|
|
||||||
|
main:
|
||||||
|
ldi r16, 1
|
||||||
|
out DDRB, r16
|
||||||
|
ldi r16, 0
|
||||||
|
out PORTB, r16
|
||||||
|
loop_start:
|
||||||
|
com r16
|
||||||
|
out PORTB, r16
|
||||||
|
init_sleep:
|
||||||
|
ldi r18, 0xFF
|
||||||
|
ldi r19, 0xFF
|
||||||
|
ldi r20, 0xFF
|
||||||
|
sleep_outer:
|
||||||
|
cpi r18, 0x00
|
||||||
|
breq loop_start
|
||||||
|
dec r18
|
||||||
|
rjmp sleep_inner1
|
||||||
|
sleep_inner0:
|
||||||
|
cpi r19, 0
|
||||||
|
breq sleep_inner0_reset
|
||||||
|
dec r19
|
||||||
|
rjmp sleep_inner1
|
||||||
|
sleep_inner0_reset:
|
||||||
|
ldi r19, 0xFF
|
||||||
|
rjmp sleep_outer
|
||||||
|
sleep_inner1:
|
||||||
|
cpi r20, 0
|
||||||
|
breq sleep_inner1_reset
|
||||||
|
dec r20
|
||||||
|
rjmp sleep_inner1
|
||||||
|
sleep_inner1_reset:
|
||||||
|
ldi r20, 0x1F
|
||||||
|
rjmp sleep_inner0
|
12
readme.md
Normal file
12
readme.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# ATMega328P Blinking LED Assembly
|
||||||
|
|
||||||
|
Toggle a LED about every second with 20MHz.
|
||||||
|
|
||||||
|
## Breadboard structure
|
||||||
|
|
||||||
|
PIN8 > LED > 220Ohm Resistor > GND
|
||||||
|
|
||||||
|
## Used packages (Linux)
|
||||||
|
|
||||||
|
- avr-binutils
|
||||||
|
- avrdude
|
Loading…
Reference in a new issue