RTC accuracy with MQX 4.1 on a K70

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

RTC accuracy with MQX 4.1 on a K70

Jump to solution
1,802 Views
arnogir
Senior Contributor II

Hello every body.

I'm using a K70 with MQX4.1

I use the rtc function (_set_time, _get_time) to set and get the current date/Hour.

But I made a test of accuracy with my Laptop and my mobile phone.

I synchronized both Laptop, Mobile phone and my K70board.

After 1 day, Laptop and mobile phone have not deviation, but the K70 board has took 20 seconds to advance!


It seems to me the K70 has register to set accuracy according Chrystal/Capacity value, but I don't found in MQX a way to set it.

Also, I don't understand how set the register (RTC_TCR?) according my problem and how know which value to configure.

In more, these value are saved when main power is down and RTC power kept?


Please inform me about the way to improve the RTC accuracy with MQX / K70

Thank:smileyhappy:


0 Kudos
Reply
1 Solution
1,114 Views
egoodii
Senior Contributor III

So that is a 12.5pf-calibrated-load-capacitance part, much like mine (though poorer initial tolerance at +/-20ppm).  So you might expect to use the same 20pf I have found (board parasitics assumed 'small'!!).  However, the 0.035ppm/C2 factor tells you that at an 'average' 0C (25 degrees below calibration temp) you would expect the crystal to be 22ppm 'slow' already.  So, you might want to drop the '4p' and just run the '16p' for 16pf on the pins, to try to compensate for that.  You will find some experimentation, and 'day long tests', will get you your best answer in your situation.  But just keep in mind that your initial tolerance, and the other 'fudge factors', will get you 'at best' about 3s/day (35ppm); a part with initial +/-10ppm tolerance 2s/day 'worst case'.  If one is TRULY trying to hit 'about 1s/day', IMHO the cleanest option is an external 'compensated oscillator' from SiTime: SIT1552AC-JE-DCC-32.768D.  Takes a little more battery, but insures +/-10ppm 0-70C (extended temp versions available -40+85C, holds +/-13ppm).

View solution in original post

0 Kudos
Reply
5 Replies
1,114 Views
egoodii
Senior Contributor III

Within MQX you are looking for the function '_rtc_init' in krtc.c, on a path similar to this:

C:\Projects\IforceV4\MCP\MQX_RTOS\mqx\source\io\rtc\krtc.c

My MQX code has this:

rtc->CR = RTC_CR_SC8P_MASK | RTC_CR_OSCE_MASK;

which is setting only the 8p capacitor.  If your hardware crystal is a 12.5pf part, I find that l need the SC4P and SC16P settings both enabled, and with that I get about 10ppm 'fast' at room temp 25C (1s/day), 10ppm 'slow' at 5 or 45C.  The crystal I use is ABS07-32.768KHZ-1-T, which has an initial accuracy +/-10ppm yet is small & inexpensive.

I don't use the TCR function (set to 0) as we use the 32.768KHz 'count' register to approximate millisecond-level timestamping in _rtc_get_time:

time->MILLISECONDS = (rtc->TPR*1000 + 16384)/32768;

//Round crystal counts to milliseconds

And in any case that only helps if you are going to (periodically) read temperature, and knowing the TCR curve of such tuning-fork crystals attempt to adjust.

And yes, all RTC control registers are held 'valid' by the RTC battery voltage.

BTW I recommend timeanddate.com for your synchronization reference.

1,114 Views
arnogir
Senior Contributor II

Hello

My MQX initialization has following:

/* Check if RTC counter or OSC for RTC is not started */ if( !(rtc->SR & RTC_SR_TCE_MASK) || !(rtc->CR & RTC_CR_OSCE_MASK) ) { rtc->CR |= RTC_CR_OSCE_MASK; /* recommended 125 ms delay for oscillator start */ _time_delay(125); rtc->SR |= RTC_SR_TCE_MASK; } /* End if */


then I will try to add some capacitor by configuring this register.

Thank


0 Kudos
Reply
1,114 Views
arnogir
Senior Contributor II

To be sure, I joined the Crystal characteristics.

which value do you recommend to me?


Typical environment will be around 0°C. 

How know register setting according  temperature?

0 Kudos
Reply
1,115 Views
egoodii
Senior Contributor III

So that is a 12.5pf-calibrated-load-capacitance part, much like mine (though poorer initial tolerance at +/-20ppm).  So you might expect to use the same 20pf I have found (board parasitics assumed 'small'!!).  However, the 0.035ppm/C2 factor tells you that at an 'average' 0C (25 degrees below calibration temp) you would expect the crystal to be 22ppm 'slow' already.  So, you might want to drop the '4p' and just run the '16p' for 16pf on the pins, to try to compensate for that.  You will find some experimentation, and 'day long tests', will get you your best answer in your situation.  But just keep in mind that your initial tolerance, and the other 'fudge factors', will get you 'at best' about 3s/day (35ppm); a part with initial +/-10ppm tolerance 2s/day 'worst case'.  If one is TRULY trying to hit 'about 1s/day', IMHO the cleanest option is an external 'compensated oscillator' from SiTime: SIT1552AC-JE-DCC-32.768D.  Takes a little more battery, but insures +/-10ppm 0-70C (extended temp versions available -40+85C, holds +/-13ppm).

0 Kudos
Reply
1,114 Views
arnogir
Senior Contributor II

Ok

Thank you for your back.

I will make some long test on many day, with different temperature to find the best mean value to apply.

:smileyhappy:

0 Kudos
Reply