Blog121.5K views1,843 votes0 replies651 following
Using volatile in Embedded C: Stop the Compiler from Caching Your Hardware Flags
The volatile keyword prevents compiler optimizations that break interrupt flags and memory-mapped I/O, but it does not guarantee atomic access.