In SX Microcontrollers, SX/B Compiler and SX-Key Tool, PJMonty wrote: Paul, No, you don't have to compensate for anything. That's what the "-136" is all about. Thanks to the magic of integer math (and good design work by the folks that made the SX), the interrupt duration [i]expressed as a negative number[/i] is added to the current RTCC value and the result is the number of cycles needed to create the same duration interrupt [b]calculated from when the current interrupt began.[/b] Think about it - you never see people struggle to make sure that the interrupt code is always the same length no matter what path is chosen. If you had to do that, it would be next to impossible to create jitter free interrupts without herculean coding efforts. The really cool thing about the SX is that all you have to ensure is that the longest path of your interrupt code is shorter than the length of the interrupt period. Do this and you'll always have a fixed and jitter free interrupt rate. It doesn't matter if one path through the interrupt code takes 16 cycles and a different path takes 100. As long as the longest code path is shorter than the interrupt period, setting w to a negative version of the desired interrupt period lets the SX guarantee consistency. finally, remember that the interrupt code duration is counted in clock cycles, but the RTCC interrupt period is counted in prescaled clock cycles. If the prescaler is at 2:1, then setting an interrupt period of -100 gives you 200 clock cycle of execution due to the prescaler. Cool stuff. [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=84910#m84983 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2005 (http://www.dotNetBB.com)