2021-06-23 07:38 AM
Hello,
I set up a thread that waits for particular set of flags (see code below) without any timeout. When flags are noticed - code is executed, but flags are not cleared (due to "osFlagsNoClear" option). One flag comes from another Thread, which sets 0x01 each 3 seconds, while HW interrupt sets 0x50 flags.
For my understanding 0x01 should be kept set from the very first accurrence of the other thread, and receiver thread should wait until interrupt sets 0x50, and after that - receiver should be kept in RUNNING state by scheduler (just like it happens when IRQ pending bit is not reset). There is no thread of higher priority (in fact there are only two threads - both on Normal priority). Receiver thread do not use any HAL_Delay() nor os_Delay().
The point is that Receiver thread is switched between BLOCKED and READY/RUNNING at the pace of the other thread - each 3 seconds same action from Receiver thread occurs. Just like osThreadFlagWait() looks rather for a flag transition from RESET to SET, instead of its SET state.
Are Thread Flags handled with similar logic?
Will be grateful for any explanation!
Piotr
/* USER CODE END Header_StartReceiver */
void StartReceiver(void *argument)
{
/* USER CODE BEGIN StartReceiver */
/* Infinite loop */
for(;;)
{
osThreadFlagsWait(0x51, osFlagsWaitAll | osFlagsNoClear, osWaitForever);
SWO_PrintChar('1'); // ITM_SendChar(); with additional new line character
}
/* USER CODE END StartReceiver */
}
2021-07-07 06:44 AM
Hello @Community member ,
Sorry, but I didn't understand well your question. Could you provide more details ?
Thanks in advance.
BeST Regards,
Walid