cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G070RB, Maximum Alarm length

MEder
Associate III

What is the maximum alarm length in the G070. I only see about 30days.

I need 6 months.

I guess I could implement one using the TAMP_BKPxR registers and compare the RTC DR , TR with the alarm values I have store in the TAMP regs. ( stripping out the WDU)

I only need to check the alarm on start up.

Thanks

3 REPLIES 3
Uwe Bonnes
Principal III

Set alarm to the longest time possible, wake up and check if you have to delay for another step or if you wake up for the real event.

You can also run the RTC with a higher divider, i.e. not at the nominal speed but slower.

JW

MEder
Associate III

I am using the RTC for time stamps to a log, so I can't change the clock. I could set a 24hr alarm and check for the 6 month period, but I just need to check on startup, it'll be on/off multiple times a day.

So the RTC DR and TR regs are formatted such that his will work...

My Alarm date is stored in 2 TAMP regs in the same format as the DR and TR regs.

// read TAMP regs 0 & 1 and see if the alarm time has passed.

uint32_t alarm_timereg = BACKUP_TR_REG; // TAMP_BKP0R

uint32_t alarm_datereg = BACKUP_DR_REG; // TAMP_BKP1R

// read out both to prevent lock

uint32_t trreg = RTC->TR;

uint32_t drreg = RTC->DR & ~RTC_DR_WDU_Msk; // remove Weekdays

// Check Enable bit

if(alarm_timereg & ALARMX_ENABLE){ // strip enable bit from TAMP reg to check alarm, I store the alarm enable in the TAMP reg

alarm_timereg &= ~ALARMX_ENABLE;

if(drreg >= alarm_datereg){ // format of time reg is PM, H,M,S, date reg is Y,M,D

if(trreg >= alarm_timereg){

return(1); // Alarm date has passed

}

}

} // end if enabled

return (0);

Seems to work ok, even for 12 hour am/pm settings.