cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in HAL_PWR_EnableWakeUpPin()

Hiroshi Sakurai
Associate II
Posted on November 01, 2016 at 10:27

Currently, HAL_PWR_EnableWakeUpPin() enables wakeup-pin before it sets polarity. The calling order should be reversed.

void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity)

{

  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinPolarity));

  

  /* Enable wake-up pin */

  SET_BIT(PWR->CSR2, (PWR_EWUP_MASK & WakeUpPinPolarity));

  /* Specifies the Wake-Up pin polarity for the event detection

    (rising or falling edge) */

  MODIFY_REG(PWR->CR2, (PWR_EWUP_MASK & WakeUpPinPolarity), (WakeUpPinPolarity >> 0x06));

}

When I tried to set a wakeup pin as falling edge by calling HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW), wakeup flag was set after MODIFY_REG is called. I think it's because the default polarity is rising edge and changing the polarity while wakeup is enabled sets a wakeup flag.

It should call MODIFY_REG before SET_BIT. 

The version I'm using is:

  * @file    stm32f7xx_hal_pwr.c

  * @author  MCD Application Team

  * @version V1.1.1

  * @date    01-July-2016

  * @brief   PWR HAL module driver.

Workaround is calling __HAL_PWR_CLEAR_WAKEUP_FLAG() after HAL_PWR_EnableWakeUpPin().
1 REPLY 1
Walid FTITI_O
Senior II
Posted on November 02, 2016 at 18:24

Hi sakurai.hiroshi, 

I report this internally for investigation. It is not related to the HAL_PWR_EnableWakeUpPin() function bit to the definedvalue PWR_WAKEUP_PINX_LOW to be written in the register.

-Hannibal-