AnsweredAssumed Answered

STM32F401 wake up with Periodic mode

Question asked by stan on Nov 7, 2015
Latest reply on Nov 26, 2015 by Amel N
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....

01.void RTC_Configuration(void)
02.{
03.        EXTI_InitTypeDef EXTI_InitStructure;
04.        NVIC_InitTypeDef NVIC_InitStructure;
05. 
06.    /* Configure EXTI Line0 */
07.     EXTI_InitStructure.EXTI_Line = EXTI_Line22;
08.     EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
09.     EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
10.     EXTI_InitStructure.EXTI_LineCmd = ENABLE;
11.     EXTI_Init(&EXTI_InitStructure);
12. 
13.    /* Enable RTC Wakup Interrupt to the lowest priority */
14.     NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
15.     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
16.     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
17.     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
18.     NVIC_Init(&NVIC_InitStructure);
19. 
20.      /* Enable the PWR clock */
21.      RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
22. 
23.      /* Allow access to RTC */
24.      PWR_RTCAccessCmd(ENABLE);
25. 
26.      /* Enable the LSI OSC */
27.      RCC_LSICmd(ENABLE);               // The RTC Clock may varies due to LSI frequency dispersion
28. 
29.      /* Wait till LSI is ready */
30.      while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET);
31. 
32.      /* Select the RTC Clock Source */
33.      RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
34. 
35.        /* Enable the RTC Clock */
36.      RCC_RTCCLKCmd(ENABLE);
37. 
38.      /* Wait for RTC APB registers synchronisation */
39.      RTC_WaitForSynchro();
40. 
41.      // RTC Wakeup Configuration
42.      RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);
43. 
44.      // RTC Set WakeUp Counter
45.      RTC_SetWakeUpCounter(0);
46. 
47.      // Enabling RTC_WakeUp interrupt
48.      RTC_ITConfig(RTC_IT_WUT, ENABLE);
49. 
50.      // Disabling Alarm Flags
51.      RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
52.      RTC_AlarmCmd(RTC_Alarm_B, DISABLE);
53. 
54.      // RTC Enable the Wakeup Function
55.      RTC_WakeUpCmd(ENABLE);
56.}

Outcomes