This example project will show user how to use and configure the basic functionalities of WKPU + LPCMP.
------------------------------------------------------------------------------
* Test HW: S32K3X4EVB-T172 (SCH-53148 REV B2)
* MCU: S32K344
* IDE: S32DS3.5 & S32DS3.6
* SDK release: RTD 6.0.0
* Debugger: PE Micro
* Target: internal_FLASH
------------------------------------------------------------------------------
This example routine configures the WKPU & LPCMP units for wake-up. The S32K3XX's LPCMP can operate in trigger mode in both standby and run mode to continuously scan the input channels. RTC-API and LPCMP must be configured before entering into standby mode as per below shown figure:
See chapters 61.1.5 Comparator Trigger Mode & 61.1.6 Interaction with RTC API to cause wakeup from the S32K3XXRM (Rev. 12) for further information.
The register configurations before entering Standby mode for LPCMP trigger mode operation is the following:
- Configure RTC.APIVAL to set the period of the round robin operation.
- Execute standby mode entry.
The routine waits for SW5 to be pressed, then turns off the green LED, and enters Wkpu_EnterStandby() function which:
- Switches CORE_CLK to FIRC.
- Initializes the WKPU instance.
- Configures WKPU2 & WKPU42 (PTB19).
- Initializes and enables interrupt for LPCMP.
- Initializes RTC and sets the timer value (in RTCC - APIVAL) to 100ms.
- Starts timer.
- Enters standby (or fast standby).
While in standby, PTA0/1/2 are active; if a voltage higher than 2.5V is detected (ICU LPCMP DAC Voltage Level = 127), or SW6 is pressed MCU will wake-up.
After wake-up, MCU resets and polls for SW5 to be pressed again.
The RTC timer value can be changed with RTC_PERIOD_DELAY_MS(x) macro defined in Wkpu.h.
This example is provided as is with no guarantees and no support.