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

How Can i READ RTC Registers, As I am trying read RTC_HOUR

Hi ,

I am using the following code with LPC2378 as Target, As on debugging this code , I should be able to read RTC_HOUR,RTC_MIN register. But as it reaches printf (bold) code lines. I am not able to do so. I am first time using RTC. Please Suggest how to read RTC and throw its value on UART.

As per my observation , there should be something which should be able to bring print control to UART 1 again after RTC initialization. And some variable which save the RTC register at a particular time instance. And Its an RTC, it should continuously show the time increment.

Please Suggest.

===============================================================================================
Code for RTC implementation
===============================================================================================

#include <LPC23xx.H>
#include <stdio.h>

void Init_UART(void);
void Init_RTC(void);

int main (void)
{ /* -------------Main----------------------------*/
Init_UART(); /* ----- Initializing UART-------------*/
Init_RTC(); /* ----- Initializing RTC-------------*/

printf("\n Real Time Clock ");
printf("\n HOUR :%d",RTC_HOUR); printf("\n MIN :%d",RTC_MIN);

while(1) { /*-------------Infinite Loop-------*/ }

}

void Init_UART() {

/* UART 2 Enable */ PINSEL0 |= 0x40000000; /* Enable TxD1 in P0.15 */

PINSEL1 |= 0x00000001; /* Enable RxD1 in P0.16 */

U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */

U1DLL = 78; /* 9600 Baud Rate @ 12.0 MHZ PCLK */

U1LCR = 0x03; /* DLAB = 0 */

printf("\n ***** UART Initialized ***** \n"); }

void Init_RTC(void) {

/*RTC Clock Intialization*/

PCONP = 0X00000200; /* RTC power enabled*/

RTC_PREINT = 0X0000016E; /* for Xtal @12MHZ */

RTC_PREFRAC = 0X0000001E;

RTC_CCR = 0X00000011;

RTC_ILR =0X1; /*clears the counter increment interrupt*/

RTC_HOUR=12;

RTC_MIN=45;

RTC_SEC=59;

RTC_DOM=21;

RTC_MONTH=12;

RTC_YEAR=2011;

printf("\n HOUR :%d",RTC_HOUR); printf("\n MIN :%d",RTC_MIN);
}

Best Regards,

Vinay. Kumar

Parents
  • Hi Per Westermark,

    Now I am able to get output on UART1

    As Output is like this. To make this I created one if else and(++) based conditions.

    If I am not USING this if else then RTC stops after displaying printf output.

    Not able to see the Counter happening which is happening in RTC without printf.

    I want to set RTC COUNTER and Output on every counter increment in sec,min,hour and Day,month and year.

    Just give me idea, I will try to implement it my own.

    ***** UART Initialized *****

    Digital Date and Time Clock DAY::MONTH::YEAR 21 / 12 / 2011

    ------------------------------------------

    ****** HOUR::MIN::SEC********** 12::46::0 ****** HOUR::MIN::SEC********** 12::46::1 ****** HOUR::MIN::SEC********** 12::46::2 ****** HOUR::MIN::SEC********** 12::46::3 ****** HOUR::MIN::SEC********** 12::46::4 ****** HOUR::MIN::SEC********** 12::46::5 ****** HOUR::MIN::SEC********** 12::46::6 ****** HOUR::MIN::SEC********** 12::46::7 ****** HOUR::MIN::SEC********** 12::46::8 ****** HOUR::MIN::SEC********** 12::46::9 ****** HOUR::MIN::SEC********** 12::46::10 ****** HOUR::MIN::SEC********** 12::46::11
    ---------------------------------------------

    Best Regards

    Vinay. Kumar

Reply
  • Hi Per Westermark,

    Now I am able to get output on UART1

    As Output is like this. To make this I created one if else and(++) based conditions.

    If I am not USING this if else then RTC stops after displaying printf output.

    Not able to see the Counter happening which is happening in RTC without printf.

    I want to set RTC COUNTER and Output on every counter increment in sec,min,hour and Day,month and year.

    Just give me idea, I will try to implement it my own.

    ***** UART Initialized *****

    Digital Date and Time Clock DAY::MONTH::YEAR 21 / 12 / 2011

    ------------------------------------------

    ****** HOUR::MIN::SEC********** 12::46::0 ****** HOUR::MIN::SEC********** 12::46::1 ****** HOUR::MIN::SEC********** 12::46::2 ****** HOUR::MIN::SEC********** 12::46::3 ****** HOUR::MIN::SEC********** 12::46::4 ****** HOUR::MIN::SEC********** 12::46::5 ****** HOUR::MIN::SEC********** 12::46::6 ****** HOUR::MIN::SEC********** 12::46::7 ****** HOUR::MIN::SEC********** 12::46::8 ****** HOUR::MIN::SEC********** 12::46::9 ****** HOUR::MIN::SEC********** 12::46::10 ****** HOUR::MIN::SEC********** 12::46::11
    ---------------------------------------------

    Best Regards

    Vinay. Kumar

Children
No data