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
  • You probably showed the same care when writing your code, as you showed when posting it.

    Why did you chose to not read the instructions and use the "pre" tag around the code?

    Another thing - be careful about writing full values to registers.

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


    How many bits do you think you affect with this write? What about power to your UART? Didn't you notice in the user manual that PCONP on reset have a number of bits set? Did you really make an explicit decision about every of these bits before you decided to zero them with the above assign?

    Spend some more time working through your code. You even have access to a debugger - check that every line of your code does exactly what you think it does. Be a bit careful.

Reply
  • You probably showed the same care when writing your code, as you showed when posting it.

    Why did you chose to not read the instructions and use the "pre" tag around the code?

    Another thing - be careful about writing full values to registers.

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


    How many bits do you think you affect with this write? What about power to your UART? Didn't you notice in the user manual that PCONP on reset have a number of bits set? Did you really make an explicit decision about every of these bits before you decided to zero them with the above assign?

    Spend some more time working through your code. You even have access to a debugger - check that every line of your code does exactly what you think it does. Be a bit careful.

Children
More questions in this forum