Can't enter sleep mode in STM32L052C8T6 (part of RHF76-052C LoRaWAN Module)
I have Lora module with STM32L052C8T6 mcu. I like to send short massages every minute or two. I sent data with success alredy, but my device will be battery powered so I need very power efficient approach.
I figured out that stop mode will be best suitable for me.
I created new project on CubeMX.
Selected 2 pins as output for led.
In RTC section: Selected: Activated Clock Source
Selected: Activate Calendar.
Alarm A: Disable, Alarm B: Disable,
Wake Up: Internal Wake Up
To generated code I added in main loop:
while (1) {
HAL_GPIO_TogglePin(GPIOB, LED1_Pin);
HAL_Delay(1000);
HAL_GPIO_TogglePin(GPIOB, LED1_Pin);
uint32_t _time = (((uint32_t) 500) * 2314) / 1000;
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, _time, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
__HAL_RCC_PWR_CLK_ENABLE(); // Enable Power Control clock
HAL_PWREx_EnableUltraLowPower(); // Ultra low power mode
HAL_PWREx_EnableFastWakeUp(); // Fast wake-up for ultra low power mode
// Switch to STOPMode
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
for (int n = 0; n < 10; n++) {
HAL_GPIO_TogglePin(GPIOB, LED1_Pin);
HAL_Delay(100);
}
}And mcu is blinking all the time. It never enters stop mode I think.
I tried everything. For example when I add before while loop line:
HAL_PWREx_EnableLowPowerRunMode();Program stops when it should, but never wakes up...
I don't know what is going on. Every sample on the Internet looks simple, but I can't reach stop mode. Maybe this mcu do this on other way?
I tried to use sample for nucleo board PWR_STOP_RTC but result is identical.
Please help me ;).
