international: OHS_SSCI_STICK.asm

File OHS_SSCI_STICK.asm, 3.3 KB (added by Shinichi Ohki, 9 years ago)
Line 
1.org 0x0000
2 rjmp RESET
3 reti ; INT0_ISR
4 reti ; PCINT0_ISR
5 reti ; TIM1_COMPA_ISR
6 reti ; TIM1_OVF_ISR
7 reti ; TIM0_OVF_ISR
8 reti ; EE_RDY_ISR
9 reti ; ANA_COMP_ISR
10 reti ; ADC_ISR
11 reti ; TIM1_COMPB_ISR
12 reti ; TIM0_COMPA_ISR
13 reti ; TIM0_COMPB_ISR
14 reti ; WDT_ISR
15 reti ; USI_START_ISR
16 reti ; USI_OVF_ISR
17
18RESET:
19 ldi R16,0x00 ; R16(LED_MODE) = 0
20 ldi R17,0x00 ; R17(LED_COUNTER) = 0
21 ldi R18,0x00 ; R18(MODE_TIMER) = 0
22 ; LED_INIT
23 ldi R20,0x19 ; R20 <- **011001B
24 out 0x17,R20 ; DDRB <- R20
25 MAIN_LOOP:
26 inc R17
27 inc R18 ; R18(MODE_TIMER)++
28 cpi R18,0x50 ; TimeLimitChekc
29 brne LED_CONTROL
30 ldi R18,0x00 ; R18(MODE_TIMER) CLEAR
31 inc R16 ; R16(LED_MODE)++
32 andi R16,0x03
33 ldi R17,0x00
34 LED_CONTROL:
35 cpi R16,0x01
36 brcs LED_MODE0
37 breq LED_MODE1
38 cpi R16,0x03
39 brne LED_MODE2
40 rjmp LED_MODE3
41; -------------------------
42LED_MODE0:
43 andi R17,0x03
44 breq LED_MODE0L
45 cpi R17,0x02
46 breq LED_MODE0R
47 LED_MODE0C:
48 ldi R20,0xf7 ; R20 <- 11110111B
49 out 0x18,R20 ; PORTB <- R20
50 rjmp LED_MODE0_WAIT
51 LED_MODE0L:
52 ldi R20,0xfe ; R20 <- 11111110B
53 out 0x18,R20 ; PORTB <- R20
54 rjmp LED_MODE0_WAIT
55 LED_MODE0R:
56 ldi R20,0xef ; R20 <- 11101111B
57 out 0x18,R20 ; PORTB <- R20
58 LED_MODE0_WAIT:
59 rjmp LED_WAIT
60; -------------------------
61LED_MODE1:
62 mov R20,R17
63 andi R20,0x04
64 breq LED_MODE1LR
65 LED_MODE1C:
66 ldi R20,0xf7 ; R20 <- 11110111B
67 out 0x18,R20 ; PORTB <- R20
68 rjmp LED_MODE1_WAIT
69 LED_MODE1LR:
70 ldi R20,0xee ; R20 <- 11101110B
71 out 0x18,R20 ; PORTB <- R20
72 LED_MODE1_WAIT:
73 rjmp LED_WAIT
74; -------------------------
75LED_MODE2:
76 cpi R17,0x01
77 breq LED_MODE2_ON
78 cpi R17,0x03
79 breq LED_MODE2_ON
80 andi R17,0x07
81 LED_MODE2_OFF:
82 ldi R20,0xff ; R20 <- 11111111B
83 out 0x18,R20 ; PORTB <- R20
84 rjmp LED_MODE2_WAIT
85 LED_MODE2_ON:
86 ldi R20,0xe6 ; R20 <- 11100110B
87 out 0x18,R20 ; PORTB <- R20
88 LED_MODE2_WAIT:
89 rjmp LED_WAIT
90; -------------------------
91LED_MODE3:
92 cpi R17,0x0e
93 brne LED_MODE3_MAIN
94 ldi R17,0x00
95 LED_MODE3_MAIN:
96 cpi R17,0x01
97 brcs LED_MODE30
98 breq LED_MODE31
99 cpi R17,0x03
100 brcs LED_MODE32
101 breq LED_MODE33
102 cpi R17,0x05
103 brcs LED_MODE34
104 breq LED_MODE35
105 cpi R17,0x07
106 brcs LED_MODE35
107 breq LED_MODE34
108 cpi R17,0x09
109 brcs LED_MODE33
110 breq LED_MODE32
111 cpi R17,0x0b
112 brcs LED_MODE31
113 breq LED_MODE30
114 rjmp LED_MODE35
115 LED_MODE30:
116 ldi R20,0xfe ; R20 <- 11111110B
117 out 0x18,R20 ; PORTB <- R20
118 rjmp LED_MODE3_WAIT
119 LED_MODE31:
120 ldi R20,0xf6 ; R20 <- 11110110B
121 out 0x18,R20 ; PORTB <- R20
122 rjmp LED_MODE3_WAIT
123 LED_MODE32:
124 ldi R20,0xe6 ; R20 <- 11100110B
125 out 0x18,R20 ; PORTB <- R20
126 rjmp LED_MODE3_WAIT
127 LED_MODE33:
128 ldi R20,0xe7 ; R20 <- 11100111B
129 out 0x18,R20 ; PORTB <- R20
130 rjmp LED_MODE3_WAIT
131 LED_MODE34:
132 ldi R20,0xef ; R20 <- 11101111B
133 out 0x18,R20 ; PORTB <- R20
134 rjmp LED_MODE3_WAIT
135 LED_MODE35:
136 ldi R20,0xff ; R20 <- 11111111B
137 out 0x18,R20 ; PORTB <- R20
138 LED_MODE3_WAIT:
139 ldi R20,0x04 ; WAIT_TIME
140 rjmp LED_WAIT
141; -------------------------
142LED_WAIT:
143 ldi R20,0x01 ; WAIT_TIME
144 LED_WAIT0:
145 ldi R21,0x7f ; R21,0xff
146 LED_WAIT1:
147 ldi R22,0xff ; R22,0xff
148 LED_WAIT2:
149 nop
150 dec R22 ; R22--
151 brne LED_WAIT2 ; R22 != 0 LED_WAIT3
152 dec R21 ; R21--
153 brne LED_WAIT1 ; R21 != 0 LED_WAIT2
154 dec R20 ; R20--
155 brne LED_WAIT0 ; R20 != 0 LED_WAIT1
156 rjmp MAIN_LOOP