S32K312 : LPCMP Generating Run Time Interrupt RTD3.0.0 S32DS3.5
********************************************************************************************
* 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).
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 LPCMP module:
Modifications in IntCtrl_IP module:
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.
GPIO selection details:
How to test ?
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
Connect male jumper wire at PTC2
Thanks & regards,
Krishnakumar V