how to use   API ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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 

0 Likes
7 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

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 ?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable
        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);   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
Anonymous
Not applicable

        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'

0 Likes
Anonymous
Not applicable

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}

0 Likes