Hallo
Wo ist denn das "else" geblieben? < 160 wird nur geprüft, wenn die StopWatch >= 80 ist...Annahme: Stopwatch steht bei 40
If Stopwatch3 < 80 ---> ist True
If Stopwatch3 < 80+80 ---> ist aber ebenfalls True
So sieht man auf einen Blick ohne großen Kommentar, wie der Wert entsteht. Da es sich um Konstanten handelt, wird beim Kompilieren beides gleich übersetzt:Warum eigentlich 80+80 und nicht gleich 160?
Bei meinem RP6 funktioniert das Programm oben wie erwartet. Wenn man z.b. die 100 in 1000 ändert, sieht man deutlich den geänderten Blinkrythmus. Warum dein Piepen nicht funktioniert liegt möglicherweise an der Erweiterung.Code:// testzeile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ if (getStopwatch3() < 80) 24c: 80 91 b8 00 lds r24, 0x00B8 250: 90 91 b9 00 lds r25, 0x00B9 254: 80 35 cpi r24, 0x50 ; 80 256: 91 05 cpc r25, r1 258: 90 f0 brcs .+36 ; 0x27e <eigenefunktion+0x32> { setLEDs(63); //PORTC |= IO_PC7; //PORTC |= IO_PC5; } else if (getStopwatch3() < 80+80) 25a: 80 91 b8 00 lds r24, 0x00B8 25e: 90 91 b9 00 lds r25, 0x00B9 262: 80 3a cpi r24, 0xA0 ; 160 264: 91 05 cpc r25, r1 266: 20 f4 brcc .+8 ; 0x270 <eigenefunktion+0x24> //testzeile { setLEDs(0); 268: 80 e0 ldi r24, 0x00 ; 0 26a: 0e 94 a6 01 call 0x34c <setLEDs> 26e: 08 95 ret //PORTC &= ~IO_PC7; //PORTC &= ~IO_PC5; } else if (getStopwatch3() < 80+80+80) 270: 80 91 b8 00 lds r24, 0x00B8 274: 90 91 b9 00 lds r25, 0x00B9 278: 80 3f cpi r24, 0xF0 ; 240 27a: 91 05 cpc r25, r1 27c: 10 f4 brcc .+4 ; 0x282 <eigenefunktion+0x36> { setLEDs(63); 27e: 8f e3 ldi r24, 0x3F ; 63 280: f4 cf rjmp .-24 ; 0x26a <eigenefunktion+0x1e> //PORTC |= IO_PC7; //PORTC |= IO_PC5; } else if (getStopwatch3() < 80+80+80+100) 282: 80 91 b8 00 lds r24, 0x00B8 286: 90 91 b9 00 lds r25, 0x00B9 28a: 84 55 subi r24, 0x54 ; 84 28c: 91 40 sbci r25, 0x01 ; 1 28e: 60 f3 brcs .-40 ; 0x268 <eigenefunktion+0x1c> { setLEDs(0); //PORTC &= ~IO_PC7; //PORTC &= ~IO_PC5; } else setStopwatch3(0); 290: 10 92 b9 00 sts 0x00B9, r1 294: 10 92 b8 00 sts 0x00B8, r1 298: 08 95 ret 0000029a <main>: } // testzeile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Gruß
mic







Zitieren

Lesezeichen