I'm currently auditing an online edX course about embedded systems, and learning about using the SysTick timer to calculate elapsed time.
Picture of logic I'm referring to
Code of logic I'm referring to
However, there is one point that is confusing me. I understand the idea of subtracting "now" from "last" to get the elapsed time. However, what do you do when the "now" rolls over when the SysTick timer hits 0 and gets reloaded, but the "last" is the value from BEFORE the SysTick timer rolled over (so "now" is > than "last", when normally it should be smaller)? The value is being stored in an unsigned long, so does it break the program? Or does this just never happen, and if so why? I would appreciate any help on clearing this up!
I looked at the only other link I could find that was similar to my question here: How to deal with a wrapping counter in embedded C but I didn't find a clear answer to my question from that.