cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Alarm Callback Double Firing

bogeythehoagie
Associate

The name. Basically using RTC interrupts to run the call back function every minute and increment a minute counter to do stuff with. However sometimes the minute double fires. There was a post regarding TIM2 firing twice and I tried to clear RTC flags in the call back with no good results(still firing twice). I will post my call back code and image of the alarm configuration. Thanks

 

void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)

{

RTC_AlarmTypeDef sAlarm;

HAL_RTC_GetAlarm(hrtc,&sAlarm,RTC_ALARM_A,FORMAT_BIN);

//sAlarm.AlarmTime.Seconds=sAlarm.AlarmTime.Seconds+1;

 

if(sAlarm.AlarmTime.Minutes>58) {

sAlarm.AlarmTime.Minutes=0;

}else{

sAlarm.AlarmTime.Minutes=sAlarm.AlarmTime.Minutes+1;

}

while(HAL_RTC_SetAlarm_IT(hrtc, &sAlarm, FORMAT_BIN)!=HAL_OK){}

mins+=1;

if(mins==60){

mins-=60;

hrs++;

}

if(hrs==24){

hrs-=24;

days++;

}

if(days==7){

days-=7;

weeks++;

}

 

////////////This section below is me trying to clear the flag///////////

/*

__HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);

__HAL_RTC_ALARM_EXTI_CLEAR_FLAG();

__HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_IT_ALRA);

__HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);

*/

 

0 REPLIES 0