SX/B ISR ReturnINT value
Dunnsept
Posts: 115
Currently my ISR is the generic one from the help files for a clock/timer. The only modification so far is what Bean wrote to change tix from 200 to 125 and returnint from 156 to 250.
I want to add code to my ISR a la the examples for updating my display (going to add one of Bean's HC4LEDs to the system).· What method should I use, if any, to re-calc my RTCC return value and tix counter? Do I even need to worry about it? I don't need great accuracy, but still would like to know.
I·read in Guenther's book all·of the stuff about·counting the clocks for the ISR, is this also the method for SX/B? Go and look at the generated code and find out what my cycle count is for the ISR?
Is it that as long as I'm under·some value (something in the book about nc-7, dont have it with me, and can't remember)
·I am·good to go?
figured I'd better add this part:
I want the display to cycle between time and temp every.. ooooohhh..say 5 seconds.. maybe it's better to handle this in main code instead of in the ISR, but I'd still like to know how best to figure returnint values for SX/B
thanks!
Post Edited (Dunnsept) : 4/20/2006 5:44:32 PM GMT
I want to add code to my ISR a la the examples for updating my display (going to add one of Bean's HC4LEDs to the system).· What method should I use, if any, to re-calc my RTCC return value and tix counter? Do I even need to worry about it? I don't need great accuracy, but still would like to know.
I·read in Guenther's book all·of the stuff about·counting the clocks for the ISR, is this also the method for SX/B? Go and look at the generated code and find out what my cycle count is for the ISR?
Is it that as long as I'm under·some value (something in the book about nc-7, dont have it with me, and can't remember)
·I am·good to go?
ISR_Start: INC tix ' update tix counter IF tix = 125 THEN ' check for 1 second tix = 0 INC secs if use_extra = 1 then inc extra_secs endif IF secs = 60 THEN ' check for new minute secs = 0 INC mins if extra_secs = 60 then inc time1 extra_secs = 0 endif IF mins = 60 THEN ' check for new hour mins = 0 INC hrs IF hrs = MaxHr THEN hrs = 0 ENDIF ENDIF ENDIF ENDIF ISR_Exit: RETURNINT 250
figured I'd better add this part:
I want the display to cycle between time and temp every.. ooooohhh..say 5 seconds.. maybe it's better to handle this in main code instead of in the ISR, but I'd still like to know how best to figure returnint values for SX/B
thanks!
Post Edited (Dunnsept) : 4/20/2006 5:44:32 PM GMT
Comments
I don't think you'll need to change the returnint value. As long as your interrupt routine takes less cycles than the returnint value (times prescaler) then your okay (well you need to allow 7 cycles for calling and return from the interrupt).
Usually unless there is a very good reason to put a section of code in an interrupt I wouldn't do it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available·for only·$49.95·www.sxvm.com
Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com
"I reject your reality, and substitute my own." Mythbusters
·
soooo.... how did you figure that the return 250 and tix = 125 is more accurate than tix=200 and return 156? counting cycles or what?
I kinda figured after the fact that I should put the code in the main, but the SX/B example for the clock has the update routines in the ISR, that's where I was getting confused about how much code I can add to my ISR before I have to worry about the timing.
Brings up the other part, to figure the cycles for my ISR in SX/B is it best to go look at the output or can I say something like "ok, high rc.7 will take 2 cycles" or whatever it really is.
Paul...
You had 4,000,000Hz(clock) / 128(prescaler) = 31250Hz(RTCC clock) / 156(returnint value) = 200.3205 interrupts per second
The easiest way to count ISR cycles is to let SXSim do it for you.
But with ReturnInt = 250 and prescaler = 128, your ISR can take up to 32000 cycles (okay a little less) without problems.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module"·available·for only·$49.95·www.sxvm.com
Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com
"I reject your reality, and substitute my own." Mythbusters
·