2020-05-08 05:57 AM
Hi,
I can enter STOP Mode 2 while not using the ST Sequence (UTIL_SEQ). I disable interruptions, clear the pending ones and just let the RTC to wake me up.
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0xFFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV8);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
UTIL_LPM_EnterLowPower( );
HAL_ResumeTick();
SYSCLKConfig_STOP(); //restore clocks and so on...
But when I do the same in void UTIL_SEQ_Idle( void ) I get wake up inmediatly...
I tried to disable every single interrupt (I'm using GPIOS interrupts, RTC, Alarms, UART, Timer2 and the BLE stack for P2P_Server). Who is waking me up from sleep?
void UTIL_SEQ_Idle( void )
{
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
UTIL_LPM_SetStopMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE);
UTIL_LPM_SetStopMode(1U << CFG_LPM_APP_BLE, UTIL_LPM_ENABLE);
EXTI->PR1 = 0xFFFFFFFF;
EXTI->PR2 = 0xFFFFFFFF;
RTC_WAKEUPCLOCK_CK_SPRE_16BITS);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
HAL_SuspendTick();
HAL_NVIC_DisableIRQ(WWDG_IRQn);
HAL_NVIC_DisableIRQ(EXTI0_IRQn);
HAL_NVIC_DisableIRQ(EXTI1_IRQn);
HAL_NVIC_DisableIRQ(EXTI2_IRQn);
HAL_NVIC_DisableIRQ(DMA1_Channel1_IRQn);
HAL_NVIC_DisableIRQ(DMA1_Channel2_IRQn);
HAL_NVIC_DisableIRQ(TIM2_IRQn);
HAL_NVIC_DisableIRQ(EXTI15_10_IRQn);
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_DisableIRQ(HSEM_IRQn);
HAL_NVIC_DisableIRQ(USART1_IRQn);
HAL_NVIC_DisableIRQ(TIM1_UP_TIM16_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_DisableIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_ClearPendingIRQ(WWDG_IRQn);
HAL_NVIC_ClearPendingIRQ(RTC_WKUP_IRQn);
HAL_NVIC_ClearPendingIRQ(EXTI0_IRQn);
HAL_NVIC_ClearPendingIRQ(EXTI1_IRQn);
HAL_NVIC_ClearPendingIRQ(EXTI2_IRQn);
HAL_NVIC_ClearPendingIRQ(DMA1_Channel1_IRQn);
HAL_NVIC_ClearPendingIRQ(DMA1_Channel2_IRQn);
HAL_NVIC_ClearPendingIRQ(TIM2_IRQn);
HAL_NVIC_ClearPendingIRQ(EXTI15_10_IRQn);
HAL_NVIC_ClearPendingIRQ(RTC_Alarm_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_ClearPendingIRQ(HSEM_IRQn);
HAL_NVIC_ClearPendingIRQ(USART1_IRQn);
HAL_NVIC_ClearPendingIRQ(TIM1_UP_TIM16_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_RX_IRQn);
HAL_NVIC_ClearPendingIRQ(IPCC_C1_TX_IRQn);
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0xFFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV8);
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
UTIL_LPM_EnterLowPower( );
HAL_ResumeTick();
SYSCLKConfig_STOP();
}
2020-05-18 03:31 AM
Please, any input on this?
2020-05-20 01:02 AM
Tried to stop advertising BLE using
aci_gap_set_non_discoverable();
But I wake up in the same way.
2020-05-21 12:12 AM
Surprisingly the file Src/stm32_lpm_if.c was empty, function signatures were generated but anything inside the function body.
It might be a CubeMX bug when generating a Makefile project.
Last question, it is possible to left BLE discoverable while the other CPU is in STOP MODE 2?