Skip to content
Discussion options

You must be logged in to vote

Hi Guillermo,
I hope my answer clears up the concept. As you said, variables defined with the volatile qualifier are not loaded from a storage register, but from RAM memory. By default, if you don't declare it as volatile, the microprocessor accesses the value of the variable by storing it in a register because it is quicker in comparison to accessing it from RAM memory (a way of optimizing time). However, this can lead to problems when the variable is at the same time being updated outside of the main program flow. This occurs, for instance, when you apply an interrupt and your ISR modifies the value of a variable that is already being used in another function inside the program. In that…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by guilleruiz09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants