7 Replies Latest reply on Sep 7, 2015 10:50 AM by userc_40985

    how to use   API ?




      what is use of two API






      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 ?

          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 ?

            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 ?

              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.





              • 4. Re: how to use   API ?
                        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 ?

                  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.





                  • 6. Re: how to use   API ?

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




                           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 ?

                      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.








                      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);






                      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
                          //Turn on an LED