Variables used for both normal processing and interrupt processing must be volatile qualified.
When a variable is qualified with the volatile qualifier, that variable is not to be optimized and optimization, such as assigning it to a register, is not performed. When operating a variable that has been volatile qualified, a code that reads its value from memory and writes its value to memory after operation must be used. A variable not volatile qualified is assigned to a register by optimization, and the code that loads that variable from memory may be deleted. When the same value is to be assigned to a variable that is not volatile qualified, the processing may be interpreted as redundant and the code deleted by optimization.