MCUXpresso SDK Documentation

adc_polling

adc_polling#

Overview#

The SAR ADC polling example shows the simplest way to use the SAR ADC driver.

In this example, three channels (channel 0, 1, and 2) are used to form a conversion chain, these three channels are executed in the normal conversion one-shot mode. The end-of-channel interrupt, pre-sample, DMA transfer, and watchdog features of each channel in the conversion chain are disabled. The user should provide a voltage signal to each conversion channel. When running the project, type any key into the debug console to get these three channels’ conversion result, if the result of the channel conversion is valid, it will be printed to the debug console.

Supported Boards#

IMX952LPD5EVK-19
Hardware requirements
  • Personal Computer

  • IMX952LPD5BB-19-REV-A EVK board

  • 12V~20V power supply

  • J-Link Debug Probe

  • Micro USB cable

Board settings

Use the jumper to connect the J20 1-2, 3-4, 5-6

Please note this application can’t support running with Linux BSP!
Prepare the Demo
  1. Connect the 12V~20V power supply and J-Link Debug Probe to the board, and switch SW4 to power on the board.

  2. Connect a micro USB cable between the host PC and the J31 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3740.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4085.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3739.
 The channel 2 ADC conversion data is 2049.
IMX95LPD5EVK-19
Hardware requirements
  • Personal Computer

  • IMX95LPD5BB-19-REV-A EVK board

  • 12V~20V power supply

  • J-Link Debug Probe

  • Micro USB cable

Board settings

Use the jumper to connect the J20 1-2, 3-4, 5-6

Please note this application can’t support running with Linux BSP!

Prepare the Demo
  1. Connect the 12V~20V power supply and J-Link Debug Probe to the board, and switch SW4 to power on the board.

  2. Connect a micro USB cable between the host PC and the J31 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3740.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4085.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3739.
 The channel 2 ADC conversion data is 2049.
FRDM-IMX95
Hardware requirements
  • Personal Computer

  • IMX95LPD5BB-19-REV-A EVK board

  • 12V~20V power supply

  • J-Link Debug Probe

  • Micro USB cable

Board settings

Connect J9-5 to J2-3

Please note this application can’t support running with Linux BSP!

Prepare the Demo
  1. Connect the 12V~20V power supply and J-Link Debug Probe to the board, and switch SW4 to power on the board.

  2. Connect a micro USB cable between the host PC and the J31 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4063.
 The channel 2 ADC conversion data is 1379.
 The channel 3 ADC conversion data is 682.
FRDM-IMX952
Hardware requirements
  • Personal Computer

  • IMX952LPD5BB-19-REV-A EVK board

  • 12V~20V power supply

  • J-Link Debug Probe

  • Micro USB cable

Board settings

Populate a 100k resistor at R213, and a 200k resistor at R215

Please note this application can’t support running with Linux BSP!
Prepare the Demo
  1. Connect the 12V~20V power supply and J-Link Debug Probe to the board, and switch SW4 to power on the board.

  2. Connect a micro USB cable between the host PC and the J31 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 34 ADC conversion data is 4084.
 The channel 2 ADC conversion data is 2047.
 The channel 3 ADC conversion data is 1365.
FRDM-IMX937
Hardware requirements
  • Personal Computer

  • IMX937LPD5BB-19-REV-A EVK board

  • 12V~20V power supply

  • J-Link Debug Probe

  • Micro USB cable

Board settings

Connect J9-5 to J2-3

Please note this application can’t support running with Linux BSP!

Prepare the Demo
  1. Connect the 12V~20V power supply and J-Link Debug Probe to the board, and switch SW4 to power on the board.

  2. Connect a micro USB cable between the host PC and the J31 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4063.
 The channel 2 ADC conversion data is 1379.
 The channel 3 ADC conversion data is 682.
MCIMX93-EVK
Hardware requirements
  • USB Type-C cable

  • MCIMX93-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

Board settings
  • Connect ADC channel0 (ADC_CH_00) to voltage supply which is 1.8v.

  • Connect ADC channel1 (ADC_CH_01) to voltage supply which is 1.65v.

  • Connect ADC channel2 (ADC_CH_02) to voltage supply which is 0.9v.

Please note this application can’t support running with Linux BSP!
Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3740.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4085.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3739.
 The channel 2 ADC conversion data is 2049.
MCIMX93W-EVK
Hardware requirements
  • USB Type-C cable

  • MCIMX93W-EVK board

  • J-Link Debug Probe

  • 12V~20V power supply

  • Personal Computer

Board settings
  • Connect ADC channel0 (ADC_CH_00) to voltage supply which is 1.8v.

  • Connect ADC channel1 (ADC_CH_01) to voltage supply which is 1.65v.

  • Connect ADC channel2 (ADC_CH_02) to voltage supply which is 0.9v.

Please note this application can’t support running with Linux BSP!
Prepare the Demo
  1. Connect 12V~20V power supply and J-Link Debug Probe to the board, switch SW301 to power on the board.

  2. Connect a USB Type-C cable between the host PC and the J1401 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3740.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4085.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 0 ADC conversion data is 4084.
 The channel 1 ADC conversion data is 3739.
 The channel 2 ADC conversion data is 2049.
IMX943-EVK
Hardware requirements
  • Personal Computer

  • IMX943EVK board

  • 12V~20V power supply

  • J-Link Debug Probe

  • Micro USB cable

Board settings

Set 0~3.3V voltage input to below ADC channels by using DC power supply ADC channel 4(J9-2) ADC channel 5(J9-5) ADC channel 6(J9-8)

Please note this application can’t support running with Linux BSP!
Prepare the Demo
  1. Connect the 12V~20V power supply and J-Link Debug Probe to the board, and switch SW4 to power on the board.

  2. Connect a micro USB cable between the host PC and the J31 USB port on the target board.

  3. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  4. Download the program to the target board.

  5. Either re-power up your board or launch the debugger in your IDE to begin running the example.

Running the demo

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 4 ADC conversion data is 4084.
 The channel 5 ADC conversion data is 3740.
 The channel 6 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 4 ADC conversion data is 4085.
 The channel 5 ADC conversion data is 3741.
 The channel 6 ADC conversion data is 2049.
 Please press any key to get the conversion result.
 The channel 4 ADC conversion data is 4084.
 The channel 5 ADC conversion data is 3739.
 The channel 6 ADC conversion data is 2049.
FRDM-MCXE31B
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXE31B board

  • Personal Computer

Board settings

Connect the J4-8 to a voltage source.

Prepare the Demo
  1. Connect a type-c USB cable between the host PC and the MCU-Link USB port (J13) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

This demo will measure the Bandgap via ADC0 channel 48, measure VREFH via ADC0 channel 55, measure user defined voltage via channel 5. In this demo, the user defined voltage is 1.67v.

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 48 ADC conversion data is 12037.
 The channel 55 ADC conversion data is 32767.
 The channel 5 ADC conversion data is 16696.
FRDM-MCXE32B
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXE32B board

  • Personal Computer

Board settings

Connect the J4-8 to a voltage source.

Prepare the Demo
  1. Connect a type-c USB cable between the host PC and the MCU-Link USB port (J13) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

This demo will measure the Bandgap via ADC0 channel 48, measure VREFH via ADC0 channel 55, measure user defined voltage via channel 5. In this demo, the user defined voltage is 1.67v.

When the example runs successfully, you will see similar information from the terminal shown below.

 ADC polling example.
 Please press any key to get the conversion result.
 The channel 48 ADC conversion data is 12037.
 The channel 55 ADC conversion data is 32767.
 The channel 5 ADC conversion data is 16696.