This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A simple problem with atomic instructions

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

Parents
  • 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

Reply
  • 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

Children