znatok wrote on Saturday, December 01, 2012:
Hi,
What is the best way to block task waiting for bit change. In my specific case I want to wait for RX_DONE flag from UART. So actually I want to block while( !(RS_STATUS & RX_DONE) ).
1. I understand that I can write an Interrupt handler and use a semaphore to block/unblock task
2. I can make polling
But I would prefer the scheduler to poll for RS_DONE bit without context switch. (This is what I’ve done in my own OS used on 8-bit AVRs). Now I’m starting to work with STM32 ARM Core. I’ve read FreeRTOS documentation and did not find a way to block task waiting for bit set/cleared or value zero/non zero. Not sure it is possible at all in Free RTOS but I think such feature can be very efficient for non time critical events like UART for example (when processing can be relatively slow considering huge difference between baud rate and FreeRTOS tick).
3. Last option that come to my mind is to implement semaphore for blocking and poll for bits in Idle Task giving a semaphore to unblock waiting tasks. This will prevent context switch to blocked task for polling and considering the fact that IdleTask is running anyway there would be no extra context switches at all.
What do you think?