Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What data type is __IO int32_t?
What data type is __IO int32_t?

Check whether there are pre-defined definitions in the header file

#define __IO volatile /*!< defines 'read / write' permissions */

The role of volatile is arbitrary Every search found

volatile affects the results of compiler compilation. It is pointed out that volatile variables may change at any time. Operations related to volatile variables should not be compiled and optimized to avoid errors (VC++ is generating release Compilation and optimization will be performed when the executable code is released, and operations related to variables with the volatile keyword will not be compiled and optimized).

For example:

volatile int i=10;

int j = i;

...

int k = i;

volatile tells the compiler that i may change at any time. Every time it is used, it must be read from the address of i, so the executable code generated by the compiler will be re- Data is read from the address of i and placed in k.

The optimization method is that because the compiler finds that the code between the two reads of data from i

has not operated on i, it will automatically read the last The data is placed in k. Instead of reading from i again. In this way, if i is a register variable or represents a port data, it is prone to errors, so volatile can ensure stable access to special addresses without errors.