********************************************************************************************
* Test HW: S32K312 EVB-Q172
* MCU: S32K312
* Compiler: S32DS3.5
* SDK release: RTD 3.0.0
* Debugger: PE Micro
* Target: Internal_FLASH
********************************************************************************************
The objective of this demo application is to generate an interrupt by comparing DAC internal reference voltage against any analog input which is connected in analog mux input channels(IN0 : IN7) and wakes the MCU from sleep(standby) mode.
In this demo code,
1)LPCMP0 is used - DAC output is given to comparator minus (INM) and
AIN2 is given to comparator plus (INP).
From S32K3 RM, highlighted the channels used for reference.
Green color represents DAC, Pink color represents AIN2 which is selected from PMUX
2) From S32K RM,
"Compares two analog input voltages applied to INP and INM,
COUT_RAW is high when the INP input voltage is greater than the INM input voltage,
COUT_RAW is low when the INP input voltage is less than the INM input voltage"
So in this demo code,
RED LED is ON , if AIN2 Voltage > DAC Internal reference voltage(COUT is HIGH)
GREEN LED is ON, If AIN2 Voltage < DAC Internal reference voltage (COUT is LOW)
MODULES USED:
MODIFICATIONS IN INTCTRL_IP MODULE:
MODIFICATIONS IN WKPU MODULE:
From S32K3 RM, Analog comparator has used Channel 2 for wakeup.
Modifications in the "Cmp_Ip_IrqHandler" function in "Cmp_IP.c" source file:
NOTE:
Not sure how it got missed or from where to get COUT status, so added manually to get COUT status from CSR register in the Cmp_Ip_Irqhandler once code generation is completed.
PIN SELECTION DETAILS:
a) Connect jumper wire at the PTC2 in the EVB as highlighted in EVB below.
b) RED LED ON -> Jumper wire connects to 5V
GREEN LED ON-> Jumper wire connects to GND
c) MCU enters STANDBY once SW5 is pressed and it wakes up if the jumper wire is disconnected from either 5V or GND.
NOTE:
In this demo, since jumper wire is used instead of button/ADC, due to high impendence state, LED will be toggling if jumper wire is not connected to GND/5V.
Connect male jumper wire at PTC2
Thanks & regards,
Krishnakumar V