2020-05-12 01:48 PM
Hi everybody)
I have a problem with exiting after shutdown mode.
Entering code
if( (LL_PWR_IsActiveFlag_C1SB() == 0)
|| (LL_PWR_IsActiveFlag_C2SB() == 0)
)
{
/* Set the lowest low-power mode for CPU2: shutdown mode */
LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
}
HAL_RTCEx_BKUPWrite(&hrtc, 5, 0x0005);
HAL_PWREx_ClearWakeupFlag(PWR_FLAG_WU);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW);
HAL_SuspendTick();
HAL_PWREx_EnterSHUTDOWNMode();
My board have a button in PA0 with external pullup resistor.
When I press the button MCU exiting from shutdown mode, but my function
if (__HAL_PWR_GET_FLAG(PWR_FLAG_WUF1)) ...
return FALSE always.
My starting code:
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();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
MX_SPI1_Init();
MX_TIM1_Init();
MX_ADC1_Init();
MX_RTC_Init();
MX_RF_Init();
/* USER CODE BEGIN 2 */
if (__HAL_PWR_GET_FLAG(PWR_FLAG_WUF1))
{
reboot = true;
}
RTC is enable in shutdown, but don't use to wakeup. RTC tampers are disabled.
Solved! Go to Solution.
2020-05-13 06:09 AM
Per the reference manual:
A power-on reset occurs when exiting from Shutdown mode. All registers (except for the ones in the Backup domain) are reset after wakeup from Shutdown.
This includes the PWR_SR1 register. The WUF1 flag is only set after exiting standby modes.
That's how I read it, at least.
2020-05-12 06:21 PM
Your code as written checks __HAL_PWR_GET_FLAG before entering shutdown mode. Those bits will be clear after reset. Where in main() do you even enter shutdown?
2020-05-12 11:23 PM
But this is ST example. When I exiting from shutdown mode MCU is reseting (as NRST pin) and start program at the start your code
2020-05-13 06:09 AM
Per the reference manual:
A power-on reset occurs when exiting from Shutdown mode. All registers (except for the ones in the Backup domain) are reset after wakeup from Shutdown.
This includes the PWR_SR1 register. The WUF1 flag is only set after exiting standby modes.
That's how I read it, at least.
2020-05-13 08:21 AM
Ou, sorry, I misunderstood that phrase) Thanks