7 Replies Latest reply on Sep 7, 2015 10:50 AM by jayanth.devarayanadurga

    how to use   API ?

    user_444739275

      Hello

         

      what is use of two API

         

      RTC_SetAlarmMask()

         

      RTC_GetAlarmMask()

         

      actually I am trying to compare current time and alarm time. If alarm time and current time match ,alarm occur.  If both time does not match , no alarm occur. I am not sure but I think I have to use  RTC_GetAlarmMask(). so that we can compare both time 

        • 1. Re: how to use   API ?
          user_14586677

          The mask is to determine what portions of date/time you want to

             

          use to create alarm. Like month day year, mask allows you to use

             

          all for the alarm, or just month or just day year or......

             

           

             

          Regards, Dana.

          • 2. Re: how to use   API ?
            user_444739275

            when I need to get time and date from RTC. I write following statement  

               

            uint32 time;
             uint32 date;

               

               /* Get Date and Time from RTC */
                    time = RTC_GetTime();
                    date = RTC_GetDate();
             

               

            I don't want to use two API , I just want to use one RTC_GetDateAndTime()  to get current time and date 

               

            how to replace that API with RTC_GetDateAndTime() ? and also What I have to do to get alarm time and date ?

            • 3. Re: how to use   API ?
              user_1377889

              The datasheet explains the parameter that RTC_GetDateAndTime() requires: A pointer to (address of) a structure RTC_DATE_TIME which you must provide. Same applies to RTC_GetAlarmDateAndTime(). Have a look into the datasheet under "Data Structures" to see the members of the struct. Help for accessing structs is here.

                 

               

                 

              Bob

              • 4. Re: how to use   API ?
                user_444739275
                        ok , I am trying int main() { typedef struct { uint32 time; uint32 date; uint32 dayOfWeek; uint32 status; }RTC_DATE_TIME; RTC_date_time AlarmDateAndTime; AlarmDateAndTime.Sec = 55u; AlarmDateAndTime.Min = 59u; AlarmDateAndTime.Hour = 22u; AlarmDateAndTime.DayOfMonth = 31u; AlarmDateAndTime.Month = 12u; AlarmDateAndTime.Year = 2007u; RTC_SetAlarmDateAndTime(); /* Enable all interrupts */ CyGlobalIntEnable; RTC_SetAtarmDateAndTime(& AlarmDataAndTime); RTC_GetAtarmDateAndTime(& AlarmDataAndTime);   
                • 5. Re: how to use   API ?
                  user_1377889

                  Not quite right. The structure is already declared you only need to define a variable of that type as

                     

                  struct RTC_DATE_TIME MyDateTime;

                     

                  Using the pre-defined structure saves you from errors in the case of API or structure changes in future component updates.

                     

                   

                     

                  Bob

                  • 6. Re: how to use   API ?
                    user_444739275

                            int main()
                    {
                       
                        uint32 time;
                        uint32 date;
                        uint32 alarm;

                       

                     while(1)
                        {

                       

                           date = RTC_GetDate();
                            time = RTC_GetTime();
                            alarm = RTC_GetAlarmDateAndTime();

                       

                    why I am getting this error ?

                       

                    Build error: too few arguments to function 'RTC_GetAlarmDateAndTime'

                    • 7. Re: how to use   API ?
                      jayanth.devarayanadurga

                      Hi vead

                         

                       

                         

                      I am pic.programmer at edaboard. I am trying to solve your problem. You have to do like this.

                         

                      I am waiting for the answer here.

                         

                      http://www.cypress.com/forum/psoc-4-architecture/how-set-values-time-date-dayofweek-and-status

                         

                       

                         

                      {code}

                         

                      RTC_date_time myDateAndTime, myAlarmDateAndTime;
                      uint32 alarmStatus = 0;

                         

                      //Set these values. They are uint32 type values.

                         

                      myDateAndTime.time = 
                      myDateAndTime.date = 
                      myDateAndTime.dayOfWeek = 
                      myDateAndTime.status = 

                         

                      myAlarmDateAndTime.time = 
                      myAlarmDateAndTime.date = 
                      myAlarmDateAndTime.dayOfWeek = 
                      myAlarmDateAndTime.status = 

                         

                      RTC_SetDateAndTime(myDateAndTime.time, myDateAndTime.date);

                         

                      RTC_SetAlarmDateAndTime(&myAlarmDataAndTime);

                         

                      RTC_SetAlarmMask(RTC_ALARM_SEC_MASK | RTC_ALARM_MIN_MASK | RTC_ALARM_HOUR_MASK 
                              | RTC_ALARM_DAYOFWEEK_MASK | RTC_ALARM_DAYOFMONTH_MASK | RTC_ALARM_MONTH_MASK | RTC_ALARM_YEAR_MASK);

                         

                      Read Alarm Status to check if Alarm has a match using

                         

                      alarmStatus = RTC_GetAlarmStatus();

                         

                      if(alarmStatus) {
                          //Current time and date match alarm time and date
                          RTC_ClearAlarmStatus();
                          //Turn on an LED
                      }

                         

                      {/code}