In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: Bean, If you have an int_period of 217 and no prescaler you only have 217 cycles available inside the isr. Inside the isr a counter is decremented and when it reaches zero it does a context switch, allowing a subroutine to run after the isr exits. This counter is reloaded and decremented inside the isr while the subroutine runs as mainline code. If the reload value is 100, then you have 100*217 cycles available for the subroutine, assuming the subroutine must return to not miss the next context switch. That is how it currently is setup. I mentioned in an earlier post that timing issues with a task, eg. the subroutine takes longer than 1 TASKTICK, can be resolved by using a statemachine in that subroutine so you can make sure the subroutine returns on time. Next time the subroutine runs it can continue where it was. Your example of two tasks each lasting for 3 TASKTICKs and 5 ticks apart made me think. I can change the setup so that when a task is already running when a context switch should occur, that I decrement the taskDelay(1) by 1. That is sufficient to have taskDelay(1) set to 2 when the running task returns after 3 TASKTICKs. That is quite a bit better than the statemachine solution, though that still could be used. regards peter ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=2&m=157842#m176181 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)