problem in RTC ALARM

hi everyone

I'm usig stm32f103 and code below  to set rtc alarm every one hour

RTC_Alarm_Time.Alarm = 1; 

RTC_Alarm_Time.AlarmTime.Hours=RTC_Time.Hours+1;
 if (RTC_Alarm_Time.AlarmTime.Hours>23)
{
 RTC_Alarm_Time.AlarmTime.Hours=0;
 }
 RTC_Alarm_Time.AlarmTime.Hours=RTC_Time.Hours;
RTC_Alarm_Time.AlarmTime.Minutes=RTC_Time.Minutes;
RTC_Alarm_Time.AlarmTime.Seconds=RTC_Time.Seconds;
HAL_RTC_SetAlarm_IT(&hrtc, &RTC_Alarm_Time, RTC_FORMAT_BIN);

my problem is that it skips hour zero and after hour 23 it goes to hour 1.

i tried this code but it didnt worked too.

if(RTC_Time.Hours==23)
{
RTC_Alarm_Time.AlarmTime.Hours=0;
}
else
{
RTC_Alarm_Time.AlarmTime.Hours=RTC_Time.Hours+1;
}

RTC_Alarm_Time.AlarmTime.Minutes=RTC_Time.Minutes;
RTC_Alarm_Time.AlarmTime.Seconds=RTC_Time.Seconds;

appreciate your help.

More questions in this forum