PIC24 Support Libraries
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
adc7scan1_dma_conv_order.c File Reference
#include "pic24_all.h"
#include "stdio.h"

Go to the source code of this file.

Functions

uint8_t configDMA_ADC (uint16_t u16_ch0ScanMask, uint8_t u8_autoSampleTime, uint8_t u8_use12bit, uint8_t u8_useScatterGather, uint8_t u8_dmaLocsPerInput)
 

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 Ordered mode, with a block size determined by CONVERSIONS_PER_INPUT. For a block size = 1 and ordered mode, this means that results are written to the DMA buffer in the order in which the conversion is done, in this case: AN0 result is written to DMA buffer[0] AN1 result to the DMA buffer[1], AN4 result to the DMA buffer[2], AN5 result to the DMA buffer[3], etc. Uses DMA completion interrupts to get values from the DMA memory buffer. The DMA mode for Ordered mode should be DMA_AMODE_REGISTER_POSTINC (register mode, post increment) 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_dma1.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_conv_order.c.

Function Documentation

uint8_t configDMA_ADC ( uint16_t  u16_ch0ScanMask,
uint8_t  u8_autoSampleTime,
uint8_t  u8_use12bit,
uint8_t  u8_useScatterGather,
uint8_t  u8_dmaLocsPerInput 
)

Configure the internal ADC

Definition at line 100 of file adc7scan1_dma_conv_order.c.