Hallo zusammen!
Ich habe mich in den letzten paar Wochen das erste Mal mit einem PIC
Mikrocontroller auseinander gesetzt. Mit Atmel uC habe ich jedoch schon
viel Erfahrung.
Ich habe nun folgendes Problem:
Wenn ich die Interrupts eingeschaltet habe, wird das Hauptprogramm
blockiert.
Schalte ich nur das Timer1 Interrupt aus funktioniert alles einwandfrei.
Woran kann das liegen?
Hier meine Timer1 Initialisierung:
1 | T1CKPS1 = 0; //T1CKSPS1:0 set prescaler to 1:1
|
2 | T1CKPS0 = 0;
|
3 | T1OSCEN = 1; //Enable the oscillator
|
4 | TMR1CS = 0; //Work with the internal clock
|
5 | TMR1ON = 1; //Timer 1 off
|
6 | TMR1H = 244; //Clear TMR1 Register
|
7 | TMR1L = 72;
|
8 | TMR1IE = 1;
|
9 | TMR1IF = 0;
|
Hier meine Interrupt Initialisierung:
1 | GIE = 1; //enable every interrupt
|
2 | INTE = 1; //enable the INT pin interrupt
|
3 | INTEDG = 1; //go to interrupt by rising edge
|
4 | PEIE = 1; //enable all peripheral interrupts
|
Und hier noch meine Interruptroutine:
1 | interrupt IR(void) //Interruptroutine for INT input
|
2 | {
|
3 | if(INTF) //If the interrupt input is high
|
4 | {
|
5 | RB5 ^= 1; //Action in interrupt
|
6 | INTF = 0; //Clear the interrupt flag
|
7 | }
|
8 |
|
9 | if(TMR1IF == 1) //Timer1 Overflow
|
10 | {
|
11 | RB5 ^= 1; //Action in interrupt
|
12 | TMR1IF = 0; //Clear the interrupt flag
|
13 | TMR1H = 244;
|
14 | TMR1L = 72;
|
15 | }
|
16 | }
|
Vielen Dank schon im voraus!
Marc