cancel
Showing results for 
Search instead for 
Did you mean: 

32F429IDISCOVERY Waking up from STANDBY by RTC alarm issue

mchalapetr
Associate II
Posted on May 07, 2015 at 21:38

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...

#rtc #stm32f4 #standby #alarm
3 REPLIES 3
Posted on May 07, 2015 at 22:14

Do you have an LSE crystal on this board? By default it and it's associated components are not present. Pretty sure LSI isn't in the low power domain.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mchalapetr
Associate II
Posted on May 08, 2015 at 14:37

Yeah, I am using LSE...I added it mainly becuase of RTC accuracy...

The RTC is obviously fine because when MCU doesnt wake up and I leave it for example +10 min alone and then wake it up by USER button then the clock is really +10 min...

I think I have same problem as described here: [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Leaving%20Standby%20by%20WakeUp%20pin%20and%20RTC%20Alarm&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=497]topic ...

mchalapetr
Associate II
Posted on May 15, 2015 at 14:38

Hi problem was with this line....alarm_time.seconds = time.seconds + 5;

Basically an overflow of the usable range...I thought that the RTC modifies the data before using...