Hi all,
i have stuck with interrupt problem. My program doesn't enter into the interrupt routine. I am using PIC16F877A with 4 MHz crystal freq.I used MP LAB with Hi-tech C.following is my code
thaq milan it works
mind to explain why my code is not working
i have one more doubt . it only once enter into the isr.if i clear Count1 in the if loop the port doesn't change any more. why these al happens. :roll:
Genraly u require configuration bit for selecting internal or external crystal try this for external crystal
__CONFIG (0x0005);
also don't initializes any variable in ISR
don't make TMR1IE again in ISR it require only once instead u reload count of timer in ISR
try for
TMR1H=0XF0;
TMR1L=0XFF;
The most common reason an interrupt only works 1 time is the simple fact that it is not reenabled. There are two causes for this, the first is that the interrupt itself is not reenabled, the second is that the return from the ISR does not enable the master interrupt flag.
Just to clarify. It is the interrupt that needs to be reeabled, not the timer. I've only programmed the PIC processores in Assembly, but there are 2 different return instructions, RETURN from a normal subroutine, and RETFIE from ISR routines. The last one will reenable the master interrupt flag.
When dealing with ISRs you should also be aware of the corruption of the status register, if you don't save it when entering an ISR.
Interrupt enable activity is done once before the main but in ISR u require to clear corresponding interrupt flag , require to reload count of timer. No need to re enable as it not disable.
If u don't know basic then don't try programming instead start reading datasheet, basic function of timer , crystal , compiler etc then start coding otherwise u require lot of time to study