cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401 wake up with Periodic mode

sshults9
Associate
Posted on November 07, 2015 at 17:25

Dear gentelmen,

I'm quite new in this ''PowerSaving'' area and looking for your support. I work on application where stm32f401 have to wake up every predefined period of time(30min-24h), do some job and sleep again. For power sawing I use ''Standby Mode''. Most of sollutions/examples, I found so far, are developed for 1s period of time and seems not all of them for F4x series. I'm kindly asking to help me with an code example of configuring this mode and setting different period of times. I have no external oscilator, therefore going to use LSI. I was trying to use this code but it seems ''

PWR_RTCAccessCmd(ENABLE);

'' is not part of my ''stm32f4xx_rcc.h'' library and I see no sollution for settign up time stamp....


void RTC_Configuration(void)

{

EXTI_InitTypeDef EXTI_InitStructure;

NVIC_InitTypeDef NVIC_InitStructure;


/* Configure EXTI Line0 */

EXTI_InitStructure.EXTI_Line = EXTI_Line22;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);


/* Enable RTC Wakup Interrupt to the lowest priority */

NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);


/* Enable the PWR clock */

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);


/* Allow access to RTC */

PWR_RTCAccessCmd(ENABLE);


/* Enable the LSI OSC */

RCC_LSICmd(ENABLE); // The RTC Clock may varies due to LSI frequency dispersion


/* Wait till LSI is ready */

while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);


/* Select the RTC Clock Source */

RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);


/* Enable the RTC Clock */

RCC_RTCCLKCmd(ENABLE);


/* Wait for RTC APB registers synchronisation */

RTC_WaitForSynchro();


// RTC Wakeup Configuration

RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);


// RTC Set WakeUp Counter

RTC_SetWakeUpCounter(0);


// Enabling RTC_WakeUp interrupt

RTC_ITConfig(RTC_IT_WUT, ENABLE);


// Disabling Alarm Flags

RTC_AlarmCmd(RTC_Alarm_A, DISABLE);

RTC_AlarmCmd(RTC_Alarm_B, DISABLE);


// RTC Enable the Wakeup Function

RTC_WakeUpCmd(ENABLE);

}

#!stm32f4-!stm32f401-!rtc
1 REPLY 1
Amel NASRI
ST Employee
Posted on November 26, 2015 at 14:53

Hi stan,

The function ''PWR_RTCAccessCmd'' isn't available in F4 drivers.

You should use the function ''PWR_BackupAccessCmd'' to allow access to RTC.

Another comment about your code: the RTC wakeup counter shouldn't be equal to 0. 

Have a look to the RTC configuration used in the example STM32F4xx_DSP_StdPeriph_Lib_V1.6.1\Project\STM32F4xx_StdPeriph_Examples\PWR\PWR_CurrentConsumption\stm32f4xx_lp_modes.c. 

You will find it in the functions StandbyRTCMode_Measure or StopMode_Measure.

If you are interested on other tips to efficiently manage the power consumption on your product, I recommend you have a look to

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00096220.pdf

and test its associated

http://www.st.com/web/en/catalog/tools/PF260439

.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.