casainho said:Must say that I just use local/static local or global variables. I don't know why the need of volatile, need to read about that.daffy99 said:FWIW, and that's just a remark, because I don't know anything, I do notice a very pronounced absence of the C keyword "volatile" in the firmware C source code (git repo search). I keep reading about interrupts and global variables all the time, though, which we would indicate that volatile would rather be expected ...
And the optimizations, I have them turned off on the makefile options inside. I need no optimizations to be able to better debug the code.
daffy99 has a good point. A non-volatile variable can be optimized to be the whole time in a register; if, let's say, that's in the main loop and you also use that same variable in an interrupt, changes in the main won't be seen in the interrupt. Like you updating a speed value in the main loop and it (not) being seen in an interrupt. The volatile keyword will force the variable's memory to always be updated (at an execution speed penalty cost, since it's slower than updating a CPU register only).