chap11/adc7scan1_dma2.c File Reference

#include "pic24_all.h"
#include "stdio.h"

Go to the source code of this file.

Functions

uint8 configDMA_ADC (uint16 u16_ch0ScanMask, uint8 u8_autoSampleTime, uint8 u8_use12bit, uint8 u8_useScatterGather, uint8 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_dma2.c.


Function Documentation

uint8 configDMA_ADC ( uint16  u16_ch0ScanMask,
uint8  u8_autoSampleTime,
uint8  u8_use12bit,
uint8  u8_useScatterGather,
uint8  u8_dmaLocsPerInput 
)

Configure the internal ADC

Definition at line 100 of file adc7scan1_dma2.c.


Generated on Sun Mar 15 11:14:22 2009 for PIC24 Support Libraries by  doxygen 1.5.8