4.8.6.1 Wake-Up Inputs
Any level change on a PIOBUx, WKUP0 pin, or Security Module event (WKUP1), can trigger a wake-up. Wake-up is configured in the Mode register (SHDW_MR) and Wake-Up Inputs register (SHDW_WUIR). The transition detector can be programmed to detect either a positive or negative transition on any PIOBUx, WKUP0 pin. The detection can also be disabled. Programming is performed by enabling the bit Wake-up Input Enable (WKUPENx) and defining the Wake-up Input Type bit (WKUPTx) in the SHDW_WUIR.
Moreover, a debouncing circuit can be programmed for PIOBUx, WKUP0. The debouncing circuit filters pulses on PIOBUx, WKUP0 shorter than the programmed value in SHDW_MR.WKUPDBC. If the programmed level change is detected on a pin, a counter starts. When the counter reaches the value programmed in WKUPDBC, the SHDN pin is released. If a new input change is detected before the counter reaches the corresponding value, the counter is stopped and cleared. One counter is shared among all PIOBUx, WKUP0 inputs and all programmed level detection is merged into this counter. The bit WKUPISx of the Status register (SHDW_SR) reports the detection of the programmed events on PIOBUx, WKUP0 with a reset after the read of SHDW_SR (or SHDW_ISR). SHDW_SR must be cleared before asserting the SHDN pin, else the Backup mode will be exited immediately. SHDW_SR clearing can take up to two MD_SLCK clock cycles to be effective.
The same debouncing circuit can be used to generate an interrupt by configuring SHDW_IER/SHDW_IDR. The status of the WKUP0 pins can be read in SHDW_ISR. Status of the pins is cleared after the read of SHDW_SR or SHDW_ISR.
The SHDWC can be programmed to activate the wake-up using the RTC and RTT alarms or the Security Module event (detection of the rising edge event is synchronized with MD_SLCK). This is done by writing SHDW_MR.RTCWKEN or RTTWKEN, or by writing SHDW_WUIR.WKUPEN1 (Security Module event is connected on the WKUP1 wake-up input). When enabled, the detection of the RTC or RTT alarms or the Security Module event is reported in SHDW_SR.RTCWK, RTTWK or WKUPIS1. These bits are cleared after reading SHDW_SR. When using the RTC or RTT alarms or the Security Module event to wake up the system, the user must ensure that the RTC and RTT alarm status flags and the Security Module event flag are cleared before shutting down the system. Otherwise, no rising edge of the status flags may be detected and the wake-up fails