Skip to main content
Associate III
July 28, 2025
Question

Issue with creating event flag in ThreadX

  • July 28, 2025
  • 1 reply
  • 527 views

When I call the tx_event_flags_create() function, the code returns an error at the following line:

 else if (event_control_block_size != (sizeof(TX_EVENT_FLAGS_GROUP)))
 {

 /* Event flags group pointer is invalid, return appropriate error code. */
 status = TX_GROUP_ERROR;
 }

I'm not sure why this would be a problem since I only have one TX_EVENT_FLAGS_GROUP defined in my program as far as I can see and the size of the struct passed in should match. Is there anything I could possibly be missing here?

1 reply

mbarg.1
Senior III
July 29, 2025

Add the code where you declare global

TX_EVENT_FLAGS_GROUP event_control_block

 

add code where you compute 

event_control_block_size 

and code tx_event_flags_create() ... and i will show you where is the problem ! 

Or double check:

you need to have a global variable with the structure TX_EVENT_FLAGS_GROUP 

+ pass the address of this variable (not the variable) to tx_event_flags_create()

+ tx_event_flags_create() returns a success code, TX_SUCCESS if everithing is ok or an error code !

Associate III
July 29, 2025

So the event flag variable is declared here at the top of my app_usbx_device.c:

TX_EVENT_FLAGS_GROUP EventFlag;

 And then inside MX_USBX_Device_Init, the flag is created and throws the error:

if (tx_event_flags_create(&EventFlag, "Event Flag" != TX_SUCCESS) {
 return TX_GROUP_ERROR
}

The event_control_block_size is computed in the tx_api.h file here:

#define tx_event_flags_create(g,n) _txe_event_flags_create((g),(n),(sizeof(TX_EVENT_FLAGS_GROUP)))

 Both TX_EVENT_FLAGS_GROUP declarations seem to link to the same struct in tx_api.c hence why I was confused since the size should be the same here. Can you catch anything I might be overlooking?

mbarg.1
Senior III
July 29, 2025

But how do you compute your variable 

event_control_block_size 

??