The STM32 example code will have a code like this static __io uint32_t timingdelay; Here side of the __io modifier is not good understanding, single from the literal can be seen for IO correlation, check its standard library can know this __io originally was redefined in core_cm3.h, in fact, is volatile, the sentence is as follows
/* IO Definitions (access restrictions to peripheral registers) */#ifdef __cplusplus #define __i &NBSP ; Volatile /*!< defines ' Read Only ' permissions &NB Sp * #else #define __i volatile const /*!< defines ' r EAD only ' permissions * * #endif # define __o &NB Sp Volatile /*!< defines ' write only ' permissions &N Bsp */#define __io volatile /*!< D Efines ' read/write ' permissions */ It's easy to see that these modifiers are used to instruct the compiler how to change the The volume of the operation. The role of volatile is to instruct the compiler not to omit this instruction for optimization, and must read and write its values directly each time. Write a test code as follows U8 test; test = 1; Test = 2; test = 3; Set optimization levelDo not run after intermediate test will be directly evaluated to 3 only the last statement is compiled with volatile volatile U8 test; test = 1; Test = 2; test = 3; The sentence will be compiled. Test has been set to 1, 2, 3 it can be seen that this role in IO operations, register operations, special variables, multi-threaded variable read and write are very important.
About the __io modifier in the STM32 library (volatile modifier, capricious meaning)