In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: From a user point of view, it might be better to specify a task interval time as a rate, just as with interrupt. The compiler can calculate the interval time ticks. Also, the initial taskDelay can be set to 1 for all tasks, meaning 1st task runs at 1, 2nd task runs at 2, etc. After a task has run, it will be rescheduled using its interval tick. So we can use myTask TASK rate where rate equals the number of times per second the task must run. The totalTaskRate equals the sum of the 8 tasks with the highest rates. From this TASKTICK can be calculated. Example: interrupt rate is 100_000 (isr cycle time is 10usec) 8 tasks all with rate 50, then totalTaskRate is 400 TASKTICK = isrRate/totalTaskRate = 100_000/400 = 250 TASKTICK should calculate into range 1 to 256, if not, the user must specify another interrupt rate or other task rates. Bean, you suggested that TASKTICK should be runtime configurable. I don't think that is wise, because TASKTICK is global to all tasks. Better to change a task's interval tick to adjust the task rate. With the given test program, a task can easily change its own interval tick. When a task runs, and it alters its interval tick, it will be rescheduled with this new tick upon return. The only problem with changing interval ticks (eg. taskrate), is that TASKTICK also should be recalculated then, and because of that, also the interval ticks of all tasks. However, if a task changes its interval tick for a short time, and then restores the original value, it may not give problems at all. 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#m176102 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)