EmbeddedRelated.com
Forums
Memfault State of IoT Report

ARM lpc2388 RTC with external crystal

Started by faiz1303 6 years ago13 replieslatest reply 6 years ago132 views

Hi, 

I was observing the behavior of RTC from several days, first I run the clock by power supply for 72 hours and the time variation is negligible. When I run the RTC on 3 volt battery (VBat), I am getting a difference of 3 sec, of every (24 hours), RTC time is leading by 3 seconds. I want to fix this error of 3 sec, is their a best way for calibration. It is a precise delay of 3 sec for every 24 hour,  Please suggest.

thanks & regards

[ - ]
Reply by CustomSargeSeptember 12, 2018

Sorry, info missing.... Power supply volt setting? / Crystal using internal circuitry? / is power consumption an issue?

3 sec in 24 hours is .0035%, check your datasheet, that's likely to be a great number. Higher precision requires a temperature stabilized source, probably not your micro.

I'd be spec'ing temperature compensated oscillators, at as high a frequency as possible. Then divide it down with counters, the higher the divisor increases precision. Use that as an interrupt at the lowest periodicity your application requires.


[ - ]
Reply by mr_banditSeptember 12, 2018

What is the RTC and what is the crystal you are using? Is your circuit exactly as specified in the RTC datasheet?

Are you using a fresh battery? did you measure the battery voltage?

CustomSarge is spot on.

[ - ]
Reply by faiz1303September 12, 2018

Hi,

ARM LPC2388 has a inbuild RTC,I am using an external crystal of 32,768 Hz with capacitor of 10pf,  RTC is powered by a 3V battery which is new one. Today I check the RTC time and as usual it is leading by 3 second.

thanks and regards


[ - ]
Reply by mr_banditSeptember 12, 2018

Have you contacted ARM (and/or NXP) about this? Since the RTC is internal to the MPU, and it works correctly when the MPU is powered, it seems the crystal/cap are correct (and I am assuming you followed the datasheet on cap value, pad placement, etc).

Is this on an eval board, a protoboard, or did you cut your own PCB? If an eval board, I assume it is from NXP - I would call their tech support after checking the chip errata.

Have you checked all of the errata for the chip?

[ - ]
Reply by faiz1303September 12, 2018

Hello mr_bandit,

We have design our own custom board for voice logger and I have gone through the errata for LPC2388, only two issue related to VBat are mention, nothing separate about RTC, here is the link. Is it possible to gain the accurate tick by tuning the capacitance, I'll try some different capacitor across the crystal. 

https://www.nxp.com/docs/en/errata/ES_LPC2378_88.pdf

thanks and regards


[ - ]
Reply by mr_banditSeptember 12, 2018

I gently suggest a call to NXP might not hurt.

Can you measure the osc frequency without disturbing the reading? I assume this was one of the first things you tried, but it can be tricky to get it right - a Heisenberg case.

I looked at the errata you provided. They missed some interesting things.

[ - ]
Reply by faiz1303September 12, 2018

Thanks mr_bandit,

I tried to contact NXP, no response yet, I think instead of 32768Hz I am getting a 32766.86 I'll try to measure the oscillator frequency on scope and let you know.

Thanks & regards

[ - ]
Reply by mr_banditSeptember 12, 2018

Post deleted by author

[ - ]
Reply by mr_banditSeptember 12, 2018

There is a trick.

Call NXP, and ask for the *admin* of engineering. Tell the admin you are a nerd and have a serious nerd question about this specific chip and you have been unable to get tech support to reply. The admin will then give you to the next person in the chain - probably the admin in tech support. Rinse, repeat.

I have used this basic technique on big companies (DEC, medical device folks, etc). It has always worked && I have *always* found the person I needed within a max of 4 links.

The last time I used it I needed the part number for a specific connector on a medical device. Three links gave me the guy who was in charge of the BOM. There was a single source for the connector. I asked Mr Google, got the single source, the BOM guy said that's it. $30 later I had one in hand.

The reason it works is because the admins *want* to help, and they know where the bodies are buried. And they all talk to each other.

[ - ]
Reply by waltxSeptember 12, 2018

Check the crystal specification. There is a voltage sensitivity of a crystal's frequency to the voltage driving it.  You did not specify the power supply voltage but I will assume it is 3.3 volts. The back up battery is 3.0 volts or less. 


[ - ]
Reply by faiz1303September 12, 2018

HI Waltx

Main board is powered by 12V, controller is operating at 3.3V, back up battery is of 3V. I have a doubt, can we get exact 32768 tick from the crystal, or I have to manage it through the code. 

I try reset or shift the time 3 second, I think its not a good practice of programming,

            if(RTC_HOUR >= 23)
                  {
                     if(RTC_MIN >=59)
                        {
                          if(RTC_SEC == 59)
                                {
                                  RTC_SEC = 56; // condition that never false
                                }

                        }

                 }

please suggest

thanks & regards

[ - ]
Reply by mr_banditSeptember 12, 2018

This is really a hardware problem.

I would *really* not try to fix it in SW, unless you have no other choice.

[ - ]
Reply by faiz1303September 12, 2018

Thanks mr_bandit

But it seems difficult to resolve the problem through the hardware, only option is to feed a different capacitance combination across the crystal, I have read somewhere C1=12pf and C2=10pf at 3V gives a oscillation of 32768.23, I'll give a try to this and try to note the changes.

thanks and regards

Memfault State of IoT Report