I couldn’t find any information on this topic, so please point me to it if I missed it.
The basic question is whether a software timer will ever interfere with code in the main loop. In other words, let’s say I have some global variables that are updated by code in a software timer, and periodically I also update those same global variables in the main loop. Will these two blocks of code ever step on each other? And further, will the entire software timer function complete (or for that matter, will the entire main loop complete) “atomically”? I’m used to using mutexes or semaphores to coordinate “safe” access to global variables, but is that necessary with software timers?
UPDATE: After a little more digging, I came across the ATOMIC_BLOCK() function. I’m running in ‘threaded’ mode, so I add this around the two places that update the global variables. It works (although it did work before). Any thoughts on this approach?