' Multitasking.bas ' a simple multitasking tutorial ' by C.D.Odom on 2-14-06 ' www.basicxandrobotics.com ' chris_odom@georgeschool.org Option Explicit ' Set aside memory space for the task: Dim RedLEDStack(1 to 50) as Byte ' Here, I set aside 50 bytes of space. ' To determine the exact stack space required, ' use Don Kinzer and Mike Perk's bxDism program found at: ' http://home.austin.rr.com/perks/micros/bxDism/ Public Sub Main() Dim i as Integer CallTask "RedLEDTask", RedLEDStack ' Call the RedLEDTask, which will run in the background ' While it counts to 500, watch the onboard Red LED. You should notice that ' RedLEDTask does not interrupt the Main program For i = 1 to 500 Debug.Print "i = " & CStr(i) Next End Sub ' ////////////////////// RedLEDTask /////////////////////// Public Sub RedLEDTask() Do Call PutPin(25,0) ' Turn Red LED on Call Delay(0.2) Call PutPin(25,1) ' Turn Red LED off Call Delay(0.5) Loop End Sub