cancel
Showing results for 
Search instead for 
Did you mean: 

Use RTC wake up in STM32F051 stop mode

THwna.1
Associate

Hello.

I am using the stm32f051 discover board.

I want to use RTC's WAKE UP function when I wake up in stop mode, is there a way?

The STM32F051 MCU must be used.

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @THwna.1​ and welcome to the Community :),

Besides to the proposal from @MM..1​, I advise you, when you configured the RTC, to get inspired form the steps described in this FAQ: How to configure the RTC to wake up the STM32 periodically from Low Power modes.

This will help you to configure the RTC peripheral of the STM32 to wake up the STM32. 

I hope this helps!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Kaouthar

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.

View solution in original post

7 REPLIES 7
MM..1
Chief III

Use examples in firmware repository folder.

KDJEM.1
ST Employee

Hello @THwna.1​ and welcome to the Community :),

Besides to the proposal from @MM..1​, I advise you, when you configured the RTC, to get inspired form the steps described in this FAQ: How to configure the RTC to wake up the STM32 periodically from Low Power modes.

This will help you to configure the RTC peripheral of the STM32 to wake up the STM32. 

I hope this helps!

When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.

Kaouthar

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.

THwna.1
Associate

Thanks to your advice, I was able to find the answer. 

Currently, I succeeded in waking up in stop mode using RTC Alarm.

ck.1
Associate III

Try the example WFI wake from Interrupt in firmware repository folder .

remodel this to wake from RTC

file will be available in this folder

/STM32F0-Discovery_FW_V1.0.0/Project/Peripheral_Examples/NVIC_WFI_Mode

ck.1
Associate III

/**

 ******************************************************************************

 * @file   NVIC_WFI_Mask/main.c

 * @author MCD Application Team

 * @version V1.0.0

 * @date   23-March-2012

 * @brief  Main program body

 ******************************************************************************

 * @attention

 *

 * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>

 *

 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");

 * You may not use this file except in compliance with the License.

 * You may obtain a copy of the License at:

 *

 *       http://www.st.com/software_license_agreement_liberty_v2

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 *

 ******************************************************************************

 */

/* Includes ------------------------------------------------------------------*/

#include "stm32f0xx.h"

#include "stm32f0_discovery.h"

/** @addtogroup STM32F0_Discovery_Peripheral_Examples

 * @{

 */

/** @addtogroup NVIC_WFI_Mask

 * @{

 */

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

__IO uint32_t LowPowerMode = 0;

/* Private function prototypes -----------------------------------------------*/

void Delay(__IO uint32_t nCount);

/* Private functions ---------------------------------------------------------*/

/**

 * @brief Main program.

 * @param None

 * @retval None

 */

int main(void)

{

 /*!< At this stage the microcontroller clock setting is already configured,

      this is done through SystemInit() function which is called from startup

      file (startup_stm32f0xx.s) before to branch to application main.

      To reconfigure the default setting of SystemInit() function, refer to

      system_stm32f0xx.c file

    */

 /* Initialize Led and USER Button mounted on STM32F0-Discovery Kit */      

 STM_EVAL_LEDInit(LED3);

 STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);

 while (1)

 {

   if(LowPowerMode == 1)

   {

     /* Turn Off LED3 */

     STM_EVAL_LEDOff(LED3);

     /* Request to enter WFI mode */

     __WFI();

     LowPowerMode = 0;

   }

   Delay(0xFFFFF);

   STM_EVAL_LEDToggle(LED3);

 }

}

/**

 * @brief Inserts a delay time.

 * @param nCount: specifies the delay time length.

 * @retval None

 */

void Delay(__IO uint32_t nCount)

{

 for(; nCount != 0; nCount--);

}

#ifdef USE_FULL_ASSERT

/**

 * @brief Reports the name of the source file and the source line number

 *        where the assert_param error has occurred.

 * @param file: pointer to the source file name

 * @param line: assert_param error line source number

 * @retval None

 */

void assert_failed(uint8_t* file, uint32_t line)

{

 /* User can add his own implementation to report the file name and line number,

    ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

 /* Infinite loop */

 while (1)

 {

 }

}

#endif

/**

 * @}

 */

/**

 * @}

 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

ck.1
Associate III

/**

 ******************************************************************************

 * @file   NVIC_WFI_Mask/stm32f0xx_it.c

 * @author MCD Application Team

 * @version V1.0.0

 * @date   23-March-2012

 * @brief  Main Interrupt Service Routines.

 *         This file provides template for all exceptions handler and

 *         peripherals interrupt service routine.

 ******************************************************************************

 * @attention

 *

 * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>

 *

 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");

 * You may not use this file except in compliance with the License.

 * You may obtain a copy of the License at:

 *

 *       http://www.st.com/software_license_agreement_liberty_v2

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 *

 ******************************************************************************

 */

/* Includes ------------------------------------------------------------------*/

#include "stm32f0xx_it.h"

#include "stm32f0_discovery.h"

/** @addtogroup STM32F0_Discovery_Peripheral_Examples

 * @{

 */

/** @addtogroup NVIC_WFI_Mask

 * @{

 */

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

extern __IO uint32_t LowPowerMode;

/* Private function prototypes -----------------------------------------------*/

/* Private functions ---------------------------------------------------------*/

/******************************************************************************/

/*           Cortex-M0 Processor Exceptions Handlers                        */

/******************************************************************************/

/**

 * @brief This function handles NMI exception.

 * @param None

 * @retval None

 */

void NMI_Handler(void)

{

}

/**

 * @brief This function handles Hard Fault exception.

 * @param None

 * @retval None

 */

void HardFault_Handler(void)

{

 /* Go to infinite loop when Hard Fault exception occurs */

 while (1)

 {

 }

}

/**

 * @brief This function handles SVCall exception.

 * @param None

 * @retval None

 */

void SVC_Handler(void)

{

}

/**

 * @brief This function handles PendSVC exception.

 * @param None

 * @retval None

 */

void PendSV_Handler(void)

{

}

/**

 * @brief This function handles SysTick Handler.

 * @param None

 * @retval None

 */

void SysTick_Handler(void)

{

}

/******************************************************************************/

/*                STM32F0xx Peripherals Interrupt Handlers                  */

/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */

/* available peripheral interrupt handler's name please refer to the startup */

/* file (startup_stm32f0xx.s).                                              */

/******************************************************************************/

/**

 * @brief This function handles External lines 0 to 1 interrupt request.

 * @param None

 * @retval None

 */

void EXTI0_1_IRQHandler(void)

{

 if(EXTI_GetITStatus(USER_BUTTON_EXTI_LINE) != RESET)

 {

   EXTI_ClearITPendingBit(USER_BUTTON_EXTI_LINE);

   LowPowerMode = 1;

 } 

}

/**

 * @brief This function handles PPP interrupt request.

 * @param None

 * @retval None

 */

/*void PPP_IRQHandler(void)

{

}*/

/**

 * @}

 */

/**

 * @}

 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

ck.1
Associate III

dm00049931-stm32f0discovery-peripheral-firmware-examples-stmicroelectronics.PDF

3.19 NVIC WFI mode example

Purpose

This example shows how to enter the WFI mode and wake up from this mode by the User

key interrupt