heinbali01 wrote on Saturday, October 10, 2015:
1 Can you please let me know is there any issue i can face in updating the flag this way?
You are accessing a memory location from both an interrupt as well as from a task. That is perfectly legal.
You already made the shared variable
volatile, which forces the compiler not to use caching but in stead to access the physical memory each time you read or write it:
volatile BaseType_t xCounter = 0;
/* No critical section is needed because nobody
will access xCounter while this ISR is active. */
void vMyTask( void *pvParameter )
for( ;; )
/* When reading the variable no
critical section is needed. */
if( xCounter > 0 )
* Need a critical section because:
* ld.w r9,r8[0x0] // load
* sub r9,1 // decrement
* st.w r8[0x0],r9 // store
2 Any other safe alternative of this? So that my task should not enter into wait/block state
As stated here above, you can read the common variable without a problem. When changing the variable (increment/decrement), make sure this is done in a critical section. If not you might miss changes that are made in the ISR.
Just curious, wouldn’t it be profitable to use some blocking mechanism? Why can’t you do that?