MCUXpresso SDK Documentation

lpc_adc_burst#

Overview#

The lpc_adc_burst example shows how to use LPC ADC driver with the burst mode.

In this example, the sensor is used to created the input analog signal. When user type in any key from the keyboard, the burst mode is enabled. Then the conversion sequence A would be started automatically, till the burst would be disabled in conversion completed ISR.

Project Information#

1.what are ADC conversion sequences? A conversion sequence is a single pass through a series of A/D conversions performed on a selected set of A/D channels. Software can set-up two independent conversion sequences, either of which can be triggered by software or by a transition on one of the hardware triggers. Each sequence can be triggered by a different hardware trigger. One of these conversion sequences is referred to as the A sequence and the other as the B sequence. It is not necessary to employ both sequences. An optional single-step mode allows advancing through the channels of a sequence one at a time on each successive occurrence of a trigger. The user can select whether a trigger on the B sequence can interrupt an already-in-progress A sequence. The B sequence, however, can never be interrupted by an A trigger.

  1. How to use software-triggered conversion? There are two ways that software can trigger a conversion sequence:

    1. Start Bit: The first way to software-trigger an sequence is by setting the START bit in the corresponding SEQn_CTRL register. The response to this is identical to occurrence of a hardware trigger on that sequence. Specifically, one cycle of conversions through that conversion sequence will be immediately triggered except as indicated above.

    2. Burst Mode: The other way to initiate conversions is to set the BURST bit in the SEQn_CTRL register. As long as this bit is 1 the designated conversion sequence will be continuously and repetitively cycled through. Any new software or hardware trigger on this sequence will be ignored. (In this example, we use this way.)

  2. What kinds of interrupt do ADC have? There are four interrupts that can be generated by the ADC: • Conversion-Complete or Sequence-Complete interrupts for sequences A and B • Threshold-Compare Out-of-Range Interrupt • Data Overrun Interrupt Any of these interrupt requests may be individually enabled or disabled in the INTEN register.

Program Flow#

1.This example demonstrates how to configure the A sequences with burst mode, you can configure channel via “DEMO_ADC_SAMPLE_CHANNEL_NUMBER”.

2.Before configuration of the ADC begins, the ADC is put through a self-calibration cycle.

3.Enable the Conversion-Complete or Sequence-Complete interrupt for sequences A.

4.After ADC channels are assigned to each of the sequences, if the user enters any key via terminal, burst mode will start.

5.When the first conversion completes, the interrupt would be triggered. The ISR will stop the burst mode and print conversion result to terminal.

Supported Boards#

LPC845BREAKOUT
Hardware requirements
  • Micro USB cable

  • LPC845 Breakout board

  • Personal Computer

Board settings
  • ADC CH0 input signal 32(PIO0-7).

Prepare the demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port on the board.

  2. Open a serial terminal with the following settings:

    • 9600 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

Adjust the potentiometer and press any key from keyboard to trigger the conversion. The log below shows the output of the ADC burst driver example in the terminal window:

ADC burst example.
ADC Calibration Done.
Configuration Done.
gAdcResultInfoStruct.result        = 547
gAdcResultInfoStruct.channelNumber = 0

gAdcResultInfoStruct.result        = 549
gAdcResultInfoStruct.channelNumber = 0

gAdcResultInfoStruct.result        = 551
gAdcResultInfoStruct.channelNumber = 0

...
LPCXpresso51U68
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso51U68 board

  • Personal Computer

Board settings
  • ADC CH4 input signal J1-15(PIO1-1).

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J6) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 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

Press any key from keyboard and trigger the conversion. The log below shows example output of the ADC burst example in the terminal window:


ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 547
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 549
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 551
gAdcResultInfoStruct.channelNumber = 4

...

LPCXpresso54628
Hardware requirements
  • Micro USB cable

  • LPCXpresso54628 board

  • Personal Computer

Board settings
  • ADC CH4 input signal J12-2(PIO0-16).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) 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

Press any key from keyboard and trigger the conversion. The log below shows example output of the ADC burst example in the terminal window:


ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 672
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 679
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 671
gAdcResultInfoStruct.channelNumber = 4

...

LPCXpresso54S018
Hardware requirements
  • Micro USB cable

  • LPCXpresso54S018 board

  • Personal Computer

Board settings
  • ADC CH4 input signal J12-2(PIO0-16).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) 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. Launch the debugger in your IDE to begin running the demo.

Running the demo

This demo is an external flash plain load demo, ROM will copy image in external flash to SRAMX to run:

  1. Build the demo to generate a bin file. Note: If need to generate bin file using MCUXpresso IDE, below steps need to be followed: Set in example Properties->C/C++ Build->Settings->Build steps->Post-build steps->Edit enbable arm-none-eabi-objcopy -v -O binary “&{BuildArtifactFileName}” “&{BuildArtifactFileBaseName}.bin”

      This plainload example linked the vector table to 0x00000000, but program to external flash 0x10000000.
    
  2. Program the bin file to external on board flash via SEGGER J-FLASH Lite(V6.22 or higher):

    a. Open SEGGER J-FLASH Lite, select device LPC54S018.

    b. Click the ‘Erase Chip’ to erase the extrenal flash.(if can not success, press SW4 button and reset the board, and try to erase again)

    c. Select the bin data file, set the ‘.bin/Erase Start’ address to 0x10000000, then click ‘Program Device’ Note: Please use above way to program the binary file built by armgcc tool chain to external flash. For IAR, KEIL, MCUXpresso IDE, you can use the IDE tool to program the external flash.
    Press any key from keyboard and trigger the conversion. The log below shows example output of the ADC burst example in the terminal window:


ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 611
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 611
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 611
gAdcResultInfoStruct.channelNumber = 4

...

LPCXpresso54S018M
Hardware requirements
  • Micro USB cable

  • LPCXpresso54S018M board

  • Personal Computer

Board settings
  • ADC CH4 input signal J12-2(PIO0-16).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) 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. Launch the debugger in your IDE to begin running the demo.

Running the demo

This demo is an external flash plain load demo, ROM will copy image in external flash to SRAMX to run:

  1. Build the demo to generate a bin file. Note: If need to generate bin file using MCUXpresso IDE, below steps need to be followed: Set in example Properties->C/C++ Build->Settings->Build steps->Post-build steps->Edit enbable arm-none-eabi-objcopy -v -O binary “&{BuildArtifactFileName}” “&{BuildArtifactFileBaseName}.bin”

      This plainload example linked the vector table to 0x00000000, but program to external flash 0x10000000.
    
  2. Program the bin file to external on board flash via SEGGER J-FLASH Lite(V6.22 or higher):

    a. Open SEGGER J-FLASH Lite, select device LPC54S018M.

    b. Click the ‘Erase Chip’ to erase the extrenal flash.(if can not success, press SW4 button and reset the board, and try to erase again)

    c. Select the bin data file, set the ‘.bin/Erase Start’ address to 0x10000000, then click ‘Program Device’ Note: Please use above way to program the binary file built by armgcc tool chain to external flash. For IAR, KEIL, MCUXpresso IDE, you can use the IDE tool to program the external flash.
    Press any key from keyboard and trigger the conversion. The log below shows example output of the ADC burst example in the terminal window:


ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 611
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 611
gAdcResultInfoStruct.channelNumber = 4

gAdcResultInfoStruct.result        = 611
gAdcResultInfoStruct.channelNumber = 4

...

LPCXpresso802
Toolchain supported
  • IAR embedded Workbench 8.11.3

  • Keil MDK 5.23

  • MCUXpresso10.1.0

Hardware requirements
  • Micro USB cable

  • LPCXpresso54608 board

  • Personal Computer

Board settings
  • ADC CH8 input signal CN5-10(PIO0-15).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 9600 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

The log below shows the output of the hello world demo in the terminal window:

ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 547
gAdcResultInfoStruct.channelNumber = 8

gAdcResultInfoStruct.result        = 549
gAdcResultInfoStruct.channelNumber = 8

gAdcResultInfoStruct.result        = 551
gAdcResultInfoStruct.channelNumber = 8

...
Customization options
LPCXpresso804
Toolchain supported
  • IAR embedded Workbench 8.22.1

  • Keil MDK 5.24a

  • MCUXpresso10.2.0

Hardware requirements
  • Micro USB cable

  • LPCXpresso804 board

  • Personal Computer

Board settings
  • ADC CH7 input signal CN6-11(PIO0-10).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 9600 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

The log below shows the output of the hello world demo in the terminal window:

ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 547
gAdcResultInfoStruct.channelNumber = 7

gAdcResultInfoStruct.result        = 549
gAdcResultInfoStruct.channelNumber = 7

gAdcResultInfoStruct.result        = 551
gAdcResultInfoStruct.channelNumber = 7

...
Customization options
LPCXpresso824MAX
Toolchain supported
  • IAR embedded Workbench 8.11.3

  • Keil MDK 5.23

  • MCUXpresso10.1.0

Hardware requirements
  • Micro USB cable

  • LPCXpresso824MAX board

  • Personal Computer

Board settings
  • ADC CH1 input signal J5-1(PIO0-6).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J3) on the target board.

  2. Open a serial terminal with the following settings:

    • 9600 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

The log below shows the output of the hello world demo in the terminal window:

ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 547
gAdcResultInfoStruct.channelNumber = 1

gAdcResultInfoStruct.result        = 549
gAdcResultInfoStruct.channelNumber = 1

gAdcResultInfoStruct.result        = 551
gAdcResultInfoStruct.channelNumber = 1

...
Customization options
LPCXpresso845MAX
Toolchain supported
  • IAR embedded Workbench 8.11.3

  • Keil MDK 5.23

  • MCUXpresso10.1.0

Hardware requirements
  • Micro USB cable

  • LPCXpresso54608 board

  • Personal Computer

Board settings
  • ADC CH0 input signal J1-6(PIO0-7).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 9600 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

The log below shows the output of the hello world demo in the terminal window:

ADC burst example.
ADC Calibration Done.
Configuration Done.
ADC Full Range: XXXX
gAdcResultInfoStruct.result        = 547
gAdcResultInfoStruct.channelNumber = 0

gAdcResultInfoStruct.result        = 549
gAdcResultInfoStruct.channelNumber = 0

gAdcResultInfoStruct.result        = 551
gAdcResultInfoStruct.channelNumber = 0

...
Customization options
LPCXpresso860MAX
Toolchain supported
  • IAR embedded Workbench 8.11.3

  • Keil MDK 5.23

  • MCUXpresso10.1.0

Hardware requirements
  • Micro USB cable

  • LPCXpresso860MAX board

  • Personal Computer

Board settings
  • ADC CH0 input signal J6-12(PIO0-7).

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J4) on the target board.

  2. Open a serial terminal with the following settings:

    • 9600 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

Monitor the information on the debug console.

Expected Result

Press any key and print user channel’s result in serial terminal.