This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTC is creating problem in ARM LPC2378

Hi All,

Any one help me in doing this. I need to continously print the current date and time in DD/MM/YY and HH:MM:SS format. Iam using ARM LPC2378. I am not sure whether my RTC code is correct. Please confirm or suggest if there is something else I need to do. My code which is creating the problem goes as follows:

void RTCInit(void)
{
    PCONP    |= 0x0200;                   /* RTC Power Enabled */
    RTC_CCR   = 0x11;                 /* RTC Osci.Clock Enabled */
    RTC_ILR  |= 0x01;                /* RTC Interrupt Enabled */
    RTC_AMR  |= 0xFF;                /* Alarm Mask Register Disabled */
    RTC_CIIR  = 0x01;                    /* Every Second Interrupt Enabled */
    RTC_CISS  = 0x87;                /* Sub Second Interrupt Disabled */

    return;
}

void RTCSetDateTime(RTCDateTime DateTime)
{

    RTC_SEC = DateTime.RTCSec;
    RTC_MIN = DateTime.RTCMin;
    RTC_HOUR = DateTime.RTCHour;
    RTC_DOM = DateTime.RTCMday;
    RTC_MONTH = DateTime.RTCMon;
    RTC_YEAR = DateTime.RTCYear;

    return;
}


RTCDateTime RTCGetDateTime(void)
{

    RTCDateTime LocalDateTime;

    /* Store RTC date and time in st_LocalDateTime structure */
    LocalDateTime.RTCSec = RTC_SEC;
    LocalDateTime.RTCMin = RTC_MIN;
    LocalDateTime.RTCHour = RTC_HOUR;
    LocalDateTime.RTCMday = RTC_DOM;
    LocalDateTime.RTCMon = RTC_MONTH;
    LocalDateTime.RTCYear = RTC_YEAR;

    return (LocalDateTime);
}



In some other part of the code I am updating the structure variables to set the time initially. And when I do this I call RTCSetDateTime(initiallocaltime); as follows


{
 ...
 ...


/* Reset the counter which is resposible for Sec Timer increment in RTC */
RTC_CCR |= 0x03; /* CTC Reset in CCR */
RTC_ILR |= 0x05; /* RTC Sec Timer Counter Reset*/

/* Updation of RTC with Date & Time initially*/
RTCSetDateTime(initiallocaltime);

RTC_CCR  = RTC_OSC_SELECT;

...
...

}


and finally Iam printing the time. Date and time is printed correctly for some time and later the it jumps above or below (some times in seconds/minutes and mostly in hours) and starts running from there.

Please let me know how can I avoid this problems with RTC and print the correct date and time continously eoth out any disturbances.

Thanks and Regards,
Sravan Kumar M.

0