MCUXpresso SDK Documentation

adc_selftest

adc_selftest#

Overview#

The SAR ADC self-test example shows the simplest way to use the SAR ADC driver.

In this example, three channels (channels 0, 1, and 2) are used to form a conversion chain, these three channels are executed in the normal conversion scan mode. The end-of-channel interrupt, pre-sample, DMA transfer, and watchdog features of each channel in the conversion chain are disabled. The self-test function is enabled, and the self-test watchdog threshold is used to check whether the self-test channel converted data is out of the range specified in the threshold, the watchdog timer is an additional check that monitors the sequence of the self-test algorithm implemented. It also verifies that the algorithm is completed within a safe period. The user should provide a voltage signal to each conversion channel. When running the project, When the execution of normal conversion ends, the terminal will print out the valid conversion data. When the conversion is more than 3 rounds and the current conversion chain is in the test channel conversion, abort the current conversion chain to make a watchdog sequence error, and the corresponding error information 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 selftest example.
 The channel 0 ADC conversion data is 4079.
 The channel 1 ADC conversion data is 3743.
 The channel 2 ADC conversion data is 2048.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3742.
 The channel 2 ADC conversion data is 2050.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4093.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4091.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2049.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 0 ADC conversion data is 4079.
 The channel 1 ADC conversion data is 3743.
 The channel 2 ADC conversion data is 2048.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3742.
 The channel 2 ADC conversion data is 2050.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4093.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4091.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2049.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 0 ADC conversion data is 4059.
 The channel 2 ADC conversion data is 1462.
 The channel 3 ADC conversion data is 691.
 The channel 0 ADC conversion data is 4060.
 The channel 2 ADC conversion data is 1463.
 The channel 3 ADC conversion data is 692.
 The channel 0 ADC conversion data is 4055.
 The channel 2 ADC conversion data is 1456.
 The channel 3 ADC conversion data is 697.
 The channel 0 ADC conversion data is 4058.
 The channel 2 ADC conversion data is 1461.
 The channel 3 ADC conversion data is 691.
 The channel 0 ADC conversion data is 4075.
 The channel 2 ADC conversion data is 1457.
 The channel 3 ADC conversion data is 695.
 The channel 0 ADC conversion data is 4050.
 The channel 2 ADC conversion data is 1461.
 The channel 3 ADC conversion data is 684.
 The channel 0 ADC conversion data is 4056.
 The channel 2 ADC conversion data is 1459.
 The channel 3 ADC conversion data is 694.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 34 ADC conversion data is 4084.
 The channel 2 ADC conversion data is 2047.
 The channel 3 ADC conversion data is 1365.
 The channel 34 ADC conversion data is 4086.
 The channel 2 ADC conversion data is 2049.
 The channel 3 ADC conversion data is 1363.
 The channel 34 ADC conversion data is 4083.
 The channel 2 ADC conversion data is 2046.
 The channel 3 ADC conversion data is 1366.
 The channel 34 ADC conversion data is 4085.
 The channel 2 ADC conversion data is 2048.
 The channel 3 ADC conversion data is 1364.
 The channel 34 ADC conversion data is 4084.
 The channel 2 ADC conversion data is 2047.
 The channel 3 ADC conversion data is 1365.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 0 ADC conversion data is 4059.
 The channel 2 ADC conversion data is 1462.
 The channel 3 ADC conversion data is 691.
 The channel 0 ADC conversion data is 4060.
 The channel 2 ADC conversion data is 1463.
 The channel 3 ADC conversion data is 692.
 The channel 0 ADC conversion data is 4055.
 The channel 2 ADC conversion data is 1456.
 The channel 3 ADC conversion data is 697.
 The channel 0 ADC conversion data is 4058.
 The channel 2 ADC conversion data is 1461.
 The channel 3 ADC conversion data is 691.
 The channel 0 ADC conversion data is 4075.
 The channel 2 ADC conversion data is 1457.
 The channel 3 ADC conversion data is 695.
 The channel 0 ADC conversion data is 4050.
 The channel 2 ADC conversion data is 1461.
 The channel 3 ADC conversion data is 684.
 The channel 0 ADC conversion data is 4056.
 The channel 2 ADC conversion data is 1459.
 The channel 3 ADC conversion data is 694.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 0 ADC conversion data is 4079.
 The channel 1 ADC conversion data is 3743.
 The channel 2 ADC conversion data is 2048.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3742.
 The channel 2 ADC conversion data is 2050.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4093.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4091.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2049.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 0 ADC conversion data is 4079.
 The channel 1 ADC conversion data is 3743.
 The channel 2 ADC conversion data is 2048.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3742.
 The channel 2 ADC conversion data is 2050.
 The channel 0 ADC conversion data is 4092.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4093.
 The channel 1 ADC conversion data is 3741.
 The channel 2 ADC conversion data is 2051.
 The channel 0 ADC conversion data is 4091.
 The channel 1 ADC conversion data is 3744.
 The channel 2 ADC conversion data is 2049.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.
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 selftest example.
 The channel 4 ADC conversion data is 4079.
 The channel 5 ADC conversion data is 3743.
 The channel 6 ADC conversion data is 2048.
 The channel 4 ADC conversion data is 4092.
 The channel 5 ADC conversion data is 3742.
 The channel 6 ADC conversion data is 2050.
 The channel 4 ADC conversion data is 4092.
 The channel 5 ADC conversion data is 3744.
 The channel 6 ADC conversion data is 2051.
 The channel 4 ADC conversion data is 4093.
 The channel 5 ADC conversion data is 3741.
 The channel 6 ADC conversion data is 2051.
 The channel 4 ADC conversion data is 4091.
 The channel 5 ADC conversion data is 3744.
 The channel 6 ADC conversion data is 2049.
 Self-test error occurred!
 ADC self-test watchdog sequence error occurred.