2018-10-15 07:37 AM
Hello,
I have a problem by using 2 wake up sources: RTC wake up and EXTI (on PWR_WAKEUP_PIN1).
Both of them works but a problem occurs when EXTI line (on PA0) is high when RTC event occurs. It make the CPU frozzen and nothing happen.
I found a clue on "STM32F40x and STM32F41x Errata sheet" (2.1.5) but I shall catch only EXTI on rising edge (not when pin high).
Here is my code:
//----------------------------------------------------------------------
//HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
__HAL_PWR_PVD_EXTI_DISABLE_EVENT();
__HAL_PWR_PVD_EXTI_DISABLE_IT();
__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
__HAL_RTC_WAKEUPTIMER_DISABLE(&hrtc);
/* Check and Clear the Wakeup flag if already set*/
if(__HAL_PWR_GET_FLAG(PWR_FLAG_WU) != RESET)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
}
/* Check and Clear the Standby flag if already set*/
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
{
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
}
/* Check PWR Exti flag */
if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
{
/* Clear PWR Exti pending bit */
__HAL_PWR_PVD_EXTI_CLEAR_FLAG();
}
__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); /* Allow wake up on rising edge + add pull down of 40ko on the pin */
/*DBP : Enable access to Backup domain */
HAL_PWR_EnableBkUpAccess();
hrtc.Lock = HAL_UNLOCKED;
/* RTC_WAKEUPCLOCK_CK_SPRE_16BITS: clock config2, counter-- each second, interrupt when counter reach 0 */
/* At the end, the device shall wake-up every 12h (43200 seconds) to do a check up */
if(HAL_RTCEx_SetWakeUpTimer_IT(&hrtc,TimeToSleep, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
hrtc.Lock = HAL_LOCKED;
/*DBP : Disable access to Backup domain */
HAL_PWR_DisableBkUpAccess();
__HAL_RTC_WAKEUPTIMER_ENABLE(&hrtc);
/* Enter to Standby mode */
HAL_PWR_EnterSTANDBYMode();
while (1)
{
}
//----------------------------------------------------------------------
If I use HAL_PWR_DisableWakeUpPin() in the first line, if PA0=1, the MCU always wakes up even if there is no rising edge.
How can I do to wake up with rising edge on PA0 and RTC without problem is PA0=1 when RTC wake up event occurs ?
Thanks for help.
Dams