Subversion Repositories Projects

Rev

Rev 52 | Rev 54 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 52 Rev 53
1
//############################################################################
1
//############################################################################
2
// - PWM CTRL 
2
// - PWM CTRL 
3
// - Main
3
// - Main
4
// - ATMEGA8 mit 8MHz
4
// - ATMEGA8 mit 8MHz
5
// - Nur für den privaten Gebrauch
5
// - Nur für den privaten Gebrauch
6
// - Keine Garantie auf Fehlerfreiheit
6
// - Keine Garantie auf Fehlerfreiheit
7
// - Kommerzielle Nutzung nur mit meiner Zustimmung
7
// - Kommerzielle Nutzung nur mit meiner Zustimmung
8
// - walter Meyer @ www.freakware.de
8
// - walter Meyer @ www.freakware.de
9
// - 11.12.2007
9
// - 11.12.2007
10
// - Make sure Fuses are programmed for internal 8 MHz RC Oscilator
10
// - Make sure Fuses are programmed for internal 8 MHz RC Oscilator
11
//############################################################################*/
11
//############################################################################*/
12
 
12
 
13
#include "main.h"
13
#include "main.h"
14
#include "uart.h"
14
#include "uart.h"
15
#include "twislave.h"
15
#include "twislave.h"
16
 
16
 
17
volatile unsigned int ppm_signal = 1500;
17
volatile unsigned int ppm_signal = 1500;
18
volatile unsigned char ppm_new = 0;
18
volatile unsigned char ppm_new = 0;
19
volatile unsigned char TMR1OvF = 0;
19
volatile unsigned char TMR1OvF = 0;
20
volatile unsigned int  TMR1MS;
20
volatile unsigned int  TMR1MS;
21
volatile unsigned char ch0;
21
volatile unsigned char ch0;
22
volatile unsigned char ch1;
22
volatile unsigned char ch1;
23
volatile unsigned char ch2;
23
volatile unsigned char ch2;
24
volatile unsigned char ch3;
24
volatile unsigned char ch3;
25
volatile unsigned char ch4;
25
volatile unsigned char ch4;
26
volatile unsigned char ch5;
26
volatile unsigned char ch5;
27
volatile unsigned char ch0_tmp;
27
volatile unsigned char ch0_tmp;
28
volatile unsigned char ch1_tmp;
28
volatile unsigned char ch1_tmp;
29
volatile unsigned char ch2_tmp;
29
volatile unsigned char ch2_tmp;
30
volatile unsigned char ch3_tmp;
30
volatile unsigned char ch3_tmp;
31
volatile unsigned char ch4_tmp;
31
volatile unsigned char ch4_tmp;
32
volatile unsigned char ch5_tmp;
32
volatile unsigned char ch5_tmp;
33
 
33
 
34
 
34
 
35
unsigned int timer;
35
unsigned int timer;
36
 
36
 
37
SIGNAL(SIG_OVERFLOW1)
37
SIGNAL(SIG_OVERFLOW1)
38
{
38
{
39
        TMR1OvF++;
39
        TMR1OvF++;
40
}
40
}
41
 
41
 
42
 
42
 
43
SIGNAL(SIG_INPUT_CAPTURE1)
43
SIGNAL(SIG_INPUT_CAPTURE1)
44
{
44
{
45
        static unsigned int pos_ICR;
45
        static unsigned int pos_ICR;
46
        static unsigned int ppm;
46
        static unsigned int ppm;
47
       
47
       
48
        if ((TCCR1B & (1<<ICES1)) != 0)                                         //rising edge
48
        if ((TCCR1B & (1<<ICES1)) != 0)                                         //rising edge
49
        {
49
        {
50
                TCCR1B &= ~(1<<ICES1);                                                          //set falling egde
50
                TCCR1B &= ~(1<<ICES1);                                                          //set falling egde
51
                TMR1OvF = 0;
51
                TMR1OvF = 0;
52
                pos_ICR = ICR1;
52
                pos_ICR = ICR1;
53
        }
53
        }
54
        else                                                                                    //falling edge
54
        else                                                                                    //falling edge
55
        {
55
        {
56
                TCCR1B |= (1<<ICES1);                                                           //set rising egde
56
                TCCR1B |= (1<<ICES1);                                                           //set rising egde
57
                ppm = (ICR1 - pos_ICR + (int) TMR1OvF * 65536);
57
                ppm = (ICR1 - pos_ICR + (int) TMR1OvF * 65536);
58
                if ((ppm > 600) && (ppm < 2400))
58
                if ((ppm > 600) && (ppm < 2400))
59
                {
59
                {
60
                        if (ppm > 2100) ppm = 2100;
60
                        if (ppm > 2100) ppm = 2100;
61
                        if (ppm < 900) ppm = 900;
61
                        if (ppm < 900) ppm = 900;
62
                        ppm = (ppm_signal * 7 + ppm) / 8;
62
                        ppm = (ppm_signal * 7 + ppm) / 8;
63
                        ppm_signal = ppm;
63
                        ppm_signal = ppm;
64
                        ppm_new = 1;
64
                        ppm_new = 1;
65
                }
65
                }
66
               
66
               
67
        }
67
        }
68
 
68
 
69
}
69
}
70
 
70
 
71
 
71
 
72
 
72
 
73
 
73
 
74
 
74
 
75
SIGNAL(SIG_OVERFLOW0)
75
SIGNAL(SIG_OVERFLOW0)
76
{
76
{
77
        // this function is called every 32us,
77
        // this function is called every 32us,
78
        // it is very important that it's execution time is as short as possible
78
        // it is very important that it's execution time is as short as possible
79
        // currently it's about 20us
79
        // currently it's about 20us
80
 
80
 
81
        static unsigned char counter = 254;
81
        static unsigned char counter = 254;
82
        static unsigned char ms1 = 0;
82
        static unsigned char ms1 = 0;
83
        unsigned char PORTB_BAK;
83
        unsigned char PORTB_BAK;
84
        unsigned char PORTD_BAK;       
84
        unsigned char PORTD_BAK;       
85
 
85
 
86
        PORTB_BAK = PORTB;
86
        PORTB_BAK = PORTB;
87
        PORTD_BAK = PORTD;
87
        PORTD_BAK = PORTD;
88
 
88
 
89
        if (counter++ == 254)
89
        if (counter++ == 254)
90
        {
90
        {
91
                PORTB_BAK LEDON (CH0_B | CH1_B | CH2_B);
91
                PORTB_BAK LEDON (CH0_B | CH1_B | CH2_B);
92
                PORTD_BAK LEDON (CH3_D | CH4_D | CH5_D);       
92
                PORTD_BAK LEDON (CH3_D | CH4_D | CH5_D);       
93
                ch0_tmp = ch0;
93
                ch0_tmp = ch0;
94
                ch1_tmp = ch1;
94
                ch1_tmp = ch1;
95
                ch2_tmp = ch2;
95
                ch2_tmp = ch2;
96
                ch3_tmp = ch3;
96
                ch3_tmp = ch3;
97
                ch4_tmp = ch4;
97
                ch4_tmp = ch4;
98
                ch5_tmp = ch5;         
98
                ch5_tmp = ch5;         
99
                counter = 0;
99
                counter = 0;
100
        }
100
        }
101
 
101
 
102
        if (ch0_tmp == counter) PORTB_BAK LEDOFF CH0_B;
102
        if (ch0_tmp == counter) PORTB_BAK LEDOFF CH0_B;
103
        if (ch1_tmp == counter) PORTB_BAK LEDOFF CH1_B;
103
        if (ch1_tmp == counter) PORTB_BAK LEDOFF CH1_B;
104
        if (ch2_tmp == counter) PORTB_BAK LEDOFF CH2_B;
104
        if (ch2_tmp == counter) PORTB_BAK LEDOFF CH2_B;
105
        if (ch3_tmp == counter) PORTD_BAK LEDOFF CH3_D;
105
        if (ch3_tmp == counter) PORTD_BAK LEDOFF CH3_D;
106
        if (ch4_tmp == counter) PORTD_BAK LEDOFF CH4_D;
106
        if (ch4_tmp == counter) PORTD_BAK LEDOFF CH4_D;
107
        if (ch5_tmp == counter) PORTD_BAK LEDOFF CH5_D;
107
        if (ch5_tmp == counter) PORTD_BAK LEDOFF CH5_D;
108
       
108
       
109
        PORTB = PORTB_BAK;
109
        PORTB = PORTB_BAK;
110
        PORTD = PORTD_BAK;
110
        PORTD = PORTD_BAK;
111
 
111
 
112
        if (ms1++ == 32)
112
        if (ms1++ == 32)
113
        {
113
        {
114
                ms1=0;
114
                ms1=0;
115
                TMR1MS++;
115
                TMR1MS++;
116
        }
116
        }
117
       
117
       
118
 
118
 
119
 
119
 
120
 
120
 
121
}
121
}
122
 
122
 
123
 
123
 
124
 
124
 
125
unsigned int SetDelay (unsigned int t)
125
unsigned int SetDelay (unsigned int t)
126
{
126
{
127
        unsigned char temp_hi;
127
        unsigned char temp_hi;
128
        unsigned char temp_lo;  
128
        unsigned char temp_lo;  
129
 
129
 
130
        temp_hi = (TMR1MS >> 8);
130
        temp_hi = (TMR1MS >> 8);
131
        temp_lo = (TMR1MS & 0xff);
131
        temp_lo = (TMR1MS & 0xff);
132
        if (temp_hi != (TMR1MS >> 8)) temp_hi = (TMR1MS >> 8);
132
        if (temp_hi != (TMR1MS >> 8)) temp_hi = (TMR1MS >> 8);
133
 
133
 
134
        return(((temp_hi << 8) | temp_lo)  + t + 1);                                            
134
        return(((temp_hi << 8) | temp_lo)  + t + 1);                                            
135
 
135
 
136
}
136
}
137
 
137
 
138
 
138
 
139
char CheckDelay(unsigned int t)
139
char CheckDelay(unsigned int t)
140
{
140
{
141
        unsigned char temp_hi;
141
        unsigned char temp_hi;
142
        unsigned char temp_lo;  
142
        unsigned char temp_lo;  
143
 
143
 
144
        temp_hi = (TMR1MS >> 8);
144
        temp_hi = (TMR1MS >> 8);
145
        temp_lo = (TMR1MS & 0xff);
145
        temp_lo = (TMR1MS & 0xff);
146
        if (temp_hi != (TMR1MS >> 8)) temp_hi = (TMR1MS >> 8);
146
        if (temp_hi != (TMR1MS >> 8)) temp_hi = (TMR1MS >> 8);
147
 
147
 
148
        return(((t - ((temp_hi << 8) | temp_lo)) & 0x8000) >> 9);
148
        return(((t - ((temp_hi << 8) | temp_lo)) & 0x8000) >> 9);
149
 
149
 
150
}
150
}
151
 
151
 
152
 
152
 
153
 
153
 
154
 
154
 
155
/*##############################################################################*/
155
/*##############################################################################*/
156
void StartPWM(void)
156
void StartPWM(void)
157
{
157
{
158
        //Timer 0 Config for getting right timing for IR Pattern
158
        //Timer 0 Config for getting right timing for IR Pattern
159
        TCCR0 = (0<<CS02)|(0<<CS01)|(1<<CS00);          // (@8MHz) =  1/8us Clk = 256/8 = 32us overflow
159
        TCCR0 = (0<<CS02)|(0<<CS01)|(1<<CS00);          // (@8MHz) =  1/8us Clk = 256/8 = 32us overflow
160
        TIMSK setbit (1<<TOIE0);                                                // enable Int
160
        TIMSK setbit (1<<TOIE0);                                                // enable Int
161
 
161
 
162
}
162
}
163
 
163
 
164
 
164
 
165
 
165
 
166
/*##############################################################################*/
166
/*##############################################################################*/
167
void StartPPM(void)
167
void StartPPM(void)
168
{
168
{
169
       
169
       
170
        //global timer1 Config
170
        //global timer1 Config
171
        TCCR1A =        (0<<COM1A1)|(0<<COM1A0)|(0<<COM1B1)|(0<<COM1B0)|
171
        TCCR1A =        (0<<COM1A1)|(0<<COM1A0)|(0<<COM1B1)|(0<<COM1B0)|
172
                                (0<<FOC1A) |(0<<FOC1B) |(0<<WGM10) |(0<<WGM11);                
172
                                (0<<FOC1A) |(0<<FOC1B) |(0<<WGM10) |(0<<WGM11);                
173
    TCCR1B =    (1<<ICNC1)|(1<<ICES1)|(0<<WGM13)|
173
    TCCR1B =    (1<<ICNC1)|(1<<ICES1)|(0<<WGM13)|
174
                                (0<<WGM12)|(0<<CS12)|(1<<CS11)|(0<<CS10);                               //ICP_POS_FLANKE
174
                                (0<<WGM12)|(0<<CS12)|(1<<CS11)|(0<<CS10);                               //ICP_POS_FLANKE
175
 
175
 
176
        // interrupts
176
        // interrupts
177
        TIMSK |=        (1<<TICIE1)|(1<<TOIE1);                                                                 //ICP_INT_ENABLE and TIMER1_INT_ENABLE
177
        TIMSK |=        (1<<TICIE1)|(1<<TOIE1);                                                                 //ICP_INT_ENABLE and TIMER1_INT_ENABLE
178
 
178
 
179
}
179
}
180
 
180
 
181
 
181
 
182
 
182
 
183
/*##############################################################################*/
183
/*##############################################################################*/
184
int GetPPM(void)
184
int GetPPM(void)
185
{
185
{
186
        //this routines seems to be nesseccary, as reading a 16 bit value
186
        //this routines seems to be nesseccary, as reading a 16 bit value
187
        //on a 8 bit machine is not atomic, so if an interrupt apears between reading
187
        //on a 8 bit machine is not atomic, so if an interrupt apears between reading
188
        //low and high byte of the 16 bit value a wrong result is possible
188
        //low and high byte of the 16 bit value a wrong result is possible
189
       
189
       
190
        unsigned char intmask;
190
        unsigned char intmask;
191
        unsigned int  ppm_temp;
191
        unsigned int  ppm_temp;
192
 
192
 
193
        intmask = TIMSK;                                //backup interupt enable bits
193
        intmask = TIMSK;                                //backup interupt enable bits
194
        TIMSK &= ~(1<<TICIE1);                  //disable ppm interrupt
194
        TIMSK &= ~(1<<TICIE1);                  //disable ppm interrupt
195
        ppm_temp = ppm_signal;
195
        ppm_temp = ppm_signal;
196
        TIMSK = intmask;                                //restore interupt enable bits
196
        TIMSK = intmask;                                //restore interupt enable bits
197
        return(ppm_temp);                               //return ppm_signal
197
        return(ppm_temp);                               //return ppm_signal
198
 
198
 
199
}
199
}
200
 
200
 
201
 
201
 
202
/*##############################################################################*/
202
/*##############################################################################*/
203
// MAIN
203
// MAIN
204
/*##############################################################################*/
204
/*##############################################################################*/
205
int main (void)
205
int main (void)
206
{
206
{
207
        unsigned int    i;
207
        unsigned int    i;
-
 
208
        unsigned int    ppm;
208
        unsigned char   colorState;
209
        unsigned char   colorState;
209
        unsigned char   nextcolorState=0;
210
        unsigned char   nextcolorState=0;
210
 
211
 
211
    DDRB  = (CH0_B|CH1_B|CH2_B);
212
    DDRB  = (CH0_B|CH1_B|CH2_B);
212
    PORTB = 0x00;
213
    PORTB = 0x00;
213
 
214
 
214
    DDRC  = (ledred);
215
    DDRC  = (ledred);
215
    PORTC = 0x00;
216
    PORTC = 0x00;
216
 
217
 
217
    DDRD  = (ledgreen|CH3_D|CH4_D|CH5_D);
218
    DDRD  = (ledgreen|CH3_D|CH4_D|CH5_D);
218
    PORTD = 0x00;
219
    PORTD = 0x00;
219
 
220
 
220
        ch0 = 0;
221
        ch0 = 0;
221
        ch1 = 0;
222
        ch1 = 0;
222
        ch2 = 0;
223
        ch2 = 0;
223
        ch3 = 0;
224
        ch3 = 0;
224
        ch4 = 0;
225
        ch4 = 0;
225
        ch5 = 0;       
226
        ch5 = 0;       
226
 
227
 
227
        //StartUART();
228
        //StartUART();
228
        StartPPM();
229
        StartPPM();
229
        //StartI2C();
230
        //StartI2C();
230
        StartPWM();
231
        StartPWM();
231
        sei();
232
        sei();
232
 
233
 
233
 
234
 
234
        // Farbablauf: rot > Violett > blau > tuerkis > gruen > gelb >
235
        // Farbablauf: rot > Violett > blau > tuerkis > gruen > gelb >
235
 
236
 
236
 
237
 
237
        colorState = 0;
238
        colorState = 0;
238
   
239
   
239
    while (1)
240
    while (1)
240
        {
241
        {
-
 
242
 
-
 
243
/*
-
 
244
        #define step    128
-
 
245
        #define mul             2
-
 
246
 
-
 
247
                if ((ppm >= (step * 0)  && (ppm < (step * 1))) ch0 = mul * ((ppm - (step * 0)));
-
 
248
                if ((ppm >= (step * 1)) && (ppm < (step * 2))) ch1 = mul * ((ppm - (step * 1)));
-
 
249
                if ((ppm >= (step * 2)) && (ppm < (step * 3))) ch0 = mul * ((step - 1) - (ppm - (step * 2)));
-
 
250
                if ((ppm >= (step * 3)) && (ppm < (step * 4))) ch2 = mul * ((ppm - (step * 3)));
-
 
251
                if ((ppm >= (step * 4)) && (ppm < (step * 5))) ch1 = mul * ((step - 1) - (ppm - (step * 4)));
-
 
252
                if ((ppm >= (step * 5)) && (ppm < (step * 6))) ch0 = mul * ((ppm - (step * 5)));
-
 
253
                if ((ppm >= (step * 6)) && (ppm < (step * 7))) ch2 = mul * ((step - 1) - (ppm - (step * 6)));
241
 
254
 
-
 
255
                //printf("%d ",ppm);
242
                //printf("%d ",ppm_signal);
256
*/
243
 
257
 
244
                for (i=0; i<=255; i++)
258
                for (i=0; i<=255; i++)
245
                {
259
                {
246
                        switch(colorState)
260
                        switch(colorState)
247
                        {
261
                        {
248
                        case 0:
262
                        case 0:
249
                                ch0 = i;                                //fade in (ch0) red
263
                                ch0 = i;                                //fade in (ch0) red
250
                                nextcolorState = 2;
264
                                nextcolorState = 2;
251
                                break;
265
                                break;
252
 
266
 
253
                        case 2:
267
                        case 2:
254
                                ch1 = i;                                //fade in (ch1) blue to get pure purple (red + blue)
268
                                ch1 = i;                                //fade in (ch1) blue to get pure purple (red + blue)
255
                                nextcolorState = 4;
269
                                nextcolorState = 4;
256
                                break;
270
                                break;
257
 
271
 
258
                        case 4:
272
                        case 4:
259
                                ch0 = 255 - i;                  //fade out (ch0) red to get pure blue
273
                                ch0 = 255 - i;                  //fade out (ch0) red to get pure blue
260
                                nextcolorState = 6;
274
                                nextcolorState = 6;
261
                                break;
275
                                break;
262
 
276
 
263
                        case 6:
277
                        case 6:
264
                                ch2 = i;                                //fade in  (ch2) green to get pure cyan (blue + green)
278
                                ch2 = i;                                //fade in  (ch2) green to get pure cyan (blue + green)
265
                                nextcolorState = 8;                            
279
                                nextcolorState = 8;                            
266
                                break;
280
                                break;
267
 
281
 
268
                        case 8:
282
                        case 8:
269
                                ch1 = 255 - i;                  //fade out (ch1) blue to get pure green
283
                                ch1 = 255 - i;                  //fade out (ch1) blue to get pure green
270
                                nextcolorState = 10;
284
                                nextcolorState = 10;
271
                                break;
285
                                break;
272
 
286
 
273
                        case 10:
287
                        case 10:
274
                                ch0 = i;                                //fade in  (ch0) red to get yellow pure (green + red)
288
                                ch0 = i;                                //fade in  (ch0) red to get yellow pure (green + red)
275
                                nextcolorState = 12;                           
289
                                nextcolorState = 12;                           
276
                                break;
290
                                break;
277
 
291
 
278
                        case 12:
292
                        case 12:
279
                                ch2 = 255 - i;                  //fade out (ch2) green to get pure red
293
                                ch2 = 255 - i;                  //fade out (ch2) green to get pure red
280
                                nextcolorState = 0;
294
                                nextcolorState = 0;
281
                                break;
295
                                break;
282
                        }
296
                        }
283
 
297
 
284
 
298
 
285
                        timer = SetDelay(5);            //wait 10ms
299
                        timer = SetDelay(5);            //wait 10ms
286
                        while (!CheckDelay(timer));
300
                        while (!CheckDelay(timer));
287
                }
301
                }
288
                       
302
                       
289
                colorState = nextcolorState;
303
                colorState = nextcolorState;
290
 
304
 
291
                timer = SetDelay(3);                    //hold pure colors for additional 3ms
305
                timer = SetDelay(3);                    //hold pure colors for additional 3ms
292
                while (!CheckDelay(timer));
306
                while (!CheckDelay(timer));
293
 
307
 
294
 
308
 
295
        }
309
        }
296
 
310
 
297
 
311
 
298
}
312
}
299
 
-
 
300
 
-
 
301
 
-
 
302
/*
-
 
303
 170 00fa 1F92                  push __zero_reg__
-
 
304
 171 00fc 0F92                  push __tmp_reg__
-
 
305
 172 00fe 0FB6                  in __tmp_reg__,__SREG__
-
 
306
 173 0100 0F92                  push __tmp_reg__
-
 
307
 174 0102 1124                  clr __zero_reg__
-
 
308
 175 0104 2F93                  push r18
-
 
309
 176 0106 3F93                  push r19
-
 
310
 177 0108 8F93                  push r24
-
 
311
 178 010a 9F93                  push r25
-
 
312
 181 010c 38B3                  in r19,56-0x20
-
 
313
 184 010e 22B3                  in r18,50-0x20
-
 
314
 187 0110 8091 0000             lds r24,counter.1797
-
 
315
 188 0114 8F5F                  subi r24,lo8(-(1))
-
 
316
 189 0116 8093 0000             sts counter.1797,r24
-
 
317
 190 011a 8F3F                  cpi r24,lo8(-1)
-
 
318
 191 011c 01F4                  brne .L15
-
 
319
 193 011e 3E60                  ori r19,lo8(14)
-
 
320
 195 0120 2863                  ori r18,lo8(56)
-
 
321
 197 0122 8091 0000             lds r24,ch0
-
 
322
 198 0126 8093 0000             sts ch0_tmp,r24
-
 
323
 200 012a 8091 0000             lds r24,ch1
-
 
324
 201 012e 8093 0000             sts ch1_tmp,r24
-
 
325
 203 0132 8091 0000             lds r24,ch2
-
 
326
 204 0136 8093 0000             sts ch2_tmp,r24
-
 
327
 206 013a 8091 0000             lds r24,ch3
-
 
328
 207 013e 8093 0000             sts ch3_tmp,r24
-
 
329
 209 0142 8091 0000             lds r24,ch4
-
 
330
 210 0146 8093 0000             sts ch4_tmp,r24
-
 
331
 212 014a 8091 0000             lds r24,ch5
-
 
332
 213 014e 8093 0000             sts ch5_tmp,r24
-
 
333
 215 0152 1092 0000             sts counter.1797,__zero_reg__
-
 
334
 218 0156 8091 0000             lds r24,ch0_tmp
-
 
335
 219 015a 9091 0000             lds r25,counter.1797
-
 
336
 220 015e 8917                  cp r24,r25
-
 
337
 221 0160 01F4                  brne .L17
-
 
338
 222 0162 377F                  andi r19,lo8(-9)
-
 
339
 225 0164 8091 0000             lds r24,ch1_tmp
-
 
340
 226 0168 8917                  cp r24,r25
-
 
341
 227 016a 01F4                  brne .L19
-
 
342
 228 016c 3B7F                  andi r19,lo8(-5)
-
 
343
 231 016e 8091 0000             lds r24,ch2_tmp
-
 
344
 232 0172 8917                  cp r24,r25
-
 
345
 233 0174 01F4                  brne .L21
-
 
346
 234 0176 3D7F                  andi r19,lo8(-3)
-
 
347
 237 0178 8091 0000             lds r24,ch3_tmp
-
 
348
 238 017c 8917                  cp r24,r25
-
 
349
 239 017e 01F4                  brne .L23
-
 
350
 240 0180 277F                  andi r18,lo8(-9)
-
 
351
 243 0182 8091 0000             lds r24,ch4_tmp
-
 
352
 244 0186 8917                  cp r24,r25
-
 
353
 245 0188 01F4                  brne .L25
-
 
354
 246 018a 2F7E                  andi r18,lo8(-17)
-
 
355
 249 018c 8091 0000             lds r24,ch5_tmp
-
 
356
 250 0190 8917                  cp r24,r25
-
 
357
 251 0192 01F4                  brne .L27
-
 
358
 252 0194 2F7D                  andi r18,lo8(-33)
-
 
359
 255 0196 38BB                  out 56-0x20,r19
-
 
360
 257 0198 22BB                  out 50-0x20,r18
-
 
361
 259 019a 8091 0000             lds r24,ms1.1798
-
 
362
 260 019e 8F5F                  subi r24,lo8(-(1))
-
 
363
 261 01a0 8093 0000             sts ms1.1798,r24
-
 
364
 262 01a4 8132                  cpi r24,lo8(33)
-
 
365
 263 01a6 01F4                  brne .L31
-
 
366
 265 01a8 1092 0000             sts ms1.1798,__zero_reg__
-
 
367
 267 01ac 8091 0000             lds r24,TMR1MS
-
 
368
 268 01b0 9091 0000             lds r25,(TMR1MS)+1
-
 
369
 269 01b4 0196                  adiw r24,1
-
 
370
 270 01b6 9093 0000             sts (TMR1MS)+1,r25
-
 
371
 271 01ba 8093 0000             sts TMR1MS,r24
-
 
372
 274 01be 9F91                  pop r25
-
 
373
 275 01c0 8F91                  pop r24
-
 
374
 276 01c2 3F91                  pop r19
-
 
375
 277 01c4 2F91                  pop r18
-
 
376
 278 01c6 0F90                  pop __tmp_reg__
-
 
377
 279 01c8 0FBE                  out __SREG__,__tmp_reg__
-
 
378
 280 01ca 0F90                  pop __tmp_reg__
-
 
379
 281 01cc 1F90                  pop __zero_reg__
-
 
380
 282 01ce 1895                  reti
-
 
381
 */
313
 
382
 
314