AnsweredAssumed Answered

32F429IDISCOVERY Waking up from STANDBY by RTC alarm issue

Question asked by machala.petr on May 7, 2015
Latest reply on May 15, 2015 by machala.petr
Hi,

I have a big problem with waking up the 32F429IDISCOVERY board from STANDBY mode by RTC alarm and I dont see any solutions...
The problem is that the board wakes up only sometimes from the RTC Alarm. Usually like 3 times in a row and then stops. Waking up by user button is fine...
I found some topics regarding same problems but reading them all I think that I am doing everything right...
The operation itself should be simple...I manually set up RTC alarm and get to STANDBY mode and after that the MCU wakes up does something and then goes back to STANDBY in a loop until I interupt it manually by button...


Manual set up looks like this:
// Load time and date values from RTC
RTC_AWU_GetDateTime(&time, RTC_AWU_Format_BIN);
// Set up RTC alarm
alarm_time.hours = time.hours;
alarm_time.minutes = time.minutes;
alarm_time.seconds = time.seconds + 5;
alarm_time.alarmtype = RTC_AWU_AlarmType_DayInWeek;
alarm_time.day = 1;
RTC_AWU_SetAlarm(RTC_AWU_Alarm_B, &alarm_time, RTC_AWU_Format_BIN);
/* Power down */
// Disable wakeup pin (BUTTON = PA0)
PWR_WakeUpPinCmd(DISABLE);

// Clear standby/wakeup flag
PWR_ClearFlag(PWR_FLAG_SB | PWR_FLAG_WU);
// Enable wakeup pin (BUTTON = PA0)
PWR_WakeUpPinCmd(ENABLE);
// Go to standby mode
PWR_EnterSTANDBYMode();

Then the loop exacly the same:
// RTC init (PWR_BackupAccessCmd(ENABLE) present here)
RTC_AWU_Init(RTC_AWU_ClockSource_External);

if (RTC_GetITStatus(RTC_IT_ALRB) != RESET){
     /*Some code here*/

     // Load time and date values from RTC
     RTC_AWU_GetDateTime(&time, RTC_AWU_Format_BIN);

     // Set up RTC alarm
     alarm_time.hours = time.hours;
     alarm_time.minutes = time.minutes;
     alarm_time.seconds = time.seconds + 5;
     alarm_time.alarmtype = RTC_AWU_AlarmType_DayInWeek;
     alarm_time.day = 1;
     RTC_AWU_SetAlarm(RTC_AWU_Alarm_B, &alarm_time, RTC_AWU_Format_BIN);

     /* Power down */
     // Disable wakeup pin (BUTTON = PA0)
     PWR_WakeUpPinCmd(DISABLE);

     // Clear standby/wakeup flag
     PWR_ClearFlag(PWR_FLAG_SB | PWR_FLAG_WU);

     // Enable wakeup pin (BUTTON = PA0)
     PWR_WakeUpPinCmd(ENABLE);

     // Go to standby mode
     PWR_EnterSTANDBYMode();
}

The RTC_AWU_SetAlarm function looks like this...
// Disable Alarm B
RTC_AlarmCmd(RTC_Alarm_B, DISABLE);

// Disable Alarm B interrupt
RTC_ITConfig(RTC_IT_ALRB, DISABLE);

// Clear Alarm B pending bit
RTC_ClearFlag(RTC_IT_ALRB);

// Clear RTC Alarm pending bit
EXTI_ClearITPendingBit(EXTI_Line17);

// Configure EXTI 17 as interrupt
EXTI_InitStruct.EXTI_Line = EXTI_Line17;
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStruct);

// Configure the RTC Alarm Interrupt
NVIC_InitStruct.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStruct);



// Set RTC alarm settings
// Set alarm time
RTC_AlarmStruct.RTC_AlarmTime.RTC_Hours = DataTime->hours;
RTC_AlarmStruct.RTC_AlarmTime.RTC_Minutes = DataTime->minutes;
RTC_AlarmStruct.RTC_AlarmTime.RTC_Seconds = DataTime->seconds;
RTC_AlarmStruct.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay;
etc...

// Configure the RTC Alarm B
RTC_SetAlarm(format, RTC_Alarm_B, &RTC_AlarmStruct);

// Clear Alarm B pending bit
RTC_ClearFlag(RTC_IT_ALRB);

// Enable Alarm B interrupt
RTC_ITConfig(RTC_IT_ALRB, ENABLE);

// Enable Alarm B
RTC_AlarmCmd(RTC_Alarm_B, ENABLE);


Thanks very much for your help...

Outcomes