2017-04-17 12:28 AM
Hello, I tried to using STOP Mode on STM32L051 but it was not working
/* Includes ------------------------------------------------------------------*/
#include 'main.h'
#include 'stm32l0xx_hal.h'
#include 'rtc.h'
#include 'gpio.h'
#include <math.h>
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void Error_Handler(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
void StopMode_Init(void) {
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower();
/* Enable the fast wake up from Ultra low power mode */
HAL_PWREx_EnableFastWakeUp();
//LowPower_GPIO();
/* Select HSI as system clock source after Wake Up from Stop mode */
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_HSI);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
}
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_RTC_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, ceil(5 / (0.000437)), RTC_WAKEUPCLOCK_RTCCLK_DIV16);
//HAL_Delay(10);
StopMode_Init();
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
}
/* USER CODE END 3 */
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
but it was working on STM32L053 and STM32L073 so I can't figure out. That is so weird. Now I found another issue I put GPIO_TogglePin in RTC_Interrupt in stm32l0xx_it.c but I never get an interrupt.
void RTC_IRQHandler(void)
{
/* USER CODE BEGIN RTC_IRQn 0 */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_5);
/* USER CODE END RTC_IRQn 0 */
HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc);
/* USER CODE BEGIN RTC_IRQn 1 */
/* USER CODE END RTC_IRQn 1 */
}�?�?�?�?�?�?�?�?�?�?
2017-04-17 01:41 AM
Hi
Tanomsup.Nathapol
,I suggest you to start from the STOP exampleunder STM32cubeL0package it may be helpful :
STM32Cube_FW_L0_V1.8.0\Projects\STM32L053R8-Nucleo\Examples\PWR\PWR_STOP_RTCAlso Have a look to the
you find some recommended PCB routing guidelines-Nesrine-
2017-04-17 04:06 AM
I already looked at that example but it seems like stm32l051 never did this command
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);�?
I tried to use without RTC but it is still not working. Do I need to do something special when I use STM32L051?
2017-04-17 04:19 AM
I don't think it does not work because of my circuit. It use only internal circuit in your chip and I used LSI to wake chip up.
2017-04-17 07:32 AM
Refer to
https://community.st.com/0D50X00009XkY68SAF
Just add
/* Enter Stop Mode */HAL_SuspendTick();HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);HAL_ResumeTick();�?�?�?�?
It works like a charm. So why it must use that command. It is that bug ?