Issue about xEventGroupClearBits()

hi,
example code below:
I def a one-shot softwaretimer ,whose period is 10000ms;

void vTimerCallBack( TimerHandle_t xTimer)
{
if( xTimer == xTimerHandle )
{
xEventGroupClearBits( xEventGroupHandle, 0x00ffffff );
}
}
at a task,I start the timer.
void vTaskA( void *pvPara )
{
for( ;; )
{
xTimerReset( xTimerHandle , 5 );
vTaskSuspend( NULL );
}
}
What I want to do is clear all bits in the EventGroup.
if the parameter set 0x00ffffff; no bad happen. it run well;
but if set 0xffffffff, start timer ,and after 10 senconds app crashed, and reset by WDT.
all helpul imformation welcome.

An event group only has 24 (or 8 if configUSE_16_BIT_TICK is set) event bits, so a clear (or set) value above 0x00FFFFFF is acting on bits that aren’t available. It shouldn’t ‘crash’, but it could have an assert on the value. If you break with a debugger at that point, is it stuck in an assert?

The reason for the upper limit is that internally FreeRTOS uses those upper bits in places to handle other information.

1 Like

thanks,your words resolved it.

1 Like

hi,I think these upper 8 bits limit are all 0 for now time. am i right? Has FreeRTOS use them already at some where internally until V10.

I’m not sure I understand your question - but the restrictions on which bits are used by the user and which by the kernel has not changed since the feature was introduce.

I mean for example。when calling xBits = xEventGroupGetBits( xEventGroup ); then I poll xBits, like this:
if(xBits == 0x00000010){ do something; } , because only 24bits of xBits is for user, so Should I poll xBits like
this: if( (xBits&0x00ffffff) == 0x00000010 ){do something ;}? which one is correct?

FreeRTOS will always return 0 for the upper 8 bits of the event word. It internally uses those bits in messages for manipulating events (if I remember right, for example, if an ISR posts some event bits, which is deferred to the Timer/Service task due to the unpredictable time it would take.).