Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Mar 2025

xEventGroupClearBits()

[Event Group API]

event_groups.h

1EventBits_t xEventGroupClearBits(
2 EventGroupHandle_t xEventGroup,
3 const EventBits_t uxBitsToClear );

Clear bits (flags) within an RTOS event group. This function cannot be called from an interrupt. See xEventGroupClearBitsFromISR() for a version that can be called from an interrupt.

The RTOS source file FreeRTOS/source/event_groups.c must be included in the build for the

xEventGroupClearBits()
function to be available.

Parameters:

  • xEventGroup

    The event group in which the bits are to be cleared. The event group must have previously been created using a call to xEventGroupCreate().

  • uxBitsToClear

    A bitwise value that indicates the bit or bits to clear in the event group. For example set

    uxBitsToClear
    to 0x08 to clear just bit 3. Set
    uxBitsToClear
    to 0x09 to clear bit 3 and bit 0.

Returns:

  • The value of the event group before the specified bits were cleared.

Example usage:

1#define BIT_0 ( 1 << 0 )
2#define BIT_4 ( 1 << 4 )
3
4void aFunction( EventGroupHandle_t xEventGroup )
5{
6 EventBits_t uxBits;
7
8 /* Clear bit 0 and bit 4 in xEventGroup. */
9 uxBits = xEventGroupClearBits(
10 xEventGroup, /* The event group being updated. */
11 BIT_0 | BIT_4 ); /* The bits being cleared. */
12
13 if( ( uxBits & ( BIT_0 | BIT_4 ) ) == ( BIT_0 | BIT_4 ) )
14 {
15 /* Both bit 0 and bit 4 were set before xEventGroupClearBits()
16 was called. Both will now be clear (not set). */
17 }
18 else if( ( uxBits & BIT_0 ) != 0 )
19 {
20 /* Bit 0 was set before xEventGroupClearBits() was called. It will
21 now be clear. */
22 }
23 else if( ( uxBits & BIT_4 ) != 0 )
24 {
25 /* Bit 4 was set before xEventGroupClearBits() was called. It will
26 now be clear. */
27 }
28 else
29 {
30 /* Neither bit 0 nor bit 4 were set in the first place. */
31 }
32}