chap11/adc7scan1_dma.c File Reference
#include "pic24_all.h"
#include "stdio.h"
Go to the source code of this file.
Detailed Description
Performs a basic config of the ADC and samples seven channels sequentially with automatic channel scanning. ADC values are 10-bit results. Samples are obtained continuously, and DMA is used to write a memory buffer. The DMA is done using Scatter/Gather mode, with a block size determined by CONVERSIONS_PER_INPUT. For block size = 1 and scatter/gather mode, this means that AN0 result is written to DMA buffer[0], AN1 result to the DMA buffer[1], AN15 to DMA buffer[15], etc. Uses DMA completion interrupts to get values from the DMA memory buffer. The DMA mode for Scatter/Gather mode should be DMA_AMODE_PERIPHERAL_INDIRECT (peripheral indirect) Main routine fetches the "latest" values from memory. This code assumes a maximum of 16 ANx inputs. For block size > 1, the main code averages the values for a given channel. Compare the main averaging code with 'adc7scan1_dma2.c' to see the difference in how results are stored in the buffer for 'ordered' mode versus 'scatter/gather'.
Conversion results are printed to screen to match adc2pots1.c project (HEX values and voltages are printed.) This is only for PIC24 CPUs with DMA.
Definition in file adc7scan1_dma.c.
Function Documentation