zephyr/samples/sensor/mcux_lpcmp
Peter Wang 28d9a458dc boards: frdm_mcxa166, frdm_mcxa276: add lpcmp support
1. enable sensor/nxp,lpcmp support
2. verified samples/sensor/mcux_lpcmp
3. update the mcux_lpcmp to support different port

Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
2025-07-19 10:10:07 +02:00
..
boards boards: frdm_mcxa166, frdm_mcxa276: add lpcmp support 2025-07-19 10:10:07 +02:00
src boards: frdm_mcxa166, frdm_mcxa276: add lpcmp support 2025-07-19 10:10:07 +02:00
CMakeLists.txt
Kconfig boards: frdm_mcxa166, frdm_mcxa276: add lpcmp support 2025-07-19 10:10:07 +02:00
prj.conf
README.rst boards: frdm_mcxa166, frdm_mcxa276: add lpcmp support 2025-07-19 10:10:07 +02:00
sample.yaml boards: frdm_mcxa166, frdm_mcxa276: add lpcmp support 2025-07-19 10:10:07 +02:00

.. zephyr:code-sample:: mcux_lpcmp
   :name: NXP MCUX Low-power Analog Comparator (LPCMP)
   :relevant-api: sensor_interface

   Get analog comparator data from an NXP MCUX Low-power Analog Comparator (LPCMP).

Overview
********

This sample show how to use the NXP MCUX Low-power Analog Comparator (LPCMP) driver.

In this application, the negative input port of the LPCMP is set with
:kconfig:option:`CONFIG_LPCMP_NEGATIVE_PORT` which means the input voltage comes
from the LPCMP internal DAC. The reference voltage of the DAC is set to 0 (check
the reference manual to confirm the voltage source for your specific chip). The
output voltage of the DAC equals (VREF/256)*(data+1), where data is set through
the attribute ``SENSOR_ATTR_MCUX_LPCMP_DAC_OUTPUT_VOLTAGE``. The positive input
port is set with :kconfig:option:`CONFIG_LPCMP_POSITIVE_PORT`. Check the reference
manual and board schematic to confirm which specific port is used. You can connect
an external voltage to that port and change the input voltage to see the output
change of the LPCMP.

The output value of the LPCMP is reported on the console.

Building and Running
********************

Building and Running for NXP FRDM-MCXN947
=========================================
Build the application for the :zephyr:board:`frdm_mcxn947` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-17.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxn947//cpu0
   :goals: build flash
   :compact:

Building and Running for NXP FRDM-MCXN236
=========================================
Build the application for the :zephyr:board:`frdm_mcxn236` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-8.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxn236
   :goals: build flash
   :compact:

Building and Running for NXP FRDM-MCXA156
=========================================
Build the application for the :zephyr:board:`frdm_mcxa156` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-9.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxa156
   :goals: build flash
   :compact:

Building and Running for NXP FRDM-MCXA153
=========================================
Build the application for the :zephyr:board:`frdm_mcxa153` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-9.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxa153
   :goals: build flash
   :compact:

Building and Running for NXP FRDM-MCXA166
=========================================
Build the application for the :zephyr:board:`frdm_mcxa166` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-17.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxa166
   :goals: build flash
   :compact:

Building and Running for NXP FRDM-MCXA276
=========================================
Build the application for the :zephyr:board:`frdm_mcxa276` board, and adjust the
LPCMP positive input port voltage by changing the voltage input to J2-17.

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/mcux_lpcmp
   :board: frdm_mcxa276
   :goals: build flash
   :compact: