In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote: Ray, If you want an interrupt to occur every 100 cycles, of course the interrupt routine will have to be less than 100 cycles. Here is what happens: Your main program is merrily going about it's business, RTCC is increamenting with each clock cycle. All of a sudden RTCC rolls-over (from 255 to 0), the interrupt is started (I think there is a 3 cycle delay until the first interrupt instruction is executed). Now RTCC is STILL merrily increamenting while we are in the interrupt routine. Let's suppose that the interrupt routine took 40 cycles(including overhead), so RTCC would be 40. Now if RTCC was not adjusted the next interrupt would be 216 cycles later, but we are going to use RETURNINT 100 That means that RTCC is is going to be 40-100 or 40 + 156 = 196 so the next interrupt will occur 60 cycles later. You see how the time spend inside the interrupt routine is accounted for. The interrupt routine can take different number of cycles, but it will always be called every 100 cycles no matter what. I hope I didn't confuse you any more... Bean. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=104346#m104414 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)