Hi I am using this code in my program:
_inline void Local_Clear( U8 StackerID ) { U8 idata idx; idx = StackerID-3; _atomic_(0); TxSpiBuff[idx] &= 0x0fff; TxSpiBuff[idx] |= 0x3000; _endatomic_(); }
But after compiling, this error is shown: MainTask.c(804): error C185: atomic #8: out of range
I know what is happening, but I want a good solution. A solution to this problem is that I duplicate the function for each StackerID (the parameter) and eliminate it from the parameter list, so the idx will be a constant and the error is resolved. But I am seeking for a better solution.
Thanks all
Just an idea, but can the same effect be acheived using #pragma DISABLE directive ?
link:
http://www.keil.com/support/man/docs/c166/c166_disable.htm
I'm not sure the effect is the same but it may work
Dear christian, Thanks for your reply.
It sound helpful. But because I'm using multitasking, I'm not sure that using this pragma can help me. Because this pragma disables all the interrupts from raising. I don't know if it prevents also task switching. Do you know anything about this issue? I'm trying to study more about the Pragma.
Regrads
Hi Mehrdad,
I understand your concern that you may be disabling task switching, I'm not expert so I cannot tell you for sure.
However technical support seems to be OK with replacing atomic directive with disable directive so I assume they have considered the case of context switching, check the following link:
http://www.keil.com/support/docs/1344.htm
Best regards
The link that I posted in previous entry sugest to me that your code is broken down in more than 4 instructions by the compiler and that is why you are getting the error.
Best Regards
You should consult the technical support for whatever RTOS you're using about that.