Closed pushkin42 closed 2 years ago
Hi @pushkin42, I reproduce the behavior you described:
But this looks to be the normal behavior for this chip:
From hardware point of view, wakeup is active on Rising edge See Reference Manual RM0008 Rev 21 §5.4.2 Power control/status register (PWR_CSR):
Bit 8 EWUP: Enable WKUP pin
...
1: WKUP pin is used for wakeup from Standby mode and forced in input pull down
configuration (rising edge on WKUP pin wakes-up the system from Standby mode).
Also when default state of wakeup pin is HIGH, there is an extra wakeupevent
Note: An additional wakeup event is detected if the WKUP pin is enabled (by setting the EWUP bit)
when the WKUP pin level is already high.
This explains the immediate wakeup after the 1st shutdown.
I tested to use Pulldown on PA0 and button setting 3V3 when pressed. Its working fine: wakeup occurs only when button is pressed, in any case.
Have a next situation:
_INT0 is a function that simply sets flag.
My device goes shutdown and instantly reboots (power up again) after first shutdown. If I left power connected, two and over "shutdown" are normal - wakeup on PA0 as intended. If I remove power, wait for a while, connect power - device shutdowns and reboots after timeout instantly. Then, shutdown mode works fine (10 seconds after last FALLING edge on PA0).
PA0 connected to buttons that connected to gnd + pullup to VCC with 10kOhm resistors and capacitor 0.1uF