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 SEC, MIN, HOUR etc don't increment (LPC2129)

Hello,

I've developed a simple program that sends current time/date to the serial port COM1. But on the gyper terminal I see that time is not being changed.
Could you give me a hand with it?
What is wrong in this code?

// ------------------------------------
#include <stdio.h>
#include <LPC21xx.H>
// Delay in ms
void delay_ms(long int ms)
{ long int i,j; for(i=0;i<ms;i++) for(j=0;j<6666;j++); //6653
}

// Start point
int main (void)
{ int year, month, day; int hour, min, sec;

/* initialize the serial interface */ PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */

/* the 'printf' function call */ printf ("Hello World\n"); CCR = 0x0003; // CLKEN, CTCRST

/* When 1, the RTC is enabled. When 0, the RTC is disabled to conserve power. */
PCONP |= 0x20; //1 << 9;

while (1) { year = YEAR; month = MONTH; day = DOM; sec = SEC; min = MIN; hour = HOUR; printf("%d/%d/%d: %d:%d:%d - %d\n", day, month, year, hour, min, sec, ticks); delay_ms(100); }

Parents
  • Ok. I've corrected my source code.

    // ------------------------------------
    #include <stdio.h>
    #include <LPC21xx.H>
    // Delay in ms
    void delay_ms(long int ms)
    {
      long int i,j;
      for(i=0;i<ms;i++)
       for(j=0;j<6666;j++); //6653
    }
    
    // Start point
    int main (void)
    {
      int year, month, day;
      int hour, min, sec;
    
    /* initialize the serial interface */
      PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
      U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
      U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
      U1LCR = 0x03; /* DLAB = 0 */
    
      /* the 'printf' function call */
      printf ("Hello World\n");
      CCR = 0x0003; // CLKEN, CTCRST
    
      /* When 1, the RTC is enabled. When 0, the RTC is disabled to conserve power. */
      PCONP |= 0x20; //1 << 9;
    
      while (1)
      {
       year = YEAR;
       month = MONTH;
       day = DOM;
       sec = SEC;
       min = MIN;
       hour = HOUR;
       printf("%d/%d/%d: %d:%d:%d - %d\n", day, month, year, hour, min, sec, ticks); delay_ms(100); }
    
    

Reply
  • Ok. I've corrected my source code.

    // ------------------------------------
    #include <stdio.h>
    #include <LPC21xx.H>
    // Delay in ms
    void delay_ms(long int ms)
    {
      long int i,j;
      for(i=0;i<ms;i++)
       for(j=0;j<6666;j++); //6653
    }
    
    // Start point
    int main (void)
    {
      int year, month, day;
      int hour, min, sec;
    
    /* initialize the serial interface */
      PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
      U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
      U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */
      U1LCR = 0x03; /* DLAB = 0 */
    
      /* the 'printf' function call */
      printf ("Hello World\n");
      CCR = 0x0003; // CLKEN, CTCRST
    
      /* When 1, the RTC is enabled. When 0, the RTC is disabled to conserve power. */
      PCONP |= 0x20; //1 << 9;
    
      while (1)
      {
       year = YEAR;
       month = MONTH;
       day = DOM;
       sec = SEC;
       min = MIN;
       hour = HOUR;
       printf("%d/%d/%d: %d:%d:%d - %d\n", day, month, year, hour, min, sec, ticks); delay_ms(100); }
    
    

Children