Einen schönen guten Abend ans Forum,
habe eine Frage zur Interrupt-Behandlung bei PICs. Mein PIC soll beim
Drücken einer Taste für's Erste eine LED an PORTB6 anschalten um die
Funktion des Interrupt zu testen. Leider scheint die SW niemals in den
Interrupt zu kommen und ich würde gerne wissen warum. Hier der
Quellcode:
1 | #include <stdio.h>
|
2 | #include <stdlib.h>
|
3 | #include <pic.h>
|
4 |
|
5 | int Zustand;
|
6 |
|
7 | void interrupt isr(void)
|
8 | {
|
9 | if (INTF)
|
10 | {
|
11 | INTF = 0;
|
12 | }
|
13 | Zustand = 0b01000000;
|
14 |
|
15 | }
|
16 |
|
17 | void main(void) {
|
18 |
|
19 | int t = 0;
|
20 | Zustand = 0b00000000;
|
21 |
|
22 | TRISBbits.TRISB4 = 0;
|
23 | TRISBbits.TRISB5 = 0;
|
24 | TRISBbits.TRISB6 = 0;
|
25 |
|
26 | INTCONbits.GIE = 1;
|
27 | INTCONbits.INTE = 1;
|
28 |
|
29 | while(1)
|
30 | {
|
31 |
|
32 | PORTB = (0b00010000 | Zustand);
|
33 | for (t = 0; t < 16000; t++)
|
34 | {
|
35 | NOP();
|
36 | }
|
37 | PORTB = (0b00110000 | Zustand);
|
38 | for (t = 0; t < 16000; t++)
|
39 | {
|
40 | NOP();
|
41 | }
|
42 | PORTB = (0b00000000 | Zustand);
|
43 | for (t = 0; t < 16000; t++)
|
44 | {
|
45 | NOP();
|
46 | }
|
47 | }
|
48 | }
|
Vielen Dank für eure Hilfen!!