Question: what is difference between static and volatile in c?
Answer: Static variables retain their value between function calls. Volatile variables (which is not the opposite of static) are used when a variable is used both within an ISR (interrupt service routine) and outside it. Volatile tells the compiler to always load a variable from RAM rather than caching it in a CPU register.