cmp_polling#
Overview#
The CMP polling Example shows the simplest way to use CMP driver and help user with a quick start.
In this example, user should indicate an input channel to capture a voltage signal (can be controlled by user) as the CMP’s positive channel input. On the negative side, the internal 6-bit DAC is used to generate the fixed voltage about half value of reference voltage.
When running the project, change the input voltage of user-defined channel, then the comparator’s output would change between logic one and zero when the user’s voltage crosses the internal DAC’s value. The endless loop in main() function would detect the logic value of comparator’s output, and change the LED. The LED would be turned on when the compare output is logic one, or turned off when zero.
Supported Boards#
EVKB-IMXRT1050
Hardware requirements
Mini/micro USB cable
EVKB-IMXRT1050 board
Personal Computer
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Note
This demo will access GPIO DR_SET/DR_CLEAR registers which is only available on A1 silicon (MIMXRT105xxxxxB).
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN0 (J23-5) connected to VCC =3.3V (J24-8): USER LED on - CMP1_IN0 (J23-5) connected to GND (J24-7): USER LED off
MIMXRT1060-EVKB
Hardware requirements
Mini/micro USB cable
MIMXRT1060-EVKB board
Personal Computer
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Note
This demo will access GPIO DR_SET/DR_CLEAR registers which is only available on A1 silicon (MIMXRT106xxxxxA).
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN0 (J33-5) connected to VCC =3.3V (J17-8): USER LED on - CMP1_IN0 (J33-5) connected to GND (J17-7): USER LED off
MIMXRT1060-EVKC
Hardware requirements
Mini/micro USB cable
MIMXRT1060-EVKC board
Personal Computer
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Note
This demo will access GPIO DR_SET/DR_CLEAR registers which is only available on A1 silicon (MIMXRT106xxxxxA).
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN0 (J33-5) connected to VCC =3.3V (J17-8): USER LED on - CMP1_IN0 (J33-5) connected to GND (J17-7): USER LED off
EVK-MIMXRT1020
Hardware requirements
Mini/micro USB cable
EVK-MIMXRT1020 board
Personal Computer
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN0 (J17-7) connected to VCC =3.3V (J19-8): USER LED on - CMP1_IN0 (J17-7) connected to GND (J19-7): USER LED off
Note: To debug in qspiflash, following steps are needed:
Select the flash target and compile.
Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J23.
Start debugging in IDE.
Keil: Click “Download (F8)” to program the image to qspiflash first then clicking “Start/Stop Debug Session (Ctrl+F5)” to start debugging.
MIMXRT1024-EVK
Hardware requirements
Mini/micro USB cable
MIMXRT1024-EVK board
Personal Computer
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN0 (J17-14) connected to VCC =3.3V (J19-16): USER LED on - CMP1_IN0 (J17-14) connected to GND (J19-14): USER LED off
Note: To debug in qspiflash, following steps are needed:
Select the flash target and compile.
Set the SW8: 1 off 2 off 3 on 4 off, then power on the board and connect USB cable to J23.
Start debugging in IDE.
Keil: Click “Download (F8)” to program the image to qspiflash first then clicking “Start/Stop Debug Session (Ctrl+F5)” to start debugging.
MIMXRT1040-EVK
Hardware requirements
Mini/micro USB cable
MIMXRT1040-EVK board
Personal Computer
Board settings
Remove jumper J80.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN1 (J17-9) connected to VCC =3.3V (J32-4): USER LED on - CMP1_IN1 (J17-9) connected to GND (J32-6): USER LED off
EVK-MIMXRT1064
Hardware requirements
Mini/micro USB cable
EVK-MIMXRT1064 board
Personal Computer
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.
Note
This demo will access GPIO DR_SET/DR_CLEAR registers which is only available on A1 silicon (MIMXRT106xxxxxA).
Running the demo
When the example runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP1_IN0 (J23-5) connected to VCC =3.3V (J24-8): USER LED on - CMP1_IN0 (J23-5) connected to GND (J24-7): USER LED off
FRDM-K22F
Hardware requirements
Mini/micro USB cable
FRDM-K22F board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal on PC for OpenSDA serial device with these settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the OpenSDA terminal like:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN0 (Jump J1-16) connected to VCC=3.3V(Jump J25-4): LED GREEN on - CMP0_IN0 (Jump J1-16) connected to GND(Jump J2-14): LED GREEN off
FRDM-K32L2A4S
Hardware requirements
Mini/micro USB cable
FRDM-K32L2A4S board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal on PC for OpenSDA serial device with these settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the OpenSDA terminal like:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN1 (Jump J1-11) connected to VCC=3.3V(Jump J3-8): LED RED on - CMP0_IN1 (Jump J1-11) connected to GND (Jump J2-14): LED RED off
FRDM-K32L2B
Hardware requirements
Mini/micro USB cable
FRDM-K32L2B board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal on PC for OpenSDA serial device with these settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the OpenSDA terminal like:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN0 (Jump J1-9) connected to VCC=3.3V (Jump J3-8): LED RED on - CMP0_IN0 (Jump J1-9) connected to GND (Jump J2-14): LED RED off
FRDM-MCXC041
Hardware requirements
Type-C USB cable
FRDM-MCXC041 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a Type-C USB cable between the PC host and the OpenSDA USB port on the board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal on PC for OpenSDA serial device with these settings:
9600 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the OpenSDA terminal like:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN0 (Jump J4-6) connected to VCC=3.3V(Jump J3-4): LED GREEN on - CMP0_IN0 (Jump J4-6) connected to GND(Jump J3-12): LED GREEN off
FRDM-MCXC242
Hardware requirements
USB-C cable
FRDM-MCXC242 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a mini USB cable between the PC host and the OpenSDA USB port on the board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal on PC for OpenSDA serial device with these settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the OpenSDA terminal like:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN0 (Jump J2-8) connected to VCC=3.3V (Jump J3-8): LED RED on - CMP0_IN0 (Jump J2-8) connected to GND (Jump J2-14): LED RED off
FRDM-MCXC444
Hardware requirements
Type-C USB cable
FRDM-MCXC444 board
Personal Computer
Board settings
No special is needed.
Prepare the Demo
Connect a type-c USB cable between the host PC and the MCU-Link USB port (J13) on the target board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the log would be seen on the terminal like:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN0 (Jump J1-9) connected to VCC=3.3V (Jump J3-8): LED RED on - CMP0_IN0 (Jump J1-9) connected to GND (Jump J2-14): LED RED off
TWR-KM34Z50MV3
Hardware requirements
Mini USB cable
TWR-KM34Z75M board
Personal Computer
Board settings
Turn on the third switch of S1(connect S1-3 to S1-18).
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED.
CMP0_IN1(J11_16) connected to VCC=3.3V: LED ORANGE ON
CMP0_IN1(J11_16) connected to GND: LED ORANGE OFF
TWR-KM34Z75M
Hardware requirements
Mini USB cable
TWR-KM34Z75M board
Personal Computer
Elevator Tower
Board settings
Connect J17.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN1 (Jump A63 on Elevator Tower) connected to VCC = 3.3V (Jump B3 on Elevator Tower): LED ORANGE on - CMP0_IN1 (Jump A63 on Elevator Tower) connected to GND ( Jump B2 on Elevator Tower): LED ORANGE off
TWR-KM35Z75M
Hardware requirements
Micro USB cable
TWR-KM35Z75M board
Personal Computer
Elevator Tower
Board settings
No special settings are required.
Prepare the Demo
Connect a USB cable between the host PC and the OpenSDA USB port on the target board.
Connect the analog signal source’s output to the input of used-defined comparator’s channel (defined as “DEMO_CMP_USER_CHANNEL” in source code.)
Open a serial terminal with the following settings:
115200 baud rate
8 data bits
No parity
One stop bit
No flow control
Download the program to the target board.
Reset the SoC and run the project.
Running the demo
When the demo runs successfully, the following message is displayed in the terminal:
CMP polling Example
Then change CMP analog input, and watch the change of LED. - CMP0_IN1 (Jump A63 on Elevator Tower) connected to VCC = 3.3V (Jump B3 on Elevator Tower): LED ORANGE on - CMP0_IN1 (Jump A63 on Elevator Tower) connected to GND ( Jump B2 on Elevator Tower): LED ORANGE off