6 Replies Latest reply on May 20, 2017 10:13 AM by user_242978793

    RTC Example 5LP kit 059

    george29.-

      Hi,

         

      First timer here so please forgive my simple questions as new to C and Cypress, though have done a little C++ with Arduino.

         

      Been working though the tutorials etc and have the RTC 5LP example running ok.

         

      The first point, though cannot see anything in the RTC datasheet, wondered if  there is any way the RTC can be programmed with the current time/date automatically  taken from host PC at programming time ? a very handy feature found on the Arduino.

         

      The other point is about my lack of C knowledge

         

      Was amending the RTC main.c code to display on the LCD in different layouts etc, but then found that some changes had been totally ignored.

         

      Found the cause to be that the same code was replicated in the RtcIntHandler.c and that was overriding the changes I made in main.c

         

      So does C demand you duplicate code like this ? or was the code put in the main.c  as well,  just to make things clearer for the newbie  to see hows it was done ?

         

      thanks

         

       

         

      part of the code in both main.c   ---

         


          /* Print current time */
          tmpVar = RTC_ReadSecond();
          PrintDecNumber(tmpVar, 0u, 11u);  etc etc

         

       

         

      and RtcIntHandler.c

         

      void RTC_EverySecondHandler_Callback(void)
      {
          /* Get and print current seconds */
          temp = RTC_ReadSecond();        
          PrintDecNumber(temp, 0u, 11u);
          
          /* Get status */
          temp = RTC_ReadStatus();  etc etc
        

        • 1. Re: RTC Example 5LP kit 059
          user_78878863

          You did not post your project, and my crystal ball is still in repair, so I will take an educated guess.

             

          RtcInt is an ISR that you did add to the RTC? If so, then yes it will be called whenever the interrupt gets triggered. There is no need to duplicate this functionality in main (but you should not do long-running stuff in the ISR, such as writing to the LCD - better just set a (volatile) flag which main can then read and react on).

             

          No, there is no automatic way to set the time from the PC, and AFAIK even the Ardiuno doesn't have that (esp. when not connected to a PC...). But you can add this by yourself quite easily via the UART.

          • 2. Re: RTC Example 5LP kit 059
            george29.-

            Thanks for the reply.

               

            Its the RtcDesign Example file for the 5LP,  that comes with PSoC v4 , not any code I have written , was just amending the code to change the layout of the lcd output when I found the problem as above.

               

            Perhaps that Example code has just been quickly put together.....

               

            As you say, its not good practice to use  lengthy lcd routines in the ISR  , though wondered with these faster  chips if that was still a problem vs my old 8 bit Pic chips with Assembly code !

            • 3. Re: RTC Example 5LP kit 059
              user_1377889

              Welcome in the forum, George.

                 

              As hli says, it  is easier for us to help you when you post your complete project. With the help of the IDE everything is easier to follow and to check.

                 

              Concerning lengthy interrupt handlers: I have seen issues where just a character was sent via USB stalling the system. Usually you are not aware of delay function calls within the generated code, so hli's suggestion makes sense. Of course the code might be a bit longer, as long as you are able to overview all the consequences.

                 

               

                 

              Bob

              • 4. Re: RTC Example 5LP kit 059
                user_242978793

                Here is an example program that may help you. 

                • 5. Re: RTC Example 5LP kit 059
                  user_242978793

                  Date is set for 12/31/2007 and time is set for 22:59:22 so you will need to change this to the correct date and time.

                  • 6. Re: RTC Example 5LP kit 059
                    user_78878863

                    Its not the MCU speed thats the problem here - the LCD will just take a while for each characters, and your code needs to wait for that to finish.