Add volatile to variables that are accessed in the ISR