RTC problem in LPC1768

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

RTC problem in LPC1768

1,926 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mtgtech on Wed Feb 06 12:24:34 MST 2013
Hello, I'm having problems with RTC in LPC1768. The RTC is running, but is advancing approx 5 seconds per hour. The electrical circuit is good, with a 20ppm crystal tolerance, and 12,5pf capacitors of load. Tha VBAT is conected in CR1220 lithium battery. I have reviewed the source code and is OK. Below is my code:

void InitRTC(void) {
  LPC_RTC->CCR  =( !CLKEN |  CTCRST );
  LPC_RTC->CCR &= ~CTCRST;
  return;
}
/***************************/
void StartRTC(void){
  LPC_RTC->CCR |=( CLKEN );
  return;
}
/***************************/
int main (void){
  char temp[36];
  InitRTC();
  StartRTC();
  while(1){
    sprintf ((char *)temp,"%2.2d/%2.2d/%.2d   %2.2d:%2.2d",LPC_RTC->DOM,LPC_RTC->MONTH,LPC_RTC->YEAR,LPC_RTC->HOUR,LPC_RTC->MIN);
    lcd_gotoxy(1,0);
    lcd_print(temp);
  }
  return 0;
}


Does anyone know what might be happening?
Thanks
0 Kudos
7 Replies

1,140 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mtgtech on Thu Feb 21 12:35:21 MST 2013
Hi Dave, I update the load capacitor to 22pF. The CLKOUTCFG has been programed for output the RTC clock. I captured the values, please see in the video:http://www.youtube.com/watch?v=RKOOlhzHrec&feature=youtu.be

I noticed a fluctuation in frequency, which seems to be the cause of the problem. What can cause this fluctuation?

When the circuit is power off the RTC is running good, but when circuit is power on, the RTC is advancing.

Thanks!
0 Kudos

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Fri Feb 08 16:21:29 MST 2013
We have an FAQ on crystal load caps:
http://www.lpcware.com/content/faq/how-calculate-value-crystal-load-capacitors

But in this case it is not helping. It suggests that your load capacitance is too low but increasing it would decrease the oscillation frequency. (but the load caps should only have a slight impact on the oscillation frequency)

Can you check the frequency of the RTC oscillator? This cannot be done directly without using an active fet scope probe, but on the LPC1768 the CLKOUTCFG register can be programmed to output the RTC clock on the CLKOUT pin by writing 0b0100 to bits [3:0] and you could check it with a frequency counter or scope.

Your battery circuitry looks perfect, no diodes or anything, just as it should be. Also the battery you have chosen is Lithium Manganese Dioxide which has a nominal 3.0V output. This is good because when you power the LPC1768 from 3.3V it should be higher than the battery voltage so the battery shouldn't discharge. Sometimes people run into trouble when they use 3.4V lithium cells or a 3.0V power supply. None of this should cause the RTC to operate very slowly.

Can you tell me whether the RTC is slow when the power is off or only when the power is on?

Thanks!
-Dave @ NXP
0 Kudos

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mtgtech on Thu Feb 07 17:16:42 MST 2013
Hi Dave, the part# of crystal is: MC-306 32.7680K-A0:ROHS

See the schematic.
0 Kudos

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Thu Feb 07 14:51:10 MST 2013
This is an unusual problem, I haven't heard of anything quite like this. Can you post the part number of the crystal that you are using and the schematic of your battery circuit?

Thank you,
-Dave @ NXP
0 Kudos

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mtgtech on Thu Feb 07 13:13:22 MST 2013
The RTC is running correctly without the battery, with main power connected in VBAT. But yet the RTC is running advancing. I can't use the calibration of application note AN10849. I have 100 identical hardwares, and they are with different accurate. I think that this variation is very high for be simply a low accuracy of LPC. There must be some other problem.
0 Kudos

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Thu Feb 07 00:23:23 MST 2013
Actualy this is a known 'feature'.
The RTC clock is not very acurate on these MCU's
Fortunately there is a way to calibrate the RTC so take a look at
Application note AN10849
0 Kudos

1,141 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Wed Feb 06 13:05:26 MST 2013
First, check if the RTC is running corectly without a battery when the main power is present. If not - check your oscillator circuit.

If yes - put a diode in series with your battery, then change the battery to a new one. Probably your LPC1768 is draining the battery while the primary power is present - this is a problem with internal VBAT switch in LPC17xx.
0 Kudos