INT1 klappt, INT0 nicht.

Gast #2346740
Lesenswert?

Hey,
ich verzweifel hier wirklich langsam.

Nutze einen ATMEGA8 und nutze ein RC-Empfänger Signal um Interrupts 
auszulösen und an meinem RC Auto LEDs zu schalten.

Bei INT1 klappt das alles perfekt.
1
[...]
2
GICR = (1 << INT1); 
3

4
MCUCR = (1 << ISC11)|(1 << ISC10); 
5

6
sei(); //Generell Interrupts aktivieren
7
[...]
8
ISR(INT1_vect) 
9
{
10
[...]
11
}
12
[...]

Sobald ich überall aus der 1 eine 0 mache und mein Kabel von PD5 auf PD4 
umlöte, klappt es nicht mehr.
1
[...]
2
GICR = (1 << INT0); 
3

4
MCUCR = (1 << ISC01)|(1 << ISC00); 
5

6
sei(); //Generell Interrupts aktivieren
7
[...]
8
ISR(INT0_vect) 
9
{
10
[...]
11
}
12
[...]

Kann sich das irgendeiner erklären? Funkt das irgendein Fuse Bit rein?!
#2346789
Lesenswert?

Aus Datenblatt:
1
External Interrupts The external interrupts are triggered by the INT0, and INT1 pins. Observe that, if
2
                    enabled, the interrupts will trigger even if the INT0..1 pins are configured as outputs.
3
                    This feature provides a way of generating a software interrupt. The external interrupts
4
                    can be triggered by a falling or rising edge or a low level. This is set up as indicated in
5
                    the specification for the MCU Control Register ­ MCUCR. When the external interrupt is
6
                    enabled and is configured as level triggered, the interrupt will trigger as long as the pin is
7
                    held low. Note that recognition of falling or rising edge interrupts on INT0 and INT1
8
                    requires the presence of an I/O clock, described in "Clock Systems and their Distribu-
9
                    tion" on page 23. Low level interrupts on INT0/INT1 are detected asynchronously. This
10
                    implies that these interrupts can be used for waking the part also from sleep modes
11
                    other than Idle mode. The I/O clock is halted in all sleep modes except Idle mode.
Gast #2346810
Lesenswert?

Ja den Text habe ich auch eben gelesen. Was der Text mir genau sagen 
soll check ich nicht so ganz. Ich muss doch nich PD2/3 als Ausgang 
definieren, damit der Interupt klappt oder wohl?

Jedenfalls habe ich es bei INT1 so geregelt, dass PD3 als Eingang 
definiert ist, dass ich während der Interupt Routine nochmal den PIN auf 
High/Low überprüfe um festzustellen, wann das Empfänger Signal wieder 
auf low gesetzt wird (um die Impulsbreite zu bestimmen). Und nein, ich 
nutze dafür keinen Timer. Ich habe es so.



Wie gesagt, es klappt bei INT1 genau wie ich es gerne hätte. Oben steht 
dann halt noch DDRD = (0 << DDD3);
Gast #2346838
Lesenswert?

Ich wollte meinen Code absichtlich nicht posten^^
So hier ist er!


Signal an INT1 --> Blaulicht und Warnblinker an meinem Polizei Porsche 
lässt sich schalten.
Signal an INT0 --> Warnblinker ist permanent an und ich kann nichts 
schalten.

1
#include <avr/io.h>          
2
#include "util/delay.h"
3
#include <avr/interrupt.h>
4

5

6
uint8_t reset_oben0 = 0;
7
uint8_t reset_unten0 = 0;
8
volatile uint8_t on_oben0 = 0;
9
volatile uint8_t on_unten0 = 0;
10
uint8_t reset_oben1 = 0;
11
uint8_t reset_unten1 = 0;
12
volatile uint8_t on_oben1 = 0;
13
volatile uint8_t on_unten1 = 0;
14
uint8_t blinker_an = 0;
15
volatile uint8_t schaltkanal_an = 0;
16

17
int schaltkanal(void)
18
{
19
  //Schaltkanal
20
  if(PIND & (1 << PD0))
21
  {
22
     PORTB |= (1 << PB3) | (1 << PB2); 
23
    schaltkanal_an = 1;
24
  }
25
  else 
26
  {
27
    PORTB &= ~((1 << PB3) | (1 << PB2)); //Abblendlicht Ein- & Ausschalten
28
    schaltkanal_an = 0;
29
  }
30

31
}
32

33
int bremse(void)
34
{
35
  
36
  if(PIND & (1 << PD1)) //Bremsleuchten bei Signal an PD1
37
  { 
38
    PORTB &= ~(1 << PB4);
39
    PORTB &= ~(1 << PB5); //Bremslicht hinten aus
40
    if (schaltkanal_an == 1) PORTB |= (1 << PB3); //Normales Licht hinten an
41
    
42
 
43

44
  }
45
  else 
46
  {
47
    PORTB |= (1 << PB4);
48
    if (schaltkanal_an == 1) PORTB &= ~(1 << PB3); //Normales Licht hinten aus
49
    PORTB |= (1 << PB5);
50
  
51
     
52

53
  }
54

55

56
}
57

58

59
int main()
60
{
61

62
  DDRB = (1 << DDB2) | (1 << DDB3) | (1 << DDB4) | (1 << DDB5); 
63
  PORTB = (0 << PB2) | (0 << PB3) | (1 << PB4) | (1 << PB5); //PB2 = Licht vorne, PB3 = Licht hinten, PB4 = Bremslicht, PB5 = Licht hinten - Bremse
64
  DDRD = (0 << DDD0) | (0 << DDD3) | (1 << DDD7) | (0 << DDD1) | (0 << DDD2); //PD0 = Schaltkanal, PD3 = Interrupt, PD7 = Blinker Ausgang, PD1 = Motorsignal 
65
  DDRC = (1 << DDC4) | (1 << DDC5);  
66
  PORTC = (0 << PC4) | (0 << PC5);
67

68
  GICR = (1 << INT0) | (1 << INT1); //INT1/0-Interrupt aktivieren 
69

70
  MCUCR = (1 << ISC01)|(1 << ISC00)|(1 << ISC11)|(1 << ISC10); //Aktiviere Sensitivität auf steigende Flanke 
71

72
  sei(); //Generell Interrupts aktivieren
73

74

75
  while (1) //Hauptschleife
76
  {
77
    start:
78
    //Immer dafür sorgen, dass Blaulicht und Blinker aus sind.
79
    PORTC = (0 << PC4) | (0 << PC5);
80
    PORTD = (1 << PD7);
81

82
    //Schaltkanal
83
    schaltkanal();    
84
    bremse();
85

86
    //NUR Blaulicht an?
87
    while(on_oben1==1 && on_unten1==0)
88
    {  
89
    
90

91
      //Links
92
      PORTC = (1 << PC4) | (0 << PC5);
93
      _delay_ms(130);
94
      PORTC = (0 << PC4) | (0 << PC5);
95
      _delay_ms(50);
96
      PORTC = (1 << PC4) | (0 << PC5);
97
      _delay_ms(30);
98
      PORTC = (0 << PC4) | (0 << PC5);
99
      _delay_ms(50);
100
      PORTC = (1 << PC4) | (0 << PC5);
101
      _delay_ms(30);
102
      PORTC = (0 << PC4) | (0 << PC5);
103
      _delay_ms(50); //340ms
104

105
      if(on_oben1==0 || on_unten1==1) goto start;//Abbruch  
106
      //Schaltkanal
107
      schaltkanal();    
108

109
      //Rechts
110
      PORTC = (0 << PC4) | (1 << PC5);
111
      _delay_ms(135);  
112
      //Blinker  
113
      PORTC = (0 << PC4) | (0 << PC5);
114
      _delay_ms(50);
115
      PORTC = (0 << PC4) | (1 << PC5);
116
      _delay_ms(30);
117
      PORTC = (0 << PC4) | (0 << PC5);
118
      _delay_ms(50);
119
      PORTC = (0 << PC4) | (1 << PC5);
120
      _delay_ms(30);
121
      PORTC = (0 << PC4) | (0 << PC5);
122
      _delay_ms(160); //455ms
123

124
      if(on_oben1==0 || on_unten1==1) goto start;//Abbruch
125
      //Schaltkanal
126
      schaltkanal();    
127

128
      //Links
129
      PORTC = (1 << PC4) | (0 << PC5);
130
      _delay_ms(130);
131
      PORTC = (0 << PC4) | (0 << PC5);
132
      _delay_ms(25);
133
      //Blinker
134
      _delay_ms(25);
135
      PORTC = (1 << PC4) | (0 << PC5);
136
      _delay_ms(30);
137
      PORTC = (0 << PC4) | (0 << PC5);
138
      _delay_ms(50);
139
      PORTC = (1 << PC4) | (0 << PC5);
140
      _delay_ms(30);
141
      PORTC = (0 << PC4) | (0 << PC5);
142
      _delay_ms(20); //310ms
143

144
      if(on_oben1==0 || on_unten1==1) goto start;//Abbruch
145
      //Schaltkanal
146
      schaltkanal();    
147

148
      //Rechts
149
      PORTC = (0 << PC4) | (1 << PC5);
150
      _delay_ms(130);    
151
      PORTC = (0 << PC4) | (0 << PC5);
152
      _delay_ms(50);
153
      PORTC = (0 << PC4) | (1 << PC5);
154
      _delay_ms(30);
155
      PORTC = (0 << PC4) | (0 << PC5);
156
      _delay_ms(50);
157
      PORTC = (0 << PC4) | (1 << PC5);
158
      _delay_ms(30);
159
      PORTC = (0 << PC4) | (0 << PC5);
160
      _delay_ms(30);
161
      //Blinker
162
      _delay_ms(100);  //420ms
163

164
      if(on_oben1==0 || on_unten1==1) goto start;//Abbruch
165
      //Schaltkanal
166
      schaltkanal();    
167

168
//-------------------------------------------------
169

170
      PORTC = (1 << PC4) | (0 << PC5);
171
      _delay_ms(130);
172
      PORTC = (0 << PC4) | (0 << PC5);
173
      _delay_ms(50);
174
      PORTC = (1 << PC4) | (0 << PC5);
175
      _delay_ms(30);
176
      PORTC = (0 << PC4) | (0 << PC5);
177
      _delay_ms(50);
178
      PORTC = (1 << PC4) | (1 << PC5);
179
      _delay_ms(30);
180
      PORTC = (0 << PC4) | (0 << PC5);
181
      _delay_ms(50); //290ms
182

183
      PORTC = (0 << PC4) | (1 << PC5);
184
      _delay_ms(35);
185
      //Blinker
186
      _delay_ms(95);    
187
      PORTC = (0 << PC4) | (0 << PC5);
188
      _delay_ms(50);
189
      PORTC = (0 << PC4) | (1 << PC5);
190
      _delay_ms(30);
191
      PORTC = (0 << PC4) | (0 << PC5);
192
      _delay_ms(50);
193
      PORTC = (0 << PC4) | (1 << PC5);
194
      _delay_ms(30);
195
      PORTC = (1 << PC4) | (0 << PC5);
196
      _delay_ms(50);
197
      PORTC = (1 << PC4) | (1 << PC5);
198
      _delay_ms(30);
199
      PORTC = (0 << PC4) | (0 << PC5);
200
      _delay_ms(50);
201
      PORTC = (0 << PC4) | (0 << PC5);  
202
      _delay_ms(30); //450ms
203

204

205
      if(on_oben1==0 || on_unten1==1) goto start;//Abbruch
206
      //Schaltkanal
207
      schaltkanal();    
208

209
//-------------------------------------------------
210

211
      PORTC = (1 << PC4) | (0 << PC5);
212
      _delay_ms(60);      
213
      //Blinker
214
      _delay_ms(70);
215
      PORTC = (0 << PC4) | (0 << PC5);
216
      _delay_ms(50);
217
      PORTC = (1 << PC4) | (0 << PC5);
218
      _delay_ms(30);
219
      PORTC = (0 << PC4) | (0 << PC5);
220
      _delay_ms(50);
221
      PORTC = (1 << PC4) | (0 << PC5);
222
      _delay_ms(30);
223
      PORTC = (0 << PC4) | (0 << PC5);
224
      _delay_ms(50); //340ms
225

226
      if(on_oben1==0 || on_unten1==1) goto start;//Abbruch
227
      //Schaltkanal
228
      schaltkanal();    
229

230
      PORTC = (0 << PC4) | (1 << PC5);
231
      _delay_ms(130);    
232
      PORTC = (0 << PC4) | (0 << PC5);
233
      _delay_ms(50);
234
      PORTC = (0 << PC4) | (1 << PC5);
235
      _delay_ms(15);
236
      //Blinker
237
      _delay_ms(15);
238
      PORTC = (0 << PC4) | (0 << PC5);
239
      _delay_ms(50);
240
      PORTC = (0 << PC4) | (1 << PC5);
241
      _delay_ms(30);
242
      PORTC = (0 << PC4) | (0 << PC5);
243
      _delay_ms(50);
244
      PORTC = (0 << PC4) | (1 << PC5);
245
      _delay_ms(30);
246
      PORTC = (0 << PC4) | (0 << PC5);
247
      _delay_ms(50);
248
      PORTC = (0 << PC4) | (1 << PC5);
249
      _delay_ms(30);
250
      PORTC = (0 << PC4) | (0 << PC5);
251
      _delay_ms(50);
252
      PORTC = (1 << PC4) | (1 << PC5);
253
      _delay_ms(20);
254
      PORTC = (0 << PC4) | (0 << PC5);  
255
      _delay_ms(150); //520ms
256
      //Blinker
257

258

259

260

261
    }
262

263

264

265
    //NUR Blinker an?
266
    while(on_unten1==1 && on_oben1==0)
267
    {  
268

269
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}
270
      _delay_ms(475);
271
      //Schaltkanal
272
      schaltkanal();    
273

274
    
275
    }
276
    
277

278
    
279
    //Blinker und Blaulicht an?
280
    while(on_unten1==1 && on_oben1==1)
281
    {
282

283
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker
284
      //Schaltkanal
285
      schaltkanal();    
286

287
      //Links
288
      PORTC = (1 << PC4) | (0 << PC5);
289
      _delay_ms(130);
290
      PORTC = (0 << PC4) | (0 << PC5);
291
      _delay_ms(50);
292
      PORTC = (1 << PC4) | (0 << PC5);
293
      _delay_ms(30);
294
      PORTC = (0 << PC4) | (0 << PC5);
295
      _delay_ms(50);
296
      PORTC = (1 << PC4) | (0 << PC5);
297
      _delay_ms(30);
298
      PORTC = (0 << PC4) | (0 << PC5);
299
      _delay_ms(50); //340ms
300

301
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
302
      //Schaltkanal
303
      schaltkanal();    
304

305
      //Rechts
306
      PORTC = (0 << PC4) | (1 << PC5);
307
      _delay_ms(135);  
308
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker  
309
      PORTC = (0 << PC4) | (0 << PC5);
310
      _delay_ms(50);
311
      PORTC = (0 << PC4) | (1 << PC5);
312
      _delay_ms(30);
313
      PORTC = (0 << PC4) | (0 << PC5);
314
      _delay_ms(50);
315
      PORTC = (0 << PC4) | (1 << PC5);
316
      _delay_ms(30);
317
      PORTC = (0 << PC4) | (0 << PC5);
318
      _delay_ms(160); //455ms
319

320
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
321
      //Schaltkanal
322
      schaltkanal();    
323

324
      //Links
325
      PORTC = (1 << PC4) | (0 << PC5);
326
      _delay_ms(130);
327
      PORTC = (0 << PC4) | (0 << PC5);
328
      _delay_ms(25);
329
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker
330
      _delay_ms(25);
331
      PORTC = (1 << PC4) | (0 << PC5);
332
      _delay_ms(30);
333
      PORTC = (0 << PC4) | (0 << PC5);
334
      _delay_ms(50);
335
      PORTC = (1 << PC4) | (0 << PC5);
336
      _delay_ms(30);
337
      PORTC = (0 << PC4) | (0 << PC5);
338
      _delay_ms(20); //310ms
339

340
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
341
      //Schaltkanal
342
      schaltkanal();    
343

344
      //Rechts
345
      PORTC = (0 << PC4) | (1 << PC5);
346
      _delay_ms(130);    
347
      PORTC = (0 << PC4) | (0 << PC5);
348
      _delay_ms(50);
349
      PORTC = (0 << PC4) | (1 << PC5);
350
      _delay_ms(30);
351
      PORTC = (0 << PC4) | (0 << PC5);
352
      _delay_ms(50);
353
      PORTC = (0 << PC4) | (1 << PC5);
354
      _delay_ms(30);
355
      PORTC = (0 << PC4) | (0 << PC5);
356
      _delay_ms(30);
357
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker
358
      _delay_ms(100);  //420ms
359

360

361
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
362
      //Schaltkanal
363
      schaltkanal();    
364

365
//-------------------------------------------------
366

367
      PORTC = (1 << PC4) | (0 << PC5);
368
      _delay_ms(130);
369
      PORTC = (0 << PC4) | (0 << PC5);
370
      _delay_ms(50);
371
      PORTC = (1 << PC4) | (0 << PC5);
372
      _delay_ms(30);
373
      PORTC = (0 << PC4) | (0 << PC5);
374
      _delay_ms(50);
375
      PORTC = (1 << PC4) | (1 << PC5);
376
      _delay_ms(30);
377
      PORTC = (0 << PC4) | (0 << PC5);
378
      _delay_ms(50); //290ms
379

380
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
381
      //Schaltkanal
382
      schaltkanal();    
383

384
      PORTC = (0 << PC4) | (1 << PC5);
385
      _delay_ms(35);
386
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker
387
      _delay_ms(95);    
388
      PORTC = (0 << PC4) | (0 << PC5);
389
      _delay_ms(50);
390
      PORTC = (0 << PC4) | (1 << PC5);
391
      _delay_ms(30);
392
      PORTC = (0 << PC4) | (0 << PC5);
393
      _delay_ms(50);
394
      PORTC = (0 << PC4) | (1 << PC5);
395
      _delay_ms(30);
396
      PORTC = (1 << PC4) | (0 << PC5);
397
      _delay_ms(50);
398
      PORTC = (1 << PC4) | (1 << PC5);
399
      _delay_ms(30);
400
      PORTC = (0 << PC4) | (0 << PC5);
401
      _delay_ms(50);
402
      PORTC = (0 << PC4) | (0 << PC5);  
403
      _delay_ms(30); //450ms
404

405

406
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
407
      //Schaltkanal
408
      schaltkanal();    
409

410
//-------------------------------------------------
411

412
      PORTC = (1 << PC4) | (0 << PC5);
413
      _delay_ms(60);      
414
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker
415
      _delay_ms(70);
416
      PORTC = (0 << PC4) | (0 << PC5);
417
      _delay_ms(50);
418
      PORTC = (1 << PC4) | (0 << PC5);
419
      _delay_ms(30);
420
      PORTC = (0 << PC4) | (0 << PC5);
421
      _delay_ms(50);
422
      PORTC = (1 << PC4) | (0 << PC5);
423
      _delay_ms(30);
424
      PORTC = (0 << PC4) | (0 << PC5);
425
      _delay_ms(50); //340ms
426

427
      if(on_oben1==0 || on_unten1==0) goto start;//Abbruch
428
      //Schaltkanal
429
      schaltkanal();    
430

431
      PORTC = (0 << PC4) | (1 << PC5);
432
      _delay_ms(130);    
433
      PORTC = (0 << PC4) | (0 << PC5);
434
      _delay_ms(50);
435
      PORTC = (0 << PC4) | (1 << PC5);
436
      _delay_ms(15);
437
      if (blinker_an == 0){ PORTD = (0 << PD7); blinker_an = 1; } else { PORTD = (1 << PD7); blinker_an = 0;}//Blinker
438
      _delay_ms(15);
439
      PORTC = (0 << PC4) | (0 << PC5);
440
      _delay_ms(50);
441
      PORTC = (0 << PC4) | (1 << PC5);
442
      _delay_ms(30);
443
      PORTC = (0 << PC4) | (0 << PC5);
444
      _delay_ms(50);
445
      PORTC = (0 << PC4) | (1 << PC5);
446
      _delay_ms(30);
447
      PORTC = (0 << PC4) | (0 << PC5);
448
      _delay_ms(50);
449
      PORTC = (0 << PC4) | (1 << PC5);
450
      _delay_ms(30);
451
      PORTC = (0 << PC4) | (0 << PC5);
452
      _delay_ms(50);
453
      PORTC = (1 << PC4) | (1 << PC5);
454
      _delay_ms(20);
455
      PORTC = (0 << PC4) | (0 << PC5);  
456
      _delay_ms(150); //520ms
457

458
    }
459

460

461

462

463
  }
464

465
  return 0;
466

467
}
468

469

470

471

472
//---------------------------------------------------------------------------------------------------
473

474
ISR(INT1_vect) //Interruptvektor INT1
475
{
476

477

478
//SCHALTEN: HEBEL NACH UNTEN
479

480

481
  //Muss Hebel in Mitte? reset=0 NEIN ; reset=1 JA
482
  if(reset_unten1==0) //Nein muss er nicht
483
  {
484
    _delay_us(1200);  
485
    if( !(PIND & (1 << PD3)) ) //Ist Hebel unten?
486
    {
487
      if(on_unten1==0) on_unten1=1; else on_unten1=0;  //Ja ist er: Schalten
488
      reset_unten1 = 1; //Hebel muss in Mitte!
489
            
490
    }
491
  }
492

493
  else //Ja muss er
494
  {
495
    _delay_us(1400);  
496
    if(PIND & (1 << PD3)) //Ist Hebel in Mitte?
497
    {
498
      reset_unten1 = 0; //Ja ist er!
499
    }
500
  }
501

502

503

504

505
//SCHALTEN: HEBEL NACH OBEN
506

507

508
  //Muss Hebel in Mitte? reset=0 NEIN ; reset=1 JA
509
  if(reset_oben1==0) //Nein muss er nicht
510
  {
511
    _delay_us(600);  
512
    if(PIND & (1 << PD3)) //Ist Hebel oben?
513
    {
514
      if(on_oben1==0) on_oben1=1; else on_oben1=0;  //Ja ist er: Schalten
515
      reset_oben1 = 1; //Hebel muss in Mitte!
516
            
517
    }
518
  }
519

520
  else //Ja muss er
521
  {
522
    _delay_us(400);  
523
    if( !(PIND & (1 << PD3)) ) //Ist Hebel in Mitte?
524
    {
525
      reset_oben1 = 0; //Ja ist er!
526
    }
527
  }
528

529
  _delay_us(1000);
530

531

532
}
533

534

535

536
//---------------------------------------------------------------------------------------------------
537

538
ISR(INT0_vect) //Interruptvektor INT0
539
{
540

541

542
//SCHALTEN: HEBEL NACH UNTEN
543

544

545
  //Muss Hebel in Mitte? reset=0 NEIN ; reset=1 JA
546
  if(reset_unten1==0) //Nein muss er nicht
547
  {
548
    _delay_us(1200);  
549
    if( !(PIND & (1 << PD3)) ) //Ist Hebel unten?
550
    {
551
      if(on_unten1==0) on_unten1=1; else on_unten1=0;  //Ja ist er: Schalten
552
      reset_unten1 = 1; //Hebel muss in Mitte!
553
            
554
    }
555
  }
556

557
  else //Ja muss er
558
  {
559
    _delay_us(1400);  
560
    if(PIND & (1 << PD3)) //Ist Hebel in Mitte?
561
    {
562
      reset_unten1 = 0; //Ja ist er!
563
    }
564
  }
565

566

567

568

569
//SCHALTEN: HEBEL NACH OBEN
570

571

572
  //Muss Hebel in Mitte? reset=0 NEIN ; reset=1 JA
573
  if(reset_oben1==0) //Nein muss er nicht
574
  {
575
    _delay_us(600);  
576
    if(PIND & (1 << PD3)) //Ist Hebel oben?
577
    {
578
      if(on_oben1==0) on_oben1=1; else on_oben1=0;  //Ja ist er: Schalten
579
      reset_oben1 = 1; //Hebel muss in Mitte!
580
            
581
    }
582
  }
583

584
  else //Ja muss er
585
  {
586
    _delay_us(400);  
587
    if( !(PIND & (1 << PD3)) ) //Ist Hebel in Mitte?
588
    {
589
      reset_oben1 = 0; //Ja ist er!
590
    }
591
  }
592

593
  _delay_us(1000);
594

595

596
}
Gast #2346865
Lesenswert?

>Du sagst, Du hast Dein Kabel von PD3 auf PD2 umgelötet. Warum wird dann
>in der INT0 ISR (PD2) der Status von PD3 abgefragt?


Genau das war der Fehler. Ich bin echt ein Trottel...ICH WERDE NIE 
WIEDER CODE KOPIEREN.

Sowas passiert mit andauernt, weil man Code kopiert. Einfach nur 
dämlich.

Vielen Vielen Dank für eure Hilfe und Geduld.

Gruß!

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren