In SX Microcontrollers, SX/B Compiler and SX-Key Tool, PJMonty wrote: [quote="CBMeeks"]Follow along and let me know if I am wrong. Let's say I want an interrupt to occur every 900 clocks. Now, I assume I set the prescaler to 1:4 because 256 clocks * 4 = 1024 clocks. Next I run my code and let's say it runs for 850 clocks (under my 900 limit). I would then call a RETIW W, -#124 because 1024 - 900 = 124. Is this correct?[/quote] Peter's description is correct, but I thought I would use your example directly. You may have already figured all of this out, but I'm putting it here in case it can elp anyone else. Your use of the of the 1:4 prescaler is correct, but the rest of your example is wrong. If you specifically wanted an interrupt of 900 clocks, you would divide your desired number of cycles (900) by the prescaler (4) to give: 900 / 4 = 225. You would then just put the following at the end of your interrupt routine: [code]retiw w, #-225[/code] Through the coolness of the SX interrupt hardware, you would now be generating an interrupt every 900 clock cycles [b]regardless of the length of your interrupt code execution as long as it is shorter than the total interrupt duration.[/b] In other words, if your interrupt code took 100 cycles to execute one time, and 832 cycles the next, that simple "retiw w, #-225" will automatically put the right value into the hardware so that regardless of where the RTCC count is, the next interrupt will occur on your desired 900 cycle interrupt duration. The jitter free interrupt structure of the SX is perhaps the single best and single most misunderstood feature of the SX chip. [list]Thanks, PeterM[/list] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=144847#m145133 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)