projects
/
my-code
/
atmel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a60a7ce
)
fading lieghts, but strange behaviour with led_b
author
hackbard
<hackbard>
Sun, 14 Nov 2004 11:29:07 +0000
(11:29 +0000)
committer
hackbard
<hackbard>
Sun, 14 Nov 2004 11:29:07 +0000
(11:29 +0000)
beginners/rgb_mali.asm
patch
|
blob
|
history
diff --git
a/beginners/rgb_mali.asm
b/beginners/rgb_mali.asm
index
fc89777
..
ca83557
100644
(file)
--- a/
beginners/rgb_mali.asm
+++ b/
beginners/rgb_mali.asm
@@
-17,18
+17,18
@@
.def tmp = r16
.def uart_count = r17
.def count = r18
.def tmp = r16
.def uart_count = r17
.def count = r18
-.def R = r19
-.def G = r20
-.def B = r21
-.def mode r22
-.equ cm 0
-.equ rgb 1
+.def R
ED
= r19
+.def G
REEN
= r20
+.def B
LUE
= r21
+.def mode
=
r22
+.equ cm
=
0
+.equ rgb
=
1
.def OUTR = r23
.def FULLR = r24
.def OUTR = r23
.def FULLR = r24
-.equ LED_R PD2
-.equ LED_G PD3
-.equ LED_B PD4
-.equ LED_PORT PORTD
+.equ LED_R
=
PD2
+.equ LED_G
=
PD3
+.equ LED_B
=
PD4
+.equ LED_PORT
=
PORTD
;
; interrupt voctors
;
; interrupt voctors
@@
-44,7
+44,7
@@
reti
; timer/counter compare
reti
; timer/counter overflow 1
; timer/counter compare
reti
; timer/counter overflow 1
-r
eti
+r
jmp INC_RGB
; timer/counter overflow 0
reti
; uart rx complete
; timer/counter overflow 0
reti
; uart rx complete
@@
-63,6
+63,12
@@
INIT:
; alloc stack pointer
ldi r16,low(RAMEND)
out SPL,r16
; alloc stack pointer
ldi r16,low(RAMEND)
out SPL,r16
+; timer: clock/1024
+ldi tmp,((1<<CS11))
+out TCCR1B,tmp
+; enable timer overflow interrupt
+ldi tmp,(1<<TOIE1)
+out TIMSK,tmp
; enable uart + rx complete interrupt
ldi tmp,51 ; 9600 baud, 0,2% error @ 8mhz
out UBRR,tmp
; enable uart + rx complete interrupt
ldi tmp,51 ; 9600 baud, 0,2% error @ 8mhz
out UBRR,tmp
@@
-75,17
+81,26
@@
ldi tmp,0
mov zero,tmp
ldi uart_count,0
ldi count,0
mov zero,tmp
ldi uart_count,0
ldi count,0
-ldi R
,0xff
-ldi G
,0xff
-ldi B,0xff
+ldi R
ED,0x22
+ldi G
REEN,0x77
+ldi B
LUE
,0xff
; led pins are outputs
ldi tmp,((1<<LED_R)|(1<<LED_G)|(1<<LED_B))
out DDRD,tmp
; led pins are outputs
ldi tmp,((1<<LED_R)|(1<<LED_G)|(1<<LED_B))
out DDRD,tmp
-; enable interrupts (global
=
+; enable interrupts (global
)
sei
; jump to main
rjmp MAIN
sei
; jump to main
rjmp MAIN
+;
+; increase rgb values
+;
+INC_RGB:
+add RED,one
+add BLUE,one
+add GREEN,one
+reti
+
;
; main routine
;
;
; main routine
;
@@
-106,15
+121,15
@@
rjmp CHECK_RED
;
; reset leds
;
;
; reset leds
;
+RESET_LEDS:
ldi OUTR,((1<<LED_R)|(1<<LED_G)|(LED_B))
ldi OUTR,((1<<LED_R)|(1<<LED_G)|(LED_B))
-add count,one
-ret
+rjmp CHECK_RED
;
; check red + jump to green check
;
CHECK_RED:
;
; check red + jump to green check
;
CHECK_RED:
-cp count,R
+cp count,R
ED
breq SWITCH_OFF_R
rjmp CHECK_GREEN
breq SWITCH_OFF_R
rjmp CHECK_GREEN
@@
-129,7
+144,7
@@
rjmp CHECK_GREEN
; check green + jump to blue check
;
CHECK_GREEN:
; check green + jump to blue check
;
CHECK_GREEN:
-cp count,G
+cp count,G
REEN
breq SWITCH_OFF_G
rjmp CHECK_BLUE
breq SWITCH_OFF_G
rjmp CHECK_BLUE
@@
-144,15
+159,15
@@
rjmp CHECK_BLUE
; check blue + "do the light"
;
CHECK_BLUE:
; check blue + "do the light"
;
CHECK_BLUE:
-cp count,B
+cp count,B
LUE
breq SWITCH_OFF_B
rjmp LIGHT
;
; switch of blue led
;
breq SWITCH_OFF_B
rjmp LIGHT
;
; switch of blue led
;
-SWITCH_OFF_
G
:
-sub OUTR,(1<<LED_B)
+SWITCH_OFF_
B
:
+sub
i
OUTR,(1<<LED_B)
rjmp LIGHT
;
rjmp LIGHT
;
@@
-160,15
+175,15
@@
rjmp LIGHT
;
LIGHT:
ldi FULLR,0xff
;
LIGHT:
ldi FULLR,0xff
-
sub
FULLR,OUTR
+
eor
FULLR,OUTR
out LED_PORT,FULLR
out LED_PORT,FULLR
-
rjmp INC_COUNT
;
; increase counter + jump back to main loop
;
rjmp INC_COUNT
;
; increase counter + jump back to main loop
;
-add counter,one
+INC_COUNT:
+add count,one
rjmp LOOP
;
rjmp LOOP
;