Unzählige mal bin ich jetzt schon durchs Datenblatt, hab mir Beispiele
angeschaut und trotzdem funktioniert der Interrupt nicht...
1 | #include <avr/io.h>
|
2 | #include <avr/interrupt.h>
|
3 |
|
4 | void interrupt_init()
|
5 | {
|
6 | // rising edge on INT0 creates an interrupt
|
7 | MCUCR |= (1 << ISC00)|(1 << ISC01);
|
8 | // turns on interrupt for INT0
|
9 | GIMSK |= (1 << INT0);
|
10 | // allow global interrupts
|
11 | sei();
|
12 | //or 'SREG |= (1 << 7);'
|
13 |
|
14 | }
|
15 |
|
16 | int main(void)
|
17 | {
|
18 | //PB1 as OUTPUT
|
19 | DDRB |= (1 << PB1);
|
20 | //PB2 as INPUT
|
21 | DDRB &= ~(1<<PB2);
|
22 | //PB2 PULLUP
|
23 | PORTB |= (1 << PB2);
|
24 |
|
25 | // initialize interrupt
|
26 | interrupt_init();
|
27 |
|
28 | // loop forever
|
29 | while(1)
|
30 | {
|
31 | }
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 | ISR(INT0_vect){
|
37 | PORTB ^= ( 1 << PB1 );
|
38 | }
|
Hab Vcc über einen Taster an PB2, also INT0 angebracht, während der
Logic-Analyzer Daten von PB1 sammelt betätige ich den Schalter, ohne
jegliche Änderung an PB1 festzustellen.