Skip to main content
smhhadima
Associate III
August 12, 2015
Question

uint16_t VS __IO uint16_t

  • August 12, 2015
  • 4 replies
  • 1492 views
Posted on August 12, 2015 at 14:20

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

    This topic has been closed for replies.

    4 replies

    John F.
    Associate III
    August 12, 2015
    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 */

    Tesla DeLorean
    Guru
    August 12, 2015
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    Nesrine M_O
    Associate
    August 12, 2015
    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
    smhhadimaAuthor
    Associate III
    August 12, 2015
    Posted on August 12, 2015 at 19:23

    thank you