element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum Have a question about Micrium's embedded software? Ask our Expert, Matt Gordon
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 35 replies
  • Subscribers 495 subscribers
  • Views 4305 views
  • Users 0 members are here
  • applications
  • device
  • embedded
  • kernel
  • micrium
Related

Have a question about Micrium's embedded software? Ask our Expert, Matt Gordon

Former Member
Former Member over 14 years ago

This thread has been closed to new questions.

However, we welcome you to Post Your Question about Embedded in the element14 Community Embedded group. You'll find many fellow members and experts who have just the answer you're looking to find! 

 

Thank You, Your Friends at element14 Community

image

 

Matt Gordon

Matt Gordon is a senior applications engineer at Micrium.  He began his career developing device drivers, kernel ports, and example applications for Micrium's customers.  Drawing on this experience, Matt has written multiple articles on embedded software.  He also heads Micrium's training program and regularly teaches classes on real-time kernels and other embedded software components.  Matt holds a bachelor's degree in computer engineering from Georgia Tech, Georgia in the USA.


  • Sign in to reply
  • Cancel
Parents
  • Former Member
    Former Member over 14 years ago

    Hi Matt,

     

    You have been a great help, just one little thing, how to use the flags in uC/OS-III. I define the bits, create the flag, pend the flag and after the task is executed I post the flag, but I guess its not as simple as using a semaphore, beacuse its not working. Please help Matt. image

     

    Regards,

    jumbowat

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Former Member
    Former Member over 14 years ago

    Hi Matt,

     

    You have been a great help, just one little thing, how to use the flags in uC/OS-III. I define the bits, create the flag, pend the flag and after the task is executed I post the flag, but I guess its not as simple as using a semaphore, beacuse its not working. Please help Matt. image

     

    Regards,

    jumbowat

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Former Member
    Former Member over 14 years ago in reply to Former Member

    To some extent, event flags are like collections of binary semaphores.  Each flag represents an event and can be in one of two possible states: the event has taken place, or it hasn’t.  Your application can wait on these events using a pend function similar to the one provided as part of uC/OS-III’s semaphore API. 

     

    The pend function, which is named OSFlagPend(), accepts a number of arguments, the second of which is a bit pattern indicating the particular flags that are of importance to the calling task.  The function also accepts an options value that allows the calling task to specify whether it will wait for all (an “and” pend) or any (an “or” pend) of the designated events to take place.  A return from the pend function typically occurs once the conditions established by the calling task through these two arguments have come into existence.  However, the calling task can use another of the function’s arguments to specify a timeout, a period of time after which the function will return regardless of which events have taken place. 

     

    The pend function’s counterpart is the event flag post function, OSFlagPost().  Like pend, this function accepts an argument that specifies a set of flags.  In the case of post, though, the calling task will not wait on these flags; instead, the kernel will update the flags’ values to indicate that the events to which they correspond have taken place. 

     

    Example pend and post calls are shown below.  Additional example code can be found in the uC/OS-III books available from the knode.   

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 14 years ago in reply to Former Member

                                                                                     /* Flag creation code                          */

     

    OSFlagCreate(&AppFlagEx,                                        /* Pointer to OS_FLAG_GRP structure */

                         "Example Flag",                                    /* String name for flags                        */

                          0,                                                        /* Initial flag values                              */

                          &err);                                                   /* Error pointer                                    */

     

    void AppTaskA (void *p_arg)

    {

     

        while (1) {

            OSFlagPend(&AppFlagEx,                                   /* Pointer to OS_FLAG_GRP structure */

                                0x0003,                                          /* Specify bits 0 and 1                         */

                                100,                                               /* Wait for a maximum of 100 ticks       */

                                OS_OPT_PEND_FLAG_SET_ALL,   /* Wait for both flags to be set              */

                                0,                                                   /* No timestamp for this example          */

                                &err);                                              /* Error pointer                                    */

     

            Take actions that must follow occurrence of events;

        }

    }

     

    void AppTaskB (void *p_arg)

    {

     

        while (1) {

            OSFlagPost(&AppFlagEx,                                   /* Pointer to OS_FLAG_GRP structure   */

                               0x0003,                                          /* Specify bits 0 and 1                           */

                               OS_OPT_POST_FLAG_SET,           /* Indicate that bits will be set                */

                               &err);                                              /* Error pointer                                      */

     

            Perform additional work;

        }

    }

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 14 years ago in reply to Former Member

    Hey Matt, thank you so much image

     

    Also, if I want to make a task start from the beginning if I interrupt it in the middle of a task, then do I have an option of using something other than OSTaskDel(). What i mean is suppose my task is printing 1 to 100 and then I interrupt it at 55, now when I want to restart the task but it should start the counting again from 1, insteading of continuing it from 55.

     

    Regards.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube