Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Optimize tickless tick computation #9786
Optimize the tick computation by computing the elapsed ticks based on relative time rather than absolute time. On the NUCLEO_L073RZ this reduces the execution time of SysTimer::resume from >35us to less than
Pull request type
referenced this pull request
Feb 21, 2019
kjbracey-arm left a comment
This saves a fair bit on the M0, where it converts a 64-bit software division to a 32-bit software division, but on M3 and M4 it should save a lot more - it should be optimised into a "multiply by reciprocal" using UMULL. (I know GCC and ARMC5 do this, hopefully IAR and ARMC6 do too).
This is slightly at odds with something I'm looking to do with SysTimer - that was actually going to make it more 64-bit, to help support a manual suspend API, where I was anticipating long sleep times. But I think I could deal with that by having conditional behaviour - switch between optimised 32-bit and heavy 64-bit computations depending on whether deep sleep is locked. If deep sleep is permitted, we have a free reign on interrupt latency.
I updated this PR to preserver the long sleep times without having an impact on interrupt latency. Bringing back 64 bit division brought execution time of SysTimer::resume up to to a bit under 20us. I also added a separate commit to remove the critical section in places where it wasn't needed, such as SysTimer::resume.