Better start doing some basic things with something less complex. Static variables will be initiated outside the heap. The initial value will be applicable only once. So, the correct sequence for static variable will be like that:
static uint16_t var1;
var1 = 0xffff;
...
var1 = 0x1111;
If it doesn't work, that means you do something wrong because it just will work do you wan't that or not)))
The two code lines can be expected to work as written. But how do you check if the assignment is taking place?
Your post is far from a "detailed description".
Consider that instructions may be optimized away if they have no effect. E.g. if var1 isn't read after the second assignment, the assignment is removed by the compiler with respective optimization level in effect.
@Easyrider83 - it does not matter. You just add some unnecessary code for the initial assignment (I assume the global scope of the variable). In your example the variable will be placed into the .bss (and zeroed of course) segment and then assigned somewhere in the code. If you you initialize it in the declaration it will be placed in the .data segment and initialized by the startup code (usually by simply copy from the FLASH memory).
Adding static does not change anything, and if the variable was not optimized out it has to be changed by the assignment. Show us more code.
It depends. I read the code as local variable declaration inside a block. In this case, the initialization is just an assignment repeated each time the block is executed. The static attribute changes the behavior to single initialization during startup.
The difference however doesn't matter regarding the (up to now unclear) problem reported by Matt_Cuino.
It depends. I read the code as local variable declaration inside a block. In this case, the initialization is just an assignment repeated each time the block is executed. The static attribute changes the behavior to single initialization during startup.
The difference however doesn't matter regarding the (up to now unclear) problem reported by Matt_Cuino.