S32K312 : LPCMP Generating Run Time Interrupt RTD3.0.0 S32DS3.5

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K312 : LPCMP Generating Run Time Interrupt RTD3.0.0 S32DS3.5

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 usedDAC 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 PMUXGreen 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:

LPCMP_ModulesUsed.png       

 

Modifications in LPCMP module:

LPCMP_CMP_modifications.png

LPCMP_CMP_Modifications2.png

 

Modifications in IntCtrl_IP module:

LPCMP_INTCtrl_IP_Modifcations.png

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.

LPCMP_IRQHandler_codeChange.png

GPIO selection details:

LPCMP_PinSelectionDetails.png

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 PTC2Connect male jumper wire at PTC2

Thanks & regards,
Krishnakumar V

Attachments
No ratings
Version history
Last update:
‎02-26-2025 01:53 AM
Updated by: