include/pic24_adc.h File Reference

Go to the source code of this file.

Defines

#define IS_CONVERSION_COMPLETE_ADC1()   AD1CON1bits.DONE
#define IS_SAMPLING_ADC1()   AD1CON1bits.SAMP

Functions

uint16 convertADC1 (void)
void configADC1_ManualCH0 (uint16 u16_Ch0PositiveMask, uint8 u8_autoSampleTime, uint8 u8_Use12bits)
void configADC1_AutoScanIrqCH0 (uint16 u16_ch0ScanMask, uint8 u8_autoSampleTime, uint8 u8_12bit)
void configADC1_AutoHalfScanIrqCH0 (uint16 u16_ch0ScanMask, uint8 u8_autoSampleTime, uint8 u8_12bit)
void configADC1_Simul4ChanIrq (uint8 u8_ch0Select, uint16 u16_ch123SelectMask, uint16 u16_numTcyMask)
static void WAIT_UNTIL_CONVERSION_COMPLETE_ADC1 ()


Detailed Description

To do.

Definition in file pic24_adc.h.


Define Documentation

 
#define IS_CONVERSION_COMPLETE_ADC1 (  )     AD1CON1bits.DONE

Determines if the conversion on AD1 is done. Returns 1 if the conversion has completed, or 0 if the conversion has not started or is in progress.

Returns:
True (1) if the conversion has completed, 0 if not.

Definition at line 29 of file pic24_adc.h.

 
#define IS_SAMPLING_ADC1 (  )     AD1CON1bits.SAMP

Determines if the AD1 sample-and-hold amplifier(s) are sampling. Returns 1 if the sample-and-hold amplifier(s) are sampling, or 0 if sample-and-hold amplifier(s) are holding.

Returns:
True (1) if the sample-and-hold amplifier(s) are sampling, 0 if not.

Definition at line 42 of file pic24_adc.h.


Function Documentation

void configADC1_AutoHalfScanIrqCH0 ( uint16  u16_ch0ScanMask,
uint8  u8_autoSampleTime,
uint8  u8_use12bit 
)

Configures ADC1 to perform conversions over a number of scanned channels to CH0. The sampling is done against the AVDD and AVSS references and using the internal ADC clock to conserve timer resourses. Samples are obtained continuously once sampling begins. Triggers ADC completion interrupts every N conversion cycles, where N is the number of bits set in the scan channel mask argument u16_ch0ScanMask. Results are written to the first u8_NumChannels locations in the 8 word alternating halves of the 16 word ADCxBUFn registers.

User ISR must check the AD1CON2.BUFS bit when responding to copy the 8 words from the correct half of the ADC1BUFn register array. See Chapter 11 in the book for an example. (adc7scan2 project)

Sampling+conversion will start automatically when ADC is turned on.

Parameters:
u16_ch0ScanMask A bit-mask to select the analog inputs to scan over and convert. See AD1CSSL register and associated definess in pic24_adc.h
u8_autoSampleTime Number of TAD periods for sampling the signal. This value must be 0-31. If greater than 31, then 31TAD will be used.
u8_use12bit If TRUE, set up the ADC into 12 bit mode, else use the 10 bit mode.

Configure the internal ADC

Definition at line 197 of file pic24_adc.c.

void configADC1_AutoScanIrqCH0 ( uint16  u16_ch0ScanMask,
uint8  u8_autoSampleTime,
uint8  u8_use12bit 
)

Configures ADC1 to perform conversions over a number of scanned channels to CH0. The sampling is done against the AVDD and AVSS references and using the internal ADC clock to conserve timer resourses. Samples are obtained continuously once sampling begins. Triggers ADC completion interrupts every u8_NumChannels conversion cycles. Results are written to the first u8_NumChannels locations in the 16 word ADCxBUFn registers.

Sampling+conversion will start automatically when ADC is turned on.

User must provide ISR to copy the 1-16 ADC results from ADC1BUFn before the next conversion completes. See Chapter 11 in the book for an example (adc7scan1 project).

Parameters:
u16_ch0ScanMask A bit-mask to select the analog inputs to scan over and convert. See AD1CSSL register and associated definess in pic24_adc.h
u8_autoSampleTime Number of TAD periods for sampling the signal. This value must be 0-31. If greater than 31, then 31TAD will be used.
u8_use12bit If TRUE, set up the ADC into 12 bit mode, else use the 10 bit mode.

Configure the internal ADC

Definition at line 132 of file pic24_adc.c.

void configADC1_ManualCH0 ( uint16  u16_ch0PositiveMask,
uint8  u8_autoSampleTime,
uint8  u8_use12bit 
)

Configures ADC1 to perform 10-/12-bit conversion on a single channel via CH0. The sampling is done against the AVDD and AVSS references and using the internal ADC clock to conserve timer resourses. User can initiate this manual sampling+conversion by setting the SAMP bit nin AD1CON1. When the DONE bit in AD1CON1 goes high, the conversion is done.

Parameters:
u16_ch0PositiveMask Mask to select the single analog input to convert. See AD1CHS0 register and associated definess in pic24_adc.h
u8_autoSampleTime Number of TAD periods for sampling the signal. This value must be 0-31. If greater than 31, then 31TAD will be used.
u8_use12bit If TRUE, set up the ADC into 12 bit mode, else use the 10 bit mode.

Configure the internal ADC

Definition at line 84 of file pic24_adc.c.

void configADC1_Simul4ChanIrq ( uint8  u8_ch0Select,
uint16  u16_ch123SelectMask,
uint16  u16_numTcyMask 
)

Configures ADC1 to perform simultaneous sampling and (sequential) 10bit conversion on four channels. Sampling is done against the AVDD and AVSS references. Sample duration is determined by the Timer2/3. Conversion clock is created from the internal system instruction clock. This means that this ADC configuration can NOT be used for sleeping ADC operations.

ADC completion interrupts notify user when data is ready. Our four channel conversion values are written into the alternative halves of the ADC1BUFn registers. ADC ISR must "restart" the sample (by setting AD1CON1.SAMP bit) before exit. Sampling will end and conversion will begin on the next Timer2/3 trigger. Conversion values are written into the alternative halves of the ADC1BUFn registers.

Sampling starts when AD1CON1.SAMP bit is written by main.

User must ........ See Chapter 11 in the book for an example (adc4simul project).

Parameters:
u8_ch0Select The number of the ANx channel to sample on CH0 sample-and-hold amplifier. This pin can be the same as a pin sampled on channels 1, 2, and 3. (See next argument.)
u16_ch123SelectMask A bit-mask to select the analog inputs to for channels 1,2, and 3. See AD1CHS123 register and associated definess in pic24_adc.h
u16_numTcyMask A bit-mask to select the number of TCY periods used to create one TCY period. Note that TAD > 75ns. See AD1CON3 register and associated definess in pic24_adc.h

Configure the internal ADC

Definition at line 269 of file pic24_adc.c.

uint16 convertADC1 ( void   ) 

Prototype PIC24_ADC library functions here (functions live in the common/pic24_adc.c file)

Performs an ADC conversion (assumes ADC is initialized properly to return integer results.

Returns:
Integer value (10- or 12-bit, depending on ADC configuration) corresponding to the ADC conversion result.

Definition at line 55 of file pic24_adc.c.

static void WAIT_UNTIL_CONVERSION_COMPLETE_ADC1 (  )  [inline, static]

Waits until the conversion is completed.

Definition at line 32 of file pic24_adc.h.


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