Franck84
Newbie level 4
Hi,
my name is Franck. I have got a problem with my code. Basically the program is not going to the interrupt routine when PR2 and TMR2 match. That will be great if someone can help me on that. I have no idea what can be wrong. On the mplab watch window I can observe the flag on TMR2IF when PR2 equals TMR2 following by the reset of TMR2. But impossible to see the increment of "count"
Thanks
Here is my code:
PS: I am using MPLAB v8.60, C18 compiler
my name is Franck. I have got a problem with my code. Basically the program is not going to the interrupt routine when PR2 and TMR2 match. That will be great if someone can help me on that. I have no idea what can be wrong. On the mplab watch window I can observe the flag on TMR2IF when PR2 equals TMR2 following by the reset of TMR2. But impossible to see the increment of "count"
Thanks
Here is my code:
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 #include <p18f4610.h> #include<stdio.h> #include<delays.h> #include<timers.h> #pragma config WDT=OFF , OSC=HS , PWRT = ON, LVP=OFF #pragma interrupt isr int count=0; void isr(void) { if(PIR1bits.TMR2IF==1) { count=count++; PORTAbits.RA0=1; } PIR1bits.TMR2IF=0; } void main (void) { //T2CON=0x7F; T2CONbits.T2OUTPS0=0; T2CONbits.T2OUTPS1=0; T2CONbits.T2OUTPS2=0; T2CONbits.T2OUTPS3=0; T2CONbits.TMR2ON=1; // turn on the timer2 T2CONbits.T2CKPS0=1; T2CONbits.T2CKPS0=1; PR2= 100; PIE1bits.TMR2IE=1; //Enable TIMER2 Interrupt INTCONbits.PEIE=1; //Enable Peripheral Interrupt INTCONbits.GIE=1; //Enable INTs globally }
PS: I am using MPLAB v8.60, C18 compiler
Last edited by a moderator: