2 Replies Latest reply on Jul 22, 2019 5:02 PM by MoTa_728816

    PSoC 5LP - RTC UART output

    JaGe_4104756

      Hello everybody,

      a few weeks have passed, my first programming has worked great and I'm very proud of it.

      Now, however, I am again facing a new problem and may be silly to me :-(.

      Namely, I have installed according to data sheet of RTC to the inputs 15.2 and 15.3 a Crystal 32.768 kHz that my output of time and date is continuous.

      Can you help me with the code?

      This was the old date and time issue and this was always stamped by the debugg-date_time:

      UART_1_PutString (__ DATE__);
      UART_1_PutString (" ");
      UART_1_PutString (__ TIME__);
      UART_1_PutString (" ");
      UART_1_PutString (TransmitBuffer);
      UART_1_ClearTxBuffer ();



      Is it possible that I will give an initial stamp with "" __DATE__ and __TIME__ "and then mine will be consecutive?

      I have an issue that will be issued after a certain time, currently 10 sec, via HTerm.

      It would be unbelievably nice of you if you would help me.


      Many Thanks
      jg.vs

        • 1. Re: PSoC 5LP - RTC UART output
          BragadeeshV_41

          Hi,

           

          Can you please check if this code example helps with your issue?

           

          https://www.cypress.com/documentation/code-examples/ce95355-real-time-clock-rtc-psoc-35lp

           

          Please use the device selector (Project -> Device Selector) to test the example for PSoC 5 device.

           

          Regards,

          Bragadeesh

          • 2. Re: PSoC 5LP - RTC UART output
            MoTa_728816

            Hi,

             

            In the sample I attached at

            store measured values in CSV and output chart - PSOC 5LP

             

            I was setting date and time from UART input as below

            ==============================

            void set_date_time(void)

            {

                DateTime date_time ;

                print("Enter Date (YYYY/MM/DD) > ") ;

                while(get_string(str) <= 0) ;

                sscanf(str, "%d/%d/%d", &year, &month, &day) ;

                print("Enter Time (hh:mm:ss) > ") ;

                while(get_string(str) <= 0) ;

                sscanf(str, "%d:%d:%d", &hours, &minutes, &seconds) ;

                date_time.year    = year ;

                date_time.month  = month - 1 ; /* unix time, month is 0~11 instead of 1~12 orz */

                date_time.day    = day ;

                date_time.hours  = hours ;

                date_time.minutes = minutes ;

                date_time.seconds = seconds ;

                unix_time = convertDateToUnixTime(&date_time) ;

            }

            ==============================

             

            But if you want to acquire date and time from "__DATE__" and "__TIME__",

            it will look like

            ==============================

            static char *month_name[] = {

                "---",

                "Jan", "Feb", "Mar", "Apr",

                "May", "Jun", "Jul", "Aug",

                "Sep", "Oct", "Nov", "Dec"

            } ;

             

            void set_date_time(void)

            {

                DateTime date_time ;

                char m_name[16] ;

              

                sscanf(__DATE__, "%s %d %d", m_name, &day, &year) ;

                sscanf(__TIME__, "%d:%d:%d", &hours, &minutes, &seconds) ;

                for (month = 0 ; month < 13 ; month++) {

                    if (strncmp(month_name[month], m_name, 3) == 0) {

                        break ;

                    }

                }

                if (month >= 12) {

                    print("Unknown Month Name ") ;

                    print(m_name) ;

                    print("\n") ;

                    month = 1 ; /* assume it's Jan */

                }

             

                date_time.year    = year ;

                date_time.month  = month - 1 ; /* unix time, month is 0~11 instead of 1~12 orz */

                date_time.day    = day ;

                date_time.hours  = hours ;

                date_time.minutes = minutes ;

                date_time.seconds = seconds ;

                unix_time = convertDateToUnixTime(&date_time) ;  

            }

            ==============================

             

            And the Tera Term output looks like

            000-TeraTerm-log.JPG

             

            NOTE: the "__DATE__" and "__TIME__" strings hold the time when the program was compiled,

            so as far as you are repeating debugging it may be close to the real time,

            but if you run it after a while the date and time won't be reasonable.

             

            moto