STM32 notes pen questions

Possible, such as read only status register. It is volatile because it may change unexpectedly. It is const because the program should not attempt to modify it.

Defined as a variable volatile is that this variable may be changed unexpectedly, so the compiler would not have to assume that the value of this variable. Precisely that, every time the optimizer must be carefully re-read the value of this variable when this variable is used, instead of using a backup stored in the register of

The volatile modifier tells complier variable values can be changed in any way not explicitly specified procedures, the most common example is the value of the external ports, it can not change any assignment in the program it is likely to change, such variables can be modified by volatile, complier it will not be optimized away.
const modified variables in the program which can not be changed, but can be modified something outside of the program, the external value of the port as said above, if only use const, there may complier will optimize away these variables, plus the volatile foolproof a.

Guess you like

Origin www.cnblogs.com/risesource/p/12057119.html