<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Comparator on FRDM-MCXN947 in MCX Microcontrollers</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2066405#M2743</link>
    <description>&lt;P&gt;More likely,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do I enable CMP on P0_22 (CMP1_IN2).&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    /* Configure LPCMP input channels. */
    LPCMP_SetInputChannels(CMP1, 2, 7);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably not correct, isn't it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Mar 2025 15:14:36 GMT</pubDate>
    <dc:creator>John_Adams</dc:creator>
    <dc:date>2025-03-21T15:14:36Z</dc:date>
    <item>
      <title>Comparator on FRDM-MCXN947</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2065821#M2731</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I would like to use a comparator in my project on FRDM-MCXN947, I want to trigger an interrupt in case the voltage at its input reaches 4.6V.&lt;/P&gt;&lt;P&gt;Is it possible to use the comparator on the FRDM-MCXN947 board in this way? If so, how is it necessary to set up the VREF, DAC and CMP modules in this case?&lt;/P&gt;&lt;P&gt;John Adams&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2025 20:22:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2065821#M2731</guid>
      <dc:creator>John_Adams</dc:creator>
      <dc:date>2025-03-20T20:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Comparator on FRDM-MCXN947</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2066405#M2743</link>
      <description>&lt;P&gt;More likely,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how do I enable CMP on P0_22 (CMP1_IN2).&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    /* Configure LPCMP input channels. */
    LPCMP_SetInputChannels(CMP1, 2, 7);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is probably not correct, isn't it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 15:14:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2066405#M2743</guid>
      <dc:creator>John_Adams</dc:creator>
      <dc:date>2025-03-21T15:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Comparator on FRDM-MCXN947</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2066856#M2759</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/243923"&gt;@John_Adams&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on your needs, i think you can refer to the lpcmp_interrupt demo in SDK.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Harry_Zhang_0-1742787818963.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/329425i2197A9FF1185AD28/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Harry_Zhang_0-1742787818963.png" alt="Harry_Zhang_0-1742787818963.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 03:44:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2066856#M2759</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-03-24T03:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: Comparator on FRDM-MCXN947</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2067324#M2797</link>
      <description>&lt;P&gt;Hi Harry,&lt;/P&gt;&lt;P&gt;I have already done that, I tried to run the demo with the original pin P1_0 (CMP0_IN0) and everything worked (i.e. the comparator reacted to changes in input voltage), but then I tried to change the pin on P0_22 where the channel CMP1_IN2 is output and adjusted the SW accordingly:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    const port_pin_config_t port0_22_pin_config = {/* Internal pull-up/down resistor is disabled */
                                                    kPORT_PullDisable,
                                                    /* Low internal pull resistor value is selected. */
                                                    kPORT_LowPullResistor,
                                                    /* Fast slew rate is configured */
                                                    kPORT_FastSlewRate,
                                                    /* Passive input filter is disabled */
                                                    kPORT_PassiveFilterDisable,
                                                    /* Open drain output is disabled */
                                                    kPORT_OpenDrainDisable,
                                                    /* Low drive strength is configured */
                                                    kPORT_LowDriveStrength,
                                                    /* Pin is configured as CMP1_IN1 */
                                                    kPORT_MuxAlt0,
                                                    /* Digital input disabled; it is required for analog functions */
                                                    kPORT_InputBufferDisable,
                                                    /* Digital input is not inverted */
                                                    kPORT_InputNormal,
                                                    /* Pin Control Register fields [15:0] are not locked */
                                                    kPORT_UnlockRegister};
    /* PORT0_22 is configured as CMP1_IN2 */
    PORT_SetPinConfig(PORT0, 22U, &amp;amp;port0_22_pin_config);&lt;/LI-CODE&gt;&lt;P&gt;And also changed the demo app accordingly, but CMP is not reacting:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#include "fsl_debug_console.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "board.h"
#include "fsl_lpcmp.h"

#include "fsl_vref.h"
#include "fsl_spc.h"
/*******************************************************************************
 * Definitions
 ******************************************************************************/
#define DEMO_LPCMP_BASE             CMP1
#define DEMO_LPCMP_USER_CHANNEL     1U
#define DEMO_LPCMP_DAC_CHANNEL      7U
#define DEMO_LPCMP_IRQ           	HSCMP1_IRQn
#define LED_INIT()                  LED_RED_INIT(LOGIC_LED_ON)
#define LED_ON()                    LED_RED_ON()
#define LED_OFF()                   LED_RED_OFF()
#define DEMO_LPCMP_IRQ_HANDLER_FUNC HSCMP1_IRQHandler
#define DEMO_VREF_BASE              VREF0
#define DEMO_SPC_BASE               SPC0

/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/

/*******************************************************************************
 * Code
 ******************************************************************************/
/*!
 * @brief Main function
 */
int main(void)
{
    lpcmp_config_t mLpcmpConfigStruct;
    lpcmp_dac_config_t mLpcmpDacConfigStruct;

    /* Initialize hardware. */
    vref_config_t vrefConfig;

    /* attach FRO 12M to FLEXCOMM4 (debug console) */
    CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1U);
    CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);

    /* attach FRO 12M to CMP1 */
    CLOCK_SetClkDiv(kCLOCK_DivCmp1FClk, 1U);
    CLOCK_AttachClk(kFRO12M_to_CMP1F);

    /* enable CMP1, CMP1_DAC and VREF. */
    SPC_EnableActiveModeAnalogModules(SPC0, kSPC_controlAllModules);

    VREF_GetDefaultConfig(&amp;amp;vrefConfig);
    /* Initialize the VREF mode. */
    VREF_Init(VREF0, &amp;amp;vrefConfig);
    /* Get a 1.8V reference voltage. */
    VREF_SetTrim21Val(VREF0, 8U);

    BOARD_InitPins();
    BOARD_InitBootClocks();
    BOARD_InitDebugConsole();

    PRINTF("LPCMP Interrupt Example.\r\n");

    /*
     *   k_LpcmpConfigStruct-&amp;gt;enableStopMode      = false;
     *   k_LpcmpConfigStruct-&amp;gt;enableOutputPin     = false;
     *   k_LpcmpConfigStruct-&amp;gt;useUnfilteredOutput = false;
     *   k_LpcmpConfigStruct-&amp;gt;enableInvertOutput  = false;
     *   k_LpcmpConfigStruct-&amp;gt;hysteresisMode      = kLPCMP_HysteresisLevel0;
     *   k_LpcmpConfigStruct-&amp;gt;powerMode           = kLPCMP_LowSpeedPowerMode;
     *   k_LpcmpConfigStruct-&amp;gt;functionalSourceClock = kLPCMP_FunctionalClockSource0;
     */
    LPCMP_GetDefaultConfig(&amp;amp;mLpcmpConfigStruct);
    /* Init the LPCMP module. */
    LPCMP_Init(CMP1, &amp;amp;mLpcmpConfigStruct);

    /* Configure the internal DAC to output half of reference voltage. */
    mLpcmpDacConfigStruct.enableLowPowerMode 		= false;
    mLpcmpDacConfigStruct.referenceVoltageSource 	= kLPCMP_VrefSourceVin2;
    mLpcmpDacConfigStruct.DACValue = 0xFF;
        //((LPCMP_DCR_DAC_DATA_MASK &amp;gt;&amp;gt; LPCMP_DCR_DAC_DATA_SHIFT) &amp;gt;&amp;gt; 1U); /* Half of reference voltage. */
    LPCMP_SetDACConfig(CMP1, &amp;amp;mLpcmpDacConfigStruct);

    /* Configure LPCMP input channels. */
    LPCMP_SetInputChannels(CMP1, 0x02, 0x07);

    /* Init the LED. */
    LED_INIT();

    /* Enable the interrupt. */
    EnableIRQ(HSCMP1_IRQn);
    LPCMP_EnableInterrupts(CMP1, kLPCMP_OutputRisingInterruptEnable | kLPCMP_OutputFallingInterruptEnable);

    while (1)
    {
    	;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so how come the comparator isn't responding?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;John Adams&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Mar 2025 14:21:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2067324#M2797</guid>
      <dc:creator>John_Adams</dc:creator>
      <dc:date>2025-03-24T14:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Comparator on FRDM-MCXN947</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2070920#M2825</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/243923"&gt;@John_Adams&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is&lt;SPAN&gt;&amp;nbsp;the voltage at P0_22&amp;nbsp; actually reaching the expected 4.6V?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If it does not work.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;You can try switching to another pin that supports CMP1.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 07:55:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/Comparator-on-FRDM-MCXN947/m-p/2070920#M2825</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-03-31T07:55:49Z</dc:date>
    </item>
  </channel>
</rss>

