Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Example to use Separate Task to Execute a Command

 
Post new topic   Reply to topic    Forum Index -> Files
Author Message
mikep



Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX

Posted: 01 March 2008, 21:54 PM    Post subject: Example to use Separate Task to Execute a Command Reply with quote

Here is a simple example of how to use a separate task to perform some operation; in this case flip a I/O port bit to sound a buzzer (zero turns on the buzzer). If the buzzer is already on then no action is taken. The example shows how to wake up a sleeping task so that it can start the action right away and then control is passed back to the caller. At a later time the task asynchronously ends the action.

Here is some of the example output:
Code:
0.1 Sleeping
2.1 Sleeping
4.1 Wakeup
4.1 Buzz
8.1 Already awake
9.1 Sleeping
11.1 Sleeping
12.1 Wakeup
12.1 Buzz
16.1 Already awake
17.1 Sleeping
19.1 Sleeping
20.1 Wakeup
20.1 Buzz
The corresponding annotated timing diagram is shown below. Note that the various sleep periods in this example have been chosen to show how the program works rather than what might be used in reality. For example the buzzer may only be turned on for 250ms rather than 5 seconds. The task sleep time can be set to a very large value because it is woken up when needed by the SoundBuzzerNoWait() routine.


timing_diagram.jpg
 Description:
Example Timing Diagram
 Filesize:  25.67 KB
 Viewed:  8036 Time(s)

timing_diagram.jpg



TaskExample.zip
 Description:
Example Code

Download
 Filename:  TaskExample.zip
 Filesize:  25.04 KB
 Downloaded:  3427 Time(s)

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> Files Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group