]> hackdaworld.org Git - my-code/atmel.git/commitdiff
initial checkin for moritz's rgb lights (untested!)
authorhackbard <hackbard@tx2.hackdaworld.org>
Tue, 13 Dec 2011 20:21:07 +0000 (21:21 +0100)
committerhackbard <hackbard@tx2.hackdaworld.org>
Tue, 13 Dec 2011 20:21:07 +0000 (21:21 +0100)
beginners/rgb_moritz.asm [new file with mode: 0644]

diff --git a/beginners/rgb_moritz.asm b/beginners/rgb_moritz.asm
new file mode 100644 (file)
index 0000000..51e4c32
--- /dev/null
@@ -0,0 +1,133 @@
+;
+; rgb moritz
+;
+
+; hopefully more improved version of rgb for mali
+
+; author: hackbard@hackdaworld.org
+
+
+.include "../include/2313def.inc"
+
+; defines & equals
+.def zero = r0
+.def one = r1
+.def tmp = r16
+.def count = r17
+.def red = r18
+.def green = r19
+.def blue = r20
+.def rgb_level = r21
+.equ pin_red = 0x01
+.equ pin_green = 0x02
+.equ pin_blue = 0x04
+
+; interrupt vectors
+; reset
+rjmp INIT
+; int0
+reti
+; int1
+reti
+; timer/counter capt 1
+reti
+; timer/counter compare
+reti
+; timer/counter overflow 1
+rjmp TCO1
+; timer/counter overflow 0
+reti
+; uart rx complete
+reti
+; uart data register empty
+reti
+; uart tx complete
+reti
+; analog comparator
+reti
+
+;
+; init routine
+;
+
+INIT:
+
+; stack pointer
+ldi tmp,low(RAMEND)
+out SPL,tmp
+
+; timer: clock/8
+ldi tmp,(1<<CS11)
+out TCCR1B,tmp
+
+; enable timer overflow interrupt
+ldi tmp,(1<<TOIE1)
+out TIMSK,tmp
+
+; register values
+ldi tmp,1
+mov one,tmp
+ldi tmp,0
+mov zero,tmp
+
+; port b 0-2 -> output
+; port b 0-2 -> high
+ldi tmp,0x07
+out DDRB,tmp
+out PORTB,tmp
+
+;
+; more init
+;
+
+; rgb offsets
+mov red,zero
+ldi tmp,85
+mov green,tmp
+ldi tmp,170
+mov blue,tmp
+
+; level init
+ldi rgb_level,0x07
+
+; init count variable
+mov count,zero
+
+;
+; main routine
+; 
+
+MAIN:
+
+rjmp MAIN
+
+TCO1:
+
+cp count,zero
+brne CHECK_RED
+mov rgb_level,zero
+
+CHECK_RED:
+
+cp count,red
+brne CHECK_GREEN
+ori rgb_level,pin_red
+
+CHECK_GREEN:
+
+cp count,green
+brne CHECK_BLUE
+ori rgb_level,pin_green
+
+CHECK_BLUE:
+
+cp count,blue
+brne SET_PORTS
+ori rgb_level,pin_blue
+
+SET_PORTS:
+
+out PORTB,rgb_level
+
+reti
+