Analog-to-Digital Conversion

Functions

void adc_interrupt_enable (uint8_t cmd)
uint16_t adc_read (void)
void adc_set_adlar (uint8_t adlar)
void adc_set_auto_trigger (uint8_t cmd)
void adc_set_channel (uint8_t chan)
void adc_set_enable (uint8_t cmd)
void adc_set_prescalar (uint8_t pre)
void adc_set_reference (uint8_t ref)
void adc_start_conversion (void)
uint8_t adc_interrupt_flag (void)

Function Documentation

void adc_interrupt_enable ( uint8_t  cmd  ) 

Enable/disable the ADC ISR.

Parameters:
cmd ADC_INTERRUPT_DISABLE: disables the ISR (default)
ADC_INTERRUPT_ENABLE: enable the ISR
Author:
Andrew H. Fagg
uint8_t adc_interrupt_flag ( void   )  [inline]

Returns the state of the ADC interrupt flag (indicates whether a conversion has been completed). Should only be used when the ISR is not being used.

Returns:
1 if the conversion is complete
0 if not complete
Author:
Andrew H. Fagg

Referenced by adc_read().

uint16_t adc_read ( void   ) 

Read the analog-to-digital converter. This function blocks (waits) until a value is available to be read from the ADC.

Assumptions: a conversion is ongoing or has completed, and adlar = ADC_ADLAR_RIGHT

Returns:
The value read from the analog-to-digital converter (0 ... 0x3ff)
Author:
Andrew H. Fagg

References adc_interrupt_flag().

void adc_set_adlar ( uint8_t  adlar  ) 

Configure the position of the 10-bit ADC value in the 16-bit output register

Parameters:
adlar ADC_ADLAR_RIGHT: Right-adjust the 10-bit value (default configuration)
ADC_ADLAR_LEFT: Left-adjust the 10-bit value
Author:
Andrew H. Fagg
void adc_set_auto_trigger ( uint8_t  cmd  ) 

Set the ADC auto trigger state. If enabled, the ADC will automatically initiate the collection of the next sample after the current one is complete.

Parameters:
cmd ADC_AUTO_TRIGGER_DISABLE: disabled (default)
ADC_AUTO_TRIGGER_ENABLE: enabled
Author:
Andrew H. Fagg
void adc_set_channel ( uint8_t  chan  ) 

Select the ADC channel for the next conversion. If a conversion is already ongoing, this change will not affect it.

Parameters:
chan A channel number. Acceptable values are 0 .. 15, however useful values will vary between specific chips. For the mega8, viable values are:
ADC_CHANNEL_0 (default), ... ADC_CHANNEL_7, ADC_CHANNEL_1p23V (1.23V reference), and ADC_CHANNEL_0V (0V reference)
Author:
Andrew H. Fagg
void adc_set_enable ( uint8_t  cmd  ) 

Set the global state of the ADC hardware.

Parameters:
cmd ADC_ENABLE: enable the ADC
ADC_DISABLE: disable the ADC
Author:
Andrew H. Fagg
void adc_set_prescalar ( uint8_t  pre  ) 

Set the clock prescalar for the ADC device.

Parameters:
pre is one of: ADC_PRESCALAR_2 (default),
ADC_PRESCALAR_4,
ADC_PRESCALAR_8,
ADC_PRESCALAR_16,
ADC_PRESCALAR_32,
ADC_PRESCALAR_64,
ADC_PRESCALAR_128
Author:
Andrew H. Fagg
void adc_set_reference ( uint8_t  ref  ) 

Set the analog reference for the ADC. This reference determines the voltage at which the maximum analog value is read.

Parameters:
ref ADC_REF_AREF: use the voltage presented at the AREF pin (default)
ADC_REF_AREF_CAP: use the voltage presented at the AREF pin, but connect a capacitor to the pin
ADC_REF_2p56V: use an internal reference of 2.56V
Author:
Andrew H. Fagg
void adc_start_conversion ( void   )  [inline]

Initiate an analog-to-digital conversion.

Assumptions: the ADC has been configured.

Author:
Andrew H. Fagg
Generated on Tue Feb 14 00:23:58 2012 for OU Atmel Utilities Library by  doxygen 1.6.3