MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
CMP Peripheral and Driver Overview

Peripheral features and how this peripheral works

Peripheral features

The comparator (CMP) module provides below features:

How this peripheral works

Once the CMP is configured and enabled, the comparator will compare two analog input voltages applied to INP and INM. CMPO is high when the non-inverting input is greater than the inverting input, and is low when the non-inverting input is less than the inverting input.

The output of the comparator will be controlled by the window function or external sampling signal or internal filter per different configurations.

If there is a change on the COUT,

  1. The CMP will generate a interrupt if the interrupt is enabled
  2. The CMP will generate a DMA transfer request if the DMA is enabled

How this driver is designed to make this peripheral works

The CMP driver designed several configuration structures and function groups to help user on enable the module .

How to use this driver

Typical Use Cases

  1. Work mode kCMP_WorkModeWindowEnabledAndNoExternalSample, the window function is enabled and external sampling mode is disabled
    * config->ePlusInput = xxx
    * config->eMinusInput = xxx
    * config->eWindowOutput = kCMP_WindowOuputLastLatchedValue
    * CMP_Init(base, config)
    * CMP_Enable(base)
    *
  2. Work mode kCMP_WorkModeWindowEnabledAndNoExternalSample, the window function is enabled and external sampling mode is disabled, internal filter is enabled
    * config->ePlusInput = xxx
    * config->eMinusInput = xxx
    * config->eWindowOutput = kCMP_WindowOuputLastLatchedValue
    * config->eFilterCount = kCMP_FilterCount2
    * config->u8FilterPeriod = xxx
    * CMP_Init(base, config)
    * CMP_Enable(base)
    *
  3. Work mode kCMP_WorkModeWindowBypassAndExternalSample, the window function is bypassed and external sampling mode is enabled.
    * config->ePlusInput = xxx
    * config->eMinusInput = xxx
    * config->eExternalSampleCount = kCMP_ExternalSampleCount1
    *
    * CMP_Init(base, config)
    * CMP_Enable(base)
    *
  4. Work mode kCMP_WorkModeWindowBypassAndNoExternalSample, the window function is disabled and external sampling mode is disabled bus clock.
    * config->ePlusInput = xxx
    * config->eMinusInput = xxx
    *
    * config->bCMPEnable = true
    *
    * CMP_Init(base, config)
    *
  5. Work mode kCMP_WorkModeWindowBypassAndNoExternalSample, the window function is disabled and external sampling mode is disabled, internal filter is enabled
    * config->ePlusInput = xxx
    * config->eMinusInput = xxx
    * config->eFilterCount = kCMP_FilterCount2
    * config->u8FilterPeriod = xxx
    *
    * config->bCMPEnable = true
    *
    * CMP_Init(base, config)
    *