cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L433 Wakeup from Stop only on Wakeup Pin 2

Jonathan Frech
Associate II

In my application i desire to use the STOP2 Mode in a certain condition to save power. Currently i want to implement a wakeup through a "HIGH" on Wakeup Pin 2 of the MCU. Later i want to implement also a periodic wakeup per RTC. But for now, i want only wakeup by the Pin.

I implemented as follwowing:

void pwr_Stop(void){
 
 
	/* Suspend the Ticker */
	HAL_SuspendTick();
 
	/* Disable used wakeup source: PWR_WAKEUP_PIN1 */
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4);
 
	 HAL_PWR_DisableBkUpAccess();
	 __HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);
 
	/* Clear all related wakeup flags */
	__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
	/* Enable wakeup pin WKUP1 */
	HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH);
	/* Go to STOP2 Mode */
	HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
 
	////////////////
	// STOP MODE
	////////////////
 
	/* Resume the Ticker */
	HAL_ResumeTick();
 
 
	/* Reinit the clocks */
	sysClockConfig();
	sysClockEnable();
}

But the code does not work as excpeted. There is no wakeup from the pin, i checked the level with oscilloscope and it does change on signal input.

What could be the problem?

1 REPLY 1
Geoffrey1
Associate III

I think you might be making this more complicated that it needs to be. The Wakeup pin functionality is for Shutdown/Standby modes. For Stop mode you can just configure the Pin as an interrupt (or event) source. Here was some code I've used for STOP2 (not HAL, but it gives the idea). Elsewhere I enabled the events I wanted.

    
        DBGMCU->CR = 0;  // power down debugger interface
        MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_STOP2);
        SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
        __WFE();