M41T62 RTC Alarm
Hello,
We are currently using the M41T62 RTC which is connected to a STWINKT1B board from ST along with the drivers meant to be used with M41T62(download page).
We have been successfully able to use it to set a 1 min alarm with interruptions in repetitive mode.
The same was possible with a 1-hour alarm with interruption. We followed the guidelines given for the TIMEKEEPER series application note that tells us to set RTP5, RTP4, RTP3, RTP2, and RTP1 to set the right repetitive alarms.
The problem we have is that we are unable to set it for in-between durations such as 1 min or 30 mins or 5 mins. Can you help us out with this?
/*
Simple Test code
*/
M41T62_Date_st Date = { 0, 0, 0, 0, 0 };
M41T62_Time_st Time = { 0, 0, 0, 0 };
uint32_t rtcECntr = 0;
uint32_t pre_rtcECntr = 0;
M41T62_AF_State_et af = M41T62_AF_LOW;
M41T62_Alarm_st alarm = { 0, 0, 0, 0, 10 };
int ret = BSP_ERROR_NONE;
/*
Check for I2C Device
*/
for (int i = 1; i < 256; i++) {
ret = HAL_I2C_IsDeviceReady(&hi2c4, (uint16_t) (i << 1), 3, 5);
if (ret == HAL_OK) {
msg_info("\nDevice Id = %02d", i);
}
}
/*
Read Date/Time from STM32 internal RTC
*/
/* Get the RTC current Time */
HAL_RTC_GetTime(&hrtc, &start_rtctime, RTC_FORMAT_BIN);
/* Get the RTC current Date */
HAL_RTC_GetDate(&hrtc, &start_rtcdate, RTC_FORMAT_BIN);
Time.Hours = start_rtctime.Hours;
Time.Minutes = start_rtctime.Minutes;
Time.Seconds = start_rtctime.Seconds;
Time.Seconds_10Ths = start_rtctime.SecondFraction;
Date.DayMonth = start_rtcdate.Date;
Date.DayWeek = start_rtcdate.WeekDay;
Date.Month = start_rtcdate.Month;
Date.Year = start_rtcdate.Year;
if(M41T62_Setting_Date(Date) != M41T62_OK)
msg_error("\nM41T62_Setting_Date()");
if(M41T62_Setting_Time(Time) != M41T62_OK)
msg_error("\nM41T62_Setting_Time()");
alarm.AlSeconds = 0X30;
alarm.AlMinutes = 0x01;
M41T62_Get_AF_Bit(&af);
M41T62_Set_AFE_Bit(M41T62_AFE_LOW);
if(M41T62_Disable_Alarm() != M41T62_OK)
msg_error("\nM41T62_Disable_Alarm()");
if(M41T62_Setting_DefaultBit() != M41T62_OK)
msg_error("\nM41T62_Setting_DefaultBit()");
if(M41T62_Alarm_Setting(alarm) != M41T62_OK)
msg_error("\nM41T62_Alarm_Setting()");
if(M41T62_Alarm_Repeat_Mode_Setting(M41T62_OnceperHour) != M41T62_OK)
msg_error("\nM41T62_Alarm_Repeat_Mode_Setting()");
/*
Set Alarm Enable Bit
*/
M41T62_Set_AFE_Bit(M41T62_AFE_HIGH);
HAL_Delay(100);
M41T62_Get_AF_Bit(&af);
msg_info("\n\n");
rtcECntr = 0;
/*
Loop through and check for Alarm Bit
*/
while (1) {
HAL_Delay(1000);
M41T62_Get_AF_Bit(&af);
if (af == M41T62_AF_HIGH) {
msg_info("\n========> Alarm AF Set");
ret = M41T62_Getting_Time(&Time);
if (ret == M41T62_OK) {
msg_info("\tTime:%02d:%02d:%02d:%02d\t%02ld\t%02lds\n", Time.Hours,
Time.Minutes, Time.Seconds, Time.Seconds_10Ths,
rtcECntr, (rtcECntr - pre_rtcECntr));
pre_rtcECntr = rtcECntr;
}
else
{
msg_error("\nM41T62_Getting_Time Failed!")
}
} else {
msg_info(".");
}
M41T62_ReadRegs(M41T62_AL_MONTHREG, 5, tmp);
rtcECntr++;
}Attaching below is a reference code that we are currently running.
