Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

what is the meaning of key word volatile and where it is use

Status
Not open for further replies.

rameshbabu

Member level 2
Joined
Aug 1, 2007
Messages
46
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,663
c

what is the meaning of key word volatile and where it is used ?
 

c

volatile tells the compiler that other processes will modify this variable, so do not optimize it.

For example, lets say the main routine continually tests a variable in a loop waiting for an interrupt routine to change it. If the variable is not labeled volatile, the compiler will optimize out the testing loop as it believes it can predict that the loop will never be true.
 

c

It is used when the variable can be changed outside of the program or function you are in, such as an I/O port or a global variable changed by an interrupt routine.
It forces the compiler to read the variable before using it to stop it optimising it away.
 

c

volatile variable can be modiied.

For example, lets say the main routine continually tests a variable in a loop waiting for an interrupt routine to change it. If the variable is not labeled volatile, the compiler will optimize out the testing loop as it believes it can predict that the loop will never be true.
 

Re: c

Volatile mean tell the compiler not to optimized that variable.. This because when we use the variable in the fuction it is always store that variable in the register for accessing speed but when the data must change follow the input all the time. Such as the I/O Map architecture it is recommand that you declare the variable using volatile keyword.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top