This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Volatile variables

What is the meaning of Volatile used in a variable declaration?

Thank's

Sergio

Parents
  • This is a 'C' question.
    Volatile tells the compiler/optimizer to not assume a variable will be the same from use to use. This stops the optimzer from loading a variable into a register and using the value there instead of re-reading the variable.

    It is used on any variable which may be changed in an ISR or a different thread/task in a multi-thread/task system.
    Best luck

Reply
  • This is a 'C' question.
    Volatile tells the compiler/optimizer to not assume a variable will be the same from use to use. This stops the optimzer from loading a variable into a register and using the value there instead of re-reading the variable.

    It is used on any variable which may be changed in an ISR or a different thread/task in a multi-thread/task system.
    Best luck

Children