Is anyone using std::chrono with a K28F?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is anyone using std::chrono with a K28F?

762 Views
edw8
Contributor III

I'm having a hard time getting anything better than a 1 second resolution on a sample c++ project exercising a timer class based on std::chrono::system_clock. This is on a C++ project based on SDK 2.2 using MCUXpresso IDE 10.0.2

0 Kudos
1 Reply

560 Views
egoodii
Senior Contributor III

I can't be any help with the C++ class functions, but I can say that the 'fundamental RTC time register' in Kinetis is 'seconds'.  Now, that being said, as long as your setup isn't using the Time Compensation functions of the hardware, then the RTC system will be running 32768 counts per each said second via the Time Prescale Register, and you can read that and divide by 32.768 (for instance) to get milliseconds, or multiply by 30.517578125 (15625/512) to get microseconds.

Note that the RTC hardware is built of 'slow ripple counter' blocks, and it is necessary to 'read twice and compare' to insure a valid read.  See also:

RTC and Sub second Time 

0 Kudos