LPC2129 RTC code problem

Hello all,

Can anyone please explain this LPC2129 code in detail. It uses RTC to display the current time on UART0. The code works alright just needs an in-depth explanation. The code is attached below.

Thanks 

#include<LPC21xx.h>

void rtc_init(void);

 

void Uart_Init(void)

{

               U0LCR= 0x9B; //8 bits data, 1 stop bit, even parity /* line control registor */

               U0DLL= 0x62; //9600 baud rate /* baud rate registor */

               U0DLM= 0x00; /* baud rate registor */

               U0LCR= 0x1B; //disable the access of DLL DLM so that we can access U0THR

}

 

void Uart_Data(unsigned char data)

{

               U0THR = data;

               while((U0LSR & 0X20)!= 0X20);

}

 

void Uart_String(unsigned char *dat)

{

               while(*dat!='\0')

               {

                              Uart_Data(*dat);

                              dat++;

               }

}

 

void Port_Initial(void)

{

               PINSEL0 = 0x00000005;

}

 

int main()

{

               Port_Initial();

               Uart_Init();

               Uart_String("18070123123\n");

               //Uart_Data('\n'); 

               Uart_String("Tanay Tripathi");

               //Uart_Data('\n'); 

               PREINT=0x1C7;

               PREFRAC=0xE1C0;

               AMR=0xFF; //mask all bits ie. no alarm

               rtc_init(); //initialize all seconds,minute and hour values

               CCR=0x01; //timer started

               while(1) //to keep alive so as to monitor the clock

               {

                              Uart_Data(HOUR/10+'0');

                              Uart_Data(HOUR%10+'0');

                              Uart_Data(':');

                              Uart_Data(MIN/10+'0');

                              Uart_Data(MIN%10+'0');

                              Uart_Data(':');

                              Uart_Data(SEC/10+'0');

                              Uart_Data(SEC%10+'0');

                              Uart_String("\n");

               }

}

 

void rtc_init()

{

               SEC=20; //Initialized seconds

               MIN=00; //Initialized minutes

               HOUR=12;//Initialized hour

              

}

More questions in this forum