declare timer0_fract non static and volatile to make it available for linking#5676
declare timer0_fract non static and volatile to make it available for linking#5676kfessel wants to merge 1 commit into
Conversation
… linking using timer0_fract and Timer0s count register it's possible to write more precise millis function that include all milliseconds or return some extra accuracy (eg 1/4 on 1/8 millisecond) with less overhead than micros.
|
Commit looks good to me. It's not part of the official API, but it makes sense to at least allow access if people need it. Also, the other variables are not static, so this makes them more consistent. @fesselk, did you compare the generated .hex files before and after this change to see if the change influences the generated code? I would expect not, but perhaps this removes some optimization opportunities, so it would be good to check. However, I wonder if your suggested @fesselk, any idea how much slower your implementation is compared to the original? |
|
I did a test before i did the commit and pull request and it showed no difference for the volatile vs the static. There was no optimizations that was possible due to it being static. ( the target platforms for my tests are the mega2560 (megaADK) and mega328 (uno) ) I just did a retest and had a look at the elf s and Assembler they are identical. The millisx function that i suggested in my first comment is only for 16MHz (which both my testboard are) may be that is a problem for a replacing millis. millis is 0x18 in size (24 byte ~ 12 cycles) since both have no loops the size roughly point to their execution time (AVR does about 2 bytes per cycle) |
|
surely a better way would be..... and then inside the millis ( millisx) use this instead then it works on diffent clock speeds, no longer being hard coded to the 16MHz values. |
|
@darrylp1per, it seems there's two different problems being solved here? The original solved the problem where the Also, you should use triple backticks ( |
|
Closing here, if someone wants to adopt this PR please use this link to reopen it in the right repo, thanks. |
using timer0_fract and Timer0s count register it's possible to write more
precise millis function that include all milliseconds or return some extra
accuracy (eg 1/4 on 1/8 millisecond) with less overhead than micros.