Enable 2 alarms error

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

cross mob
Sanyika
Level 2
Level 2
10 sign-ins 5 replies posted 5 questions asked

Hello,

I try to implement 2 alarms with the RTC component on the PSOC6,
My issue it's when I call 2 functions to Set the 2 different alarms :

 

rtcApiResult = Cy_RTC_SetAlarmDateAndTime(&alarm1,CY_RTC_ALARM_1);
rtcApiResult = Cy_RTC_SetAlarmDateAndTime(&alarm2,CY_RTC_ALARM_2);

 

 I got the good return for the first function, but an error for the second (CY_RTC_INVALID_STATE)
If I put a CyDelay(1) between the 2 functions, I don't have any trouble

My question is : how to set the 2 alarms correctly (use the delay it's maybe not the good way to do it)

Thank you

0 Likes
1 Solution
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi,

It is recommended to put a delay else RTC will be busy.

This is shown in the below code snippet.

 

/* RTC Write bit set is possible only in condition that CY_RTC_BUSY bit = 0
* or RTC Read bit is not set
*/
if ((CY_RTC_BUSY != Cy_RTC_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_READ, BACKUP_RTC_RW)))
{
BACKUP_RTC_RW |= BACKUP_RTC_RW_WRITE_Msk;
retVal = CY_RTC_SUCCESS;

}

}

Regards

Alakananda

View solution in original post

0 Likes
1 Reply
Alakananda_BG
Moderator
Moderator
Moderator
50 likes received 250 sign-ins 250 replies posted

Hi,

It is recommended to put a delay else RTC will be busy.

This is shown in the below code snippet.

 

/* RTC Write bit set is possible only in condition that CY_RTC_BUSY bit = 0
* or RTC Read bit is not set
*/
if ((CY_RTC_BUSY != Cy_RTC_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_READ, BACKUP_RTC_RW)))
{
BACKUP_RTC_RW |= BACKUP_RTC_RW_WRITE_Msk;
retVal = CY_RTC_SUCCESS;

}

}

Regards

Alakananda
0 Likes