In SX Microcontrollers, SX/B Compiler and SX-Key Tool, peterverkaik wrote: A very special update this time. I have been trying to combine the dynamic VP's with the TASK commands. No luck for several reasons, mainly because of interrupt code overheaded caused by using the TASK code. So I cleaned up my optimized TASK implementation that I had offered before (in the beta forum) but that was rejected for unclear reasons. My TASK implementation is located in file TaskSwitch_DEF.SXB and consists only of macros (so there is no TaskSwitch_INC.SXB file). ' ------------------------------------------------------------------------- ' Library Description ' ------------------------------------------------------------------------- ' This library provides an alternative TASK implementation for the SXB 2.0 ' builtin TASK comands. This implementation still uses the builtin TASK ' declarations, but one has to call \mTaskList that generates a list ' of tasks (used by the TaskScheduler), and \mTaskInit that initializes ' the task variables. ' ' The reason for this alternative implementation is that the builtin implementation ' uses interrupt code which size grows with the number of task slots, leaving ' less isr cycles for other code (like dynamic VP's). This alternative implementation ' has a fixed and smaller size interrupt code. The maximum number of task slots that can ' be used with this implementation is 5 for all SX devices. The builtin implementation ' allows 5 for sx18/20/28 and 8 for sx48/52. ' ' There are macros defined that replace the builtin TASKS comands: ' \mTaskDisable replaces TASKS DISABLE ' \mTaskEnable replaces TASKS ENABLE ' \mTaskStop slot replaces TASKS STOP,slot ' \mTaskStart slot replaces TASKS START,slot ' \mTaskSuspend slot,ticks replaces TASKS SUSPEND,slot,ticks ' \mTaskSet slot,name,interval,delay replaces TASKS SET,slot,name,interval,delay ' \mTaskIsr replaces TASKS RUN,tasktick[,tasks] (inside isr) ' ' There is an additional macro for TASKS SUSPEND for use within a TASK routine. ' \mTaskReschedule ticks replaces TASKS SUSPEND,slot,ticks ' This is to let a task reschedule itself without the need to preserve __PARAM1 upon task entry. The test program runs a serial transmit and serial receive VP, plus two tasks (116 isr cycles max). You can comment out the '{$define USE_DynamicVP} at the start and the test program merely runs the two tasks (54 isr cycles max). Adding more tasks has no effect on the isr. The two tasks are LEDs flashing at different rates. Just unzip in a folder and load DynamicVP_test_TASK1.SXB Enjoy. regards peter ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=328202#m337031 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)