Hi,
I have just found a widespread discreptancy with t1s_4 being 49910.
This is where I think this has started:
The internal timer part of the settimer command reference manual pages say:
"Finally 65536 - 15625 = 49910, so our preload value become 49910."
All I could say about this calculation is that either 65536 should be 65535, or 49910 should be 49911.
Should it be 65536?
- If the preload value is 65535, then every time a minor tick occurs, the minor register overflows to 0, the timer wordvariable gets incremented (major tick), and the minor register gets preloaded with 65535 again. Thus, there is 1 minor tick per major tick, so 65536 - 65535 = 1.
- I calculated 34286 and 3036 using 65536, and I get the result of the major tick period being correct for their purpose for both of them.
So yes: where it is 49910, should be 49911.
However, I see 49910 everywhere, and I even simulated
w0=t1s_4
And I get the value 49910, not 49911, in w0 in the variables panel.
This means, the timer is running 0.2304s slower per hour. For anyone who uses settimer, try replacing "t1s_4" with "49911" and see if you get better results.
I calculated 49910 using 65536, and I got the major tick period being 1.000064sec.
I thought I post the same here, so that it's direct reference in the programming editor forum, as well as in the thread "external 4MHz crystal inaccurate timing" in the active forum section, where it might be a solution to. edit: didn't see that Janne was using 34286 rather than 49910.
I have just found a widespread discreptancy with t1s_4 being 49910.
This is where I think this has started:
The internal timer part of the settimer command reference manual pages say:
"Finally 65536 - 15625 = 49910, so our preload value become 49910."
All I could say about this calculation is that either 65536 should be 65535, or 49910 should be 49911.
Should it be 65536?
- If the preload value is 65535, then every time a minor tick occurs, the minor register overflows to 0, the timer wordvariable gets incremented (major tick), and the minor register gets preloaded with 65535 again. Thus, there is 1 minor tick per major tick, so 65536 - 65535 = 1.
- I calculated 34286 and 3036 using 65536, and I get the result of the major tick period being correct for their purpose for both of them.
So yes: where it is 49910, should be 49911.
However, I see 49910 everywhere, and I even simulated
w0=t1s_4
And I get the value 49910, not 49911, in w0 in the variables panel.
This means, the timer is running 0.2304s slower per hour. For anyone who uses settimer, try replacing "t1s_4" with "49911" and see if you get better results.
I calculated 49910 using 65536, and I got the major tick period being 1.000064sec.
I thought I post the same here, so that it's direct reference in the programming editor forum, as well as in the thread "external 4MHz crystal inaccurate timing" in the active forum section, where it might be a solution to. edit: didn't see that Janne was using 34286 rather than 49910.
Last edited: