Created
April 16, 2016 02:04
-
-
Save hikilaka/47aed9cdfbab8ff5e66672c51d761574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.device ATmega328P | |
.org 0x0000 | |
jmp reset | |
; mem loc for interript 0 | |
.org 0x0002 | |
jmp button_pushed | |
button_pushed: | |
cbi PINB, PINB5 ; disable LED | |
reti | |
reset: | |
sbi DDRB, PINB5 ; set LED to output | |
; initialize the stack | |
ldi r16, LOW(RAMEND) | |
out SPL, r16 | |
ldi r16, HIGH(RAMEND) | |
out SPH, r16 | |
; initalize the EICRA (external interrupt control register) | |
lds r17, EICRA | |
ori r17, 0b00000010 | |
sts EICRA, r17 | |
; enable pin 2 | |
in r18, EIMSK | |
ori r18, 0b00000001 | |
out EIMSK, r18 | |
sbi PINB, PINB5 ; enable LED | |
sei ; enable interrupt handler | |
; loop forever, all logic is done in interrupt handler | |
main: | |
rjmp main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment