FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2015 Threads]
Hi,
I have to implement one comparator intrrupt in Stm32F3 for protection of my circuit. When Ever interrupt comes i need to set one flag and need to check into task which i can not out into wait state/ bloack state for waiting the flag is set.
I am using FreeRTOS 7.6 in my project. I am right now using One global flag variable of volatile type and updating it.
1. Can you please let me know is there any issue i can face in updating the flag this way?
2. Any other safe alternative of this? So that my task should not enter into wait/block state .
Mukesh
Sorry - I don't understand your requirements, can you try re-phrasing "When Ever interrupt comes i need to set one flag and need to check into task which i can not out into wait state/ bloack state for waiting the flag is set."
sorry for typo. I mean one flag should be set into by Comparator interrupt. And based on this flag want to take decission in one task. This task i can not put into block/wait state.
Hello Muku,
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;
void ISR()
{
/* No critical section is needed because nobody
will access xCounter while this ISR is active. */
xCounter++;
}
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
*/
taskENTERCRITICAL();
xCounter--;
taskEXITCRITICAL();
}
}
}
~~~~~
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?
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.