Post Reply 
A small contribution and a big question (timer/keyboard)
12-02-2019, 06:37 AM
Post: #4
RE: A small contribution and a big question (timer/keyboard)
Hello,

I first was going to write: It would be interesting to have other test your code and see by how much their calculators vary...

But then, I had a thought!
2.3%... This looks close to 2.4 to me... or to be exact to 102.4-100 See where I am going with this????

So, I looked in the source code to remember better and I realized that I confused G1 and G2 here...

In G2, the RTC is based on a 32768Hz counter, from which the time/date is derived, but also the internal "tick"... both for OS switch and for the Ticks function...

The ticks is "created" by just dividing said counter by 32 (5 bits), so it actually counts at a rate of 1024 per second! so, the 2.3% deviation is nothing more than
(1-1000/1024)*100 and is perfectly normal with a counter in 1024th of a second!

extern "C" TMillisecs PrimeGetNow() // now in 1khz clock time
{
TMillisecs t1= (SNVS->HPRTCMR<<27) + (SNVS->HPRTCLR>>5); // read the clock value divided by 32...
while (true) // need to do 2 consecutive readings to make sure that the clock did not change between the reading of the 2 registers...
{
TMillisecs t2= (SNVS->HPRTCMR<<27)+(SNVS->HPRTCLR>>5);
if (t1==t2) return t1; // if the 2 readings are identical, then we are ok
t1= t2; // else do another reading!
}
}

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: A small contribution and a big question (timer/keyboard) - cyrille de brébisson - 12-02-2019 06:37 AM



User(s) browsing this thread: 1 Guest(s)