cancel
Showing results for 
Search instead for 
Did you mean: 

osEventFlagsSet/Get not working in ISR? What am I doing wrong?

abeowitz
Associate

STM32F407VET6 + STM32CubeIDE + CMSIS_OS2

Latest IDE, w/ FreeRTOS 10.2.1, CMSIS-RTOS 2.00

Touch LCD IRQ on PC_5.

EXTI line[9:5] enabled, code gen enabled, and Call HAL Handler checked.

Event defined. Fails with both dynamic and static Allocation.

Include Param: xEventGroupSetBitFromISR enabled (doesn't work disabled either)

I want to set a flag when the touch interrupt is triggered, then resume a handler thread waiting with osEventFlagsWait().

Anyway, IRQ call succeeds.

but (see comments) 

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
 
if (GPIO_Pin == Touch_INT_Pin)
   {
     uint32_t flags = 0x00;
     extern osEventFlagsId_t touchEventHandle;
 
     flags = osEventFlagsSet(touchEventHandle, 0x01);
     // ^ returns 0x01, as expected.
 
     flags = osEventFlagsGet(touchEventHandle);
     // ^ returns 0x00, but should be 0x01
 
   }
 
. . .
 
 }

debug tracing shows touchEventHandle points to the same heap location as FreeRTOS set up.

Those Set/Get routines work fine within a thread.

I've traced through debug, but am unable to discern why it's not working as I expect. The Set routine dives deep into queue related code, so do Event bits use queues? The Get routine seems simpler and doesn't.

Thanks,

-Abe

9 REPLIES 9
kronikary
Associate III

Did you manage to solve the problem? I have the same issue with STM32l4 CMSIS v2. Setting flags works outside the interrupts.

EDIT: I guess the workaround of this problem is to use osThreadFlag (which works in ISR) that will start a thread, and in this thread you can set EventFlags.

HPope.1
Associate II

I'm having the same issue, if either of y'all figured it out, I would love an update.

kronikary thanks for your EDIT, I'll try it out as a work-around, but would love to be able to set flags.

bba.1
Associate

Bumping this thread.

I have the same problem, even though the NVIC priorities are configured seemingly properly.

If there are two tasks: A and B.

A's priority is higher than B's.

A is waiting for the eventflags and B is running. The bits in the event flag are set in an IRQ, but the xHigherPriorityTaskWoken flag is false, even though task A is blocked because of this.

If I put an osDelay() into task B, then everything works correctly, but it doesn't make sense as B's priority is already lower and preemption is enabled. 

Vikx
Associate

Hello there !

Same problem here the osEventFlagSet do not work calling from an ISR, but it worked with osThreadFlagSet.

Any advice on this ? 

the documentation say that it is possible to use it inside an ISR.

Tizio1234
Associate II

Hi there!
Same problem as everyone:grinning_face_with_sweat:

mcfly7385
Associate

For me, the osEventFlagsSet was failing because the timer queue was full.

Within the IOC file's freertos config parmameters, I made the TIMER_QUEUE_LENGTH larger and it fixed the problem.

Leo4
Associate

I have the same problem. I read a post on the ARM community forum with the same problem and no solution was given. It seems CMSIS OS events do not work as expected. I will use osThreadFlags, but ST developers shall report this bug so we do not waste hours of time on a not-working library.

 

Leo

rfischer
Associate

This thread helped me and solved my problem that EventFlags sometimes have not been set.

Cheers,

Robert

Why "xEventGroupSetBitsFromISR" sometimes can not set Event? - Kernel - FreeRTOS Community Forums