From 9e92c35cb759563058676ea1528f6c11d89d2d86 Mon Sep 17 00:00:00 2001 From: hackbard Date: Tue, 13 Dec 2011 21:21:07 +0100 Subject: [PATCH] initial checkin for moritz's rgb lights (untested!) --- beginners/rgb_moritz.asm | 133 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 beginners/rgb_moritz.asm diff --git a/beginners/rgb_moritz.asm b/beginners/rgb_moritz.asm new file mode 100644 index 0000000..51e4c32 --- /dev/null +++ b/beginners/rgb_moritz.asm @@ -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< 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 + -- 2.39.2