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 Reply Children
No data