cancel
Showing results for 
Search instead for 
Did you mean: 

uint16_t VS __IO uint16_t

smhhadima
Associate II
Posted on August 12, 2015 at 14:20

what is the difference between ''uint16_t'' VS ''__IO uint16_t'' ? 

4 REPLIES 4
John F.
Senior
Posted on August 12, 2015 at 14:26

Typically in one or more header files you'll find something like,

#ifdef __cplusplus
#define __I volatile /*!< defines 'read only' permissions */
#else
#define __I volatile const /*!< defines 'read only' permissions */
#endif
#define __O volatile /*!< defines 'write only' permissions */
#define __IO volatile /*!< defines 'read / write' permissions */

Posted on August 12, 2015 at 14:43

volatile is important for peripheral registers, they don't act like memory, and operate independently of the processor, require strict sequencing and reading every time they are used.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Nesrine M_O
Lead II
Posted on August 12, 2015 at 15:08

Hi SamTheMan,

__IO = volatile is a variable that no compiler optimization is applied.

A variable should be declared volatile whenever its value could change unexpectedly. 

-Syrine-

smhhadima
Associate II
Posted on August 12, 2015 at 19:23

thank you