Hi, I am learning how to program pics and am having trouble with making interupts happen on a PIC18F6720.
I set all the bits that I think I need to enable functionality and then go into a endless loop and watch my variable values with some watches. I can see TMR0IF being set to a 1 when my timer overflows, but once it overflows it will not automatically branch to either my high or low priority address where it would clear the TMR0IF bit and execute the code that happens on a timer overflow.
Here is the meat of my code:
Am I wrong in assuming that when animating in debug mode, once the timer bit overflows the green arrow should move up to:
Which was set further up via:
I am brand new to this and have been following the tutorial at http://www.gooligum.com.au/tutorials/midrange/PIC_Mid_A_6.pdf to the best of my ability. There are so many differences though that sometimes I have some trouble converting the code for his PIC16F to PIC18F code, plus I have a later version of MPLAB (8.33) so there are differences in syntax which I have to try and covert. Just doing the best I can.
I set all the bits that I think I need to enable functionality and then go into a endless loop and watch my variable values with some watches. I can see TMR0IF being set to a 1 when my timer overflows, but once it overflows it will not automatically branch to either my high or low priority address where it would clear the TMR0IF bit and execute the code that happens on a timer overflow.
Here is the meat of my code:
Rich (BB code):
Start: ;Start of main program
BCF T0CON,T0CS ;clear the source edge bit (timer mode)
BSF T0CON,PSA ;dont assign a prescaler
BSF INTCON2,TMR0IP ;make it high priority
BSF RCON,IPEN ;enable priority lvls on all interupts
BSF INTCON,GIE ;turn on interupts
BSF INTCON,TMR0IE ;turn on interups for timer0
BSF T0CON,TMR0ON ;turn on the timer
GOTO MainLoop
MainLoop:
GOTO MainLoop
Rich (BB code):
HighInt:
; *** high priority interrupt code goes here ***
BCF INTCON,T0IF ;clear the interupt overflowed flag
retfie FAST
Rich (BB code):
HI_INT_VECTOR CODE 0x0008 ;High priority interrupt vector
bra HighInt ;go to high priority interrupt routine