This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F47187: Reading and Modifying RTC Registers without corruption for compensation

Hi,

 

I’m trying to compensate RTC accuracy over temperature and crystal error. To be able to do this, I may need to modify RTC content every minute with functions like Inc_RTC_A_Second() or Dec_RTC_A_Second().

 

But these functions seem not easy to implement. Because RTC counter is asynchronous to the CPU clock, any attempt to write to RTC registers can cause losing up to one second. There should be a safer way to do this. What is your recommendation to read and modify RTC content without losing any second.

 

Thank you.

  • Altering the time usually isn't a good idea as it causes  distortions in the timeline. It is better to adjust the clock speed using the calibration/adjustment registers. It won't correct larger gaps immediately, but will make the clock going slower or faster depending on the difference to the reference time. So in the average it swings to the desired value.

    If you let the distance between RTC time and reference time grow so large that it requires a large adjustment, then the check interval is too large.

    On my ATMega based Access point, I use an external PCF8583 RTC which is manually trimmed to  <1s/day. Reading the clock each time I need a time value would bring hthe system to a halt. So I fetch the time at startup and every minut, bubt in between I use a timer to increment the localk time value. Each minute I compare the current tome from the RTC with the local time and if they differ, I slightly adjust the timer divider (speeding it up or slowing it down by 0.1%) In the average, the two clocks run perfectly synchroneous.

    A similar machanism can be used by you for adjusting the RTC to the current temperature. What you need is  a base calibration value and a relative drift value caused by temperature. Then you can at every time put a new, adjusted value to the calibration register RTCCTL2. No need to write to the counters.

  • Hi,

     

    I think MSP430F46187 that we use doesn't have such as calibration registers for built-in RTC. Then, what can we do more?

     

    10x.

  • Your naming RTC_A_... confused my. The RTC_A does have calibraiton registers. The 4xx family RTC doesn't.

    What you can do is to manipulate the basic timer clock generation which is used for the RTC.

    You can remove some RTC ticks some clock cycles by stopping the basic timer (e.g. for the time between two TiemrA interrupts) and speed it up by applying a different clock source or speedign up its clock source, e.g. switching from ACLK/256 to ACLK for a short time.

    It's a bit complicated but maybe the best solution for this RTC type.

**Attention** This is a public forum