cancel
Showing results for 
Search instead for 
Did you mean: 

how to set RTC alarm for all day in stm32f407vgt?

Vinay1
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6

> 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

if its equals to 45 min i will set RTC Alarm Minutes to 0

 > sAlarm.AlarmMask = RTC_ALARMMASK_DATEWEEKDAY | RTC_ALARMMASK_HOURS | RTC_ALARMMASK_SECONDS;

what meaning if i use like above?

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

thank you

Assume you need to advance hours when you overflow minutes.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..