Posted: Sun Aug 02, 2020 12:05 pm Post subject: SAFE attribute for variables
What does the SAFE attribute do?
BASCOM help explains the problem for which SAFE has been implemented, but it does not explain what SAFE does.
Is it just for the compiler to alert you when the same variable is used inside and outside of an ISR in cases when it could change its value unintentionally?
Does it solve the problem by actually preventing the unintentional change of the variable value in the cases explained?
Does it work only for "Incr" and for variables longer than 1 byte or also for other functions that can be affected by the same problem?
Posted: Sun Aug 02, 2020 12:46 pm Post subject: Re: SAFE attribute for variables
hzz wrote:
but it does not explain what SAFE does.
This statement is wrong, it's explained in the help further down the page, and it shows it is ISR-related only.
SAFE encapsulates variable access by a 'disable interrupts'[varaccess]'restore interrupts status' and assures that a variable's access, which consists out of a sequence of opcodes, is completely done by the accessing code.
'Accessing code' means usually main-code, as within ISR access to variables is limited to interrupt code by default.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum