We are working on MC9S08QD4 with Code Warrior v6.3. When we assign 0 to a variable it is not getting assigned to 0 and it works with the previous value sometimes. Please share your feedback.
解決済! 解決策の投稿を見る。
Hi,
I wonder the problem is because of the optimization.
I suggest you cast the variable as "volatile" then try again. for example.
volatile int myval;
Have a great day,
Jun Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Could you share a reproducible example?
for example, if you have something like:
int i;
i = 10;
i = 0;
i = 20;
then the compiler will be able to optimize this.
Hi,
I wonder the problem is because of the optimization.
I suggest you cast the variable as "volatile" then try again. for example.
volatile int myval;
Have a great day,
Jun Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------