I was just reading an answer about global variables, it also stated that I should use volatile affix whenever a global is used in an interrupt.
In my program I am using a 30 byte ADC buffer without interrupt, it just gets regularly updated with DMA transfers.
There is also a 4 byte USB buffer which gets updated whenever I receive an USB interrupt.
There is a variable that gets changed every time main while loop starts over, it reads one of the adc values and updates itself with a proper math function, and then gets used in another function frequently to generate something else.
There is a counter which I increment in every while loop start over, it is used widely in my code ecosystem. Has nothing to do with interrupts or external sources, just gets incremented whenever code finishes a full cycle.
In which of these four situations I should use volatile and would it lead to any memory based side effects in my system?
I wasn't using volatile fix since now and not sure if I ever faced a problem related to this.
I am using cortex M-4, pure C code.