lpcware

RTC problem in LPC1768

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
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

Outcomes