Using DMA to scan the ADC channels in FreeRTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using DMA to scan the ADC channels in FreeRTOS

Using DMA to scan the ADC channels in FreeRTOS

A reference design using DMA to scan ADC0 and ADC1 channels within FreeRTOS task, trigger interrupt when one scan completes.

Hardware

FRDM-K22F (https://www.nxp.com/design/development-boards/freedom-development-boards/mcu-boards/nxp-freedom-deve...).

IDE

IAR8.4.2.

SDK

The code is based on SDK2.2 (or later version) which can be built and downloaded on nxp website https://MCUXpresso.nxp.com 

Function Description

K22F MCU support 2 ADC modules, they are configured to do ADC channel scanning at same time. The ADC channels are defined in ADC0_Channel_List and ADC1_Channel_List, and the ADC conversion result will be saved in ADC0_Result and ADC1_Result. DMA and DMA MUX are configured to load the ADC channels and save the ADC conversion result.


The DMA interrupt will be triggered when the scanning is completed.
The ADC scanning is re-started when current loop is completed. Customer can processing the ADC result.

To demonstrate multi-tasks, there are the other two tasks was implemented:

I2C task and UART2 task.  The sensor on the FRDM-K22F board will be read in I2C task.
Uart2 task recieve the data from UART2 and send the data back.

Running the Demo
============================================================
1) Open the IAR project
2) Build the project and download the code to FRDM-K22F board
3) Running the code
4) Add the arrary ADC0_result, and ADC1_Result to living watch window, the ADC result data will be refreshed.
Note: Some ADC inputs are floating, so the conversion result may have great changes.

5) Open the terminal, open the serial port, and configure it with 115200/8bit/1 stop bit, the senor data will be printed in the terminal window

Attachments
No ratings
Version history
Last update:
‎09-23-2020 07:35 AM
Updated by: