2021-11-17 04:10 AM
mcu: " STM32F407VGT Discovery Board - DICS1 "
application: RTC ALARM
i am trying to set the RTC alarm for every 15 minutes in all the day. in each RTCAlarmcallback function i am setting the RTC alarm again with sTime.Minutes + 15.
if sTime.Minutes is greter than 45, i am setting RTC alarm minutes [i.e, sRtcAlarmTime->Minutes] to 0
is i am doing correct?
pls guide me to do this.
this bellow function which is i am using:
void set_Alarm_A (RTC_TimeTypeDef *sRtcAlarmTime, RTC_DateTypeDef *sRtcAlarmDate)
{
RTC_AlarmTypeDef sAlarm = {0};
/*
* Set the Alarm A
*/
sAlarm.AlarmTime.Hours = sRtcAlarmTime->Hours;
sAlarm.AlarmTime.Minutes = sRtcAlarmTime->Minutes;
sAlarm.AlarmTime.Seconds = sRtcAlarmTime->Seconds;
sAlarm.AlarmTime.SubSeconds = sRtcAlarmTime->SubSeconds;
sAlarm.AlarmTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sAlarm.AlarmTime.StoreOperation = RTC_STOREOPERATION_RESET;
sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_SECONDS;
sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE;
sAlarm.AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE;
sAlarm.AlarmDateWeekDay = sRtcAlarmDate->Date;
sAlarm.Alarm = RTC_ALARM_A;
if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
}
is this correct?
Solved! Go to Solution.
2021-11-18 04:23 AM
I don't use Cube, but that probably directly converts to RTC_ALRMxR.MSKx bits, see RTC chapter in RM.
In other words, in the above setting, date, hours and seconds are ignored for checking the alarm, i.e. only minutes are checked.
JW
2021-11-17 04:52 AM
> if sTime.Minutes is greter than 45, i am setting RTC alarm minutes [i.e, sRtcAlarmTime->Minutes] to 0
And if it's equal to 45?
JW
2021-11-17 09:35 PM
if its equals to 45 min i will set RTC Alarm Minutes to 0
2021-11-17 11:09 PM
> sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_SECONDS;
what meaning if i use like above?
2021-11-18 04:23 AM
I don't use Cube, but that probably directly converts to RTC_ALRMxR.MSKx bits, see RTC chapter in RM.
In other words, in the above setting, date, hours and seconds are ignored for checking the alarm, i.e. only minutes are checked.
JW
2021-11-18 05:11 AM
thank you
2021-11-18 05:22 AM
Assume you need to advance hours when you overflow minutes.