Looks to me like you have to do some big time reorganization of your program...You've got it jumping all over everything...
Here's how I normally do things...might not be optimal, but it keeps me out of trouble:
Defines
Variable declarations
ASsembly macros
Skip over Int Handler/Subroutines
On Interrupt statement
Int Handler routine
Subroutines
PIC, PIC pins and other hardware Setup/Initialization
Main body
And besides all that, I don't see where you clear the TMR0 overflow flag like it says you have to do in the datasheet. I see you enable the TMR0 interrupt a couple of times which has the side effect of clearing the flag...but probably not at the right time.




Bookmarks