Answers

Question and Answer:

  Home  Personal

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

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.

 271 views

More Questions for you: