4.4.3 How Do I Share Data Between Interrupt and Main-line Code?
Variables accessed from both interrupt and main-line code can easily
become corrupted or misread by the program. The volatile
qualifier tells
the compiler to avoid performing optimizations on such variables. This will fix some of the
issues associated with this problem.