cmp_1_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 VREF ladder 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 VREF’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#
LPCXpresso55S06
Hardware requirements
Mini/micro USB cable
LPCXpresso55S06 board
Personal Computer
Board settings
(pmux)J11-2(PIO0_0) connect to voltage source1. (nmux)J11-1(PIO0_9) connect to voltage source2.
Prepare the Demo
Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.
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 driver example
Then change CMP analog input, and the LED GREEN will show the output of the comparator. If the voltage of pmux channel is higher than the voltage of nmux channel, the GREEN LED on the board will be turned on. If the voltage of pmux channel is lower than the voltage of nmux channel, the GREEN LED on the board will be turned off.
LPCXpresso55S16
Hardware requirements
Mini/micro USB cable
LPCXpresso55S16 board
Personal Computer
Board settings
(pmux)J12-19(PIO0_18) connect to voltage source1. (nmux)J12-3(PIO1_14) connect to voltage source2. The jumper setting: Default jumpers configuration does not work, you will need to add JP20 and JP21 (JP22 optional for ADC use)
Prepare the Demo
Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.
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 driver example
Then change CMP analog input, and the LED GREEN will show the output of the comparator. If the voltage of pmux channel is higher than the voltage of nmux channel, the GREEN LED on the board will be turned on. If the voltage of pmux channel is lower than the voltage of nmux channel, the GREEN LED on the board will be turned off.
LPCXpresso55S28
Hardware requirements
Mini/micro USB cable
LPCXpresso55S28 board
Personal Computer
Board settings
Connect a DC voltage source to P19_6 (PIO0_0/CMP IN1)
Prepare the Demo
Note: MCUXpresso IDE project default debug console is semihost
Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.
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 driver example
Then change CMP analog input, and the LED GREEN will show the output of the comparator. - Let CMP IN1 voltage be higher than half of the VDDA, LED GREEN on. - Let CMP IN1 voltage be lower than half of the VDDA, LED GREEN off.
LPCXpresso55S36
Hardware requirements
Mini/micro USB cable
LPCXpresso55S36 board
Personal Computer
Board settings
(pmux)VREF connect to 1.6V (3.3V * 15 /31). (nmux)J44-21(PIO1_14).
Prepare the Demo
Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J1) on the board.
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 terminal like:
CMP polling driver example RED LED turn on.(pmux > nmux). RED LED turn off.(pmux < nmux).
LPCXpresso55S69
Hardware requirements
Mini/micro USB cable
LPCxpresso55s69 board
Personal Computer
Board settings
Connect a DC voltage source to P19_6 (PIO0_0/CMP IN1)
Prepare the Demo
Note: MCUXpresso IDE project default debug console is semihost
Connect a micro USB cable between the PC host and the OpenSDA USB port on the board.
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 driver example
Then change CMP analog input, and the LED GREEN will show the output of the comparator. - Let CMP IN1 voltage be higher than half of the VDDA, LED GREEN on. - Let CMP IN1 voltage be lower than half of the VDDA, LED GREEN off.