Re: Where to place DISABLE/ENABLE INTERRUPT
Thanks Henrik,
I knew that ENABLE/DISABLE were compiler directives but the PBP manual wasn't clear to me on whether each block of code needed the directive or if you could group several unrelated subroutines and then place the directive just once at the beginning and end of the block.
Which leads me to ask is it necessary to have them in matched pairs?? I'm guessing not.
That if you have a block of subroutines at the end of your code you could just place an ENABLE at the beginning of the block and assume that all the following code will have interrupts enabled.
I guess it's time for me to dig into Darrel's INSTANT INTERRUPTS as I am seeing jitter in the timing of my interrupt service routine. I believe it is due to the interrupt not happening until the current statement finishes.
I toggle a PortPin in the ISR and look at it on an o-scope. Based on my settings for TIMER1 it should INT every 5 msecs but instead of the the square wave being fairly solid it wanders slightly.
here is the code for my ISR handler...
Code:
'***************************************************
' interrupt service routine
' H & L size determine INT timing
' INT should happen every .005 seconds
'***************************************************
disable interrupt
MyInt:
IntFlag=1 ' INT has fired so set this flag for Main code usage
TMR1H = $FB ' reset timer1h
TMR1L = $27 ' reset timer1l
toggle PortA.0 ' used for determining INT timing
PIR1.0 = 0 ' clear timer1 overflow flag
resume 'to Main
enable interrupt
'=============================================================
Last edited by Heckler; - 19th February 2016 at 23:25.
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Bookmarks