cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4A6 config WKUP pin to low level trigger fail

WWU.807
Associate II

Hi all,

I wan to use WKUP pin exit standby​ mode for low level trigger.

I set WKUP pin with low level polarity in HAL_PWR_EnableWakeUpPin() function and pull-up WKUP pin.

but the MCU alway wake-up when enter standby mode.

When set ​WKUP pin with high level polarity, the wakp-up function is working by standby mode.​

Could you give some suggestion ? thanks.

WKUP Pin config as blow Bold code:

void RUN_PWR_Mode_Init(RTC_HandleTypeDef *hrtc)

{

//-------Wake up Pin setting---------------------

 __HAL_RCC_PWR_CLK_ENABLE();//PWR APB1 clock enable

if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB)!=RESET)

{ // Clear the related wakeup pin flag

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

// Disable all used wakeup sources: Pin3(PE6)

HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);

}

//-------RTC Wake up setting---------------------

// IT_source =__HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(hrtc, RTC_FLAG_WUTF);

// Wtmr_flag =__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF);

if ((__HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE (hrtc, RTC_FLAG_WUTF) != 0U && __HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != 0U)

|| __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE (hrtc, RTC_FLAG_WUTF) == 0U)

{

//Disable RTC WakeUpTimer

HAL_RTCEx_DeactivateWakeUpTimer(hrtc);

//Clear RTC flag

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

}

}

void EnterStandbyPWR_Mode(RTC_HandleTypeDef *hrtc)

{

//-------Wake up Pin setting---------------------

// Disable all used wakeup sources: Pin3(PE6)

HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);

// Clear the related wakeup pin flag

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

// Re-enable all used wakeup sources: Pin3(PE6)

HAL_PWREx_EnableInternalWakeUpLine();

HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN3_LOW);

//-------RTC Wake up setting---------------------

// IT_source =__HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE(hrtc, RTC_FLAG_WUTF);

// Wtmr_flag =__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF);

if ((__HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE (hrtc, RTC_FLAG_WUTF) != 0U && __HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != 0U)

|| __HAL_RTC_WAKEUPTIMER_GET_IT_SOURCE (hrtc, RTC_FLAG_WUTF) == 0U)

{

//Set StnadbyTime

PWRST.StandbyTime_Sec = 30;

//set RTC WakeUpTimer

if (HAL_RTCEx_SetWakeUpTimer_IT(hrtc, PWRST.StandbyTime_Sec, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK)

{

Error_Handler();

}

}

/* Request to enter STANDBY mode */

HAL_PWR_EnterSTANDBYMode();

}

3 REPLIES 3
Mohamed Aymen HZAMI
ST Employee

Hello @WWU.807​,

Please try this sequence :

Clear the wake up flag after enabling the wake up pin

  1. HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN3_LOW);
  2. __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

Mohamed Aymen.

JGuir.1
Associate II

Hello WWU.807,

I would like to know if you have found a solution to your problem because I have exactly the same problem with an STM32WB15!.

Thanks,

Joël

Piranha
Chief II

https://community.st.com/s/question/0D53W00001bnh8dSAA/how-to-enter-standby-or-shutdown-mode-on-stm32

The particular issue of the original topic is the issue 1 in my article.

@JGuir.1​, Mohamed's post provides the same information, but you didn't read it...

EDIT: C'mon do you read anything at all?

https://community.st.com/s/question/0D53W00001t4YMKSA2/stm32wb15-wakeup-pin-polarity-issue