Skip to content

Instantly share code, notes, and snippets.

@numinit
Created June 18, 2012 05:40
Show Gist options
  • Save numinit/2947007 to your computer and use it in GitHub Desktop.
Save numinit/2947007 to your computer and use it in GitHub Desktop.
#include <avr/io.h>
.org 0x0000
rjmp run
run:
; Clear r1
clr r1
; Load 0x01 into r16 for use later
ldi r16, 0x01
; Load the data direction of DIRSET into r17
lds r17, PORTD_DIRSET
; OR with r16
or r17, r16
; Commit the data direction
sts PORTD_DIRSET, r17
; No interrupts
cli
; Loop
rjmp loop
loop:
; Load the OUTTGL register into r17
lds r17, PORTD_OUTTGL
; OR with r16
or r17, r16
; Commit
sts PORTD_OUTTGL, r17
; Delay loop
rjmp delay
delay:
; Load a 50 millisecond delay
ldi r24, 0xa8 ; 168
ldi r25, 0x7d ; 125
; Optimized delay loop
sbiw r24, 0x01
brne .-4
; Back to the loop
rjmp loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment