What is volatile keyword in embedded C ? Explain with example? What is the difference between typedef and #define?

Questions by sruthikura

Showing Answers 1 - 6 of 6 Answers

Vikram

  • Nov 13th, 2006
 

The volatile keyword is used to define memory mapped I/O device's register (or Hardware registers) variables, which indicates to the compiler

For example:

int i;

&i=0x1234;

i = 0;

delay();

if(i){                      //Here the Compiler removes this code by optimization     

  some statements  // because 'i' is already assigned with 0 so..

}

if you declare 'i' as volatile then compiler doesn't optimize.

  Was this answer useful?  Yes

seshug22

  • Jun 9th, 2010
 

Volatile variable is a global variable and cannot be typecast. It can change its value at anypoint of time.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions