|
#define | ADC_CHANNEL_0 0x00 |
|
#define | ADC_CHANNEL_1 0x01 |
|
#define | ADC_CHANNEL_2 0x02 |
|
#define | ADC_CHANNEL_3 0x03 |
|
#define | ADC_CHANNEL_4 0x04 |
|
#define | ADC_CHANNEL_5 0x05 |
|
#define | ADC_CHANNEL_6 0x06 |
|
#define | ADC_CHANNEL_7 0x07 |
|
#define | ADC_DIFF_ADC0_ADC0_10X 0x08 |
|
#define | ADC_DIFF_ADC1_ADC0_10X 0x09 |
|
#define | ADC_DIFF_ADC0_ADC0_200X 0x0A |
|
#define | ADC_DIFF_ADC1_ADC0_200X 0x0B |
|
#define | ADC_DIFF_ADC2_ADC2_10X 0x0C |
|
#define | ADC_DIFF_ADC3_ADC2_10X 0x0D |
|
#define | ADC_DIFF_ADC2_ADC2_200X 0x0E |
|
#define | ADC_DIFF_ADC3_ADC2_200X 0x0F |
|
#define | ADC_DIFF_ADC0_ADC1_1X 0x10 |
|
#define | ADC_DIFF_ADC1_ADC1_1X 0x11 |
|
#define | ADC_DIFF_ADC2_ADC1_1X 0x12 |
|
#define | ADC_DIFF_ADC3_ADC1_1X 0x13 |
|
#define | ADC_DIFF_ADC4_ADC1_1X 0x14 |
|
#define | ADC_DIFF_ADC5_ADC1_1X 0x15 |
|
#define | ADC_DIFF_ADC6_ADC1_1X 0x16 |
|
#define | ADC_DIFF_ADC7_ADC1_1X 0x17 |
|
#define | ADC_DIFF_ADC0_ADC2_1X 0x18 |
|
#define | ADC_DIFF_ADC1_ADC2_1X 0x19 |
|
#define | ADC_DIFF_ADC2_ADC2_1X 0x1A |
|
#define | ADC_DIFF_ADC3_ADC2_1X 0x1B |
|
#define | ADC_DIFF_ADC4_ADC2_1X 0x1C |
|
The ATmega1284p has 8 ADC-channels. You can run the ADC in different modes like just "single coversion", "free running" or "auto triggered" by timer or interrupts. Moreover it is possible to get differential values of two ADC-channels (with or without a gain factor)
#define ADC_ANALOG_COMPARATOR (1 << ADTS0) |
mode: ADC Analog Comparator
- Note
- Sets the ADC to comparator mode.
Definition at line 83 of file adc.h.
#define ADC_EXT_INTERRUPT (1 << ADTS1) |
mode: External Interrupt Trigger
- Note
- Enables the auto trigger mode. The ADC will start a conversion, whenever changes on external interrupt will occur.
Definition at line 89 of file adc.h.
#define ADC_FREE_RUNNING 0x00 |
mode: ADC Free Running Mode
- Note
- The ADC runs all the time. An interrupt occurs whenever one ADC cycle will finish
Definition at line 78 of file adc.h.
#define ADC_REF_1100MV_INT (1 << REFS1) |
ref: Internal 1.1V Reference
- Note
- The ADC reference voltage is provided by internal 1.1V
Definition at line 143 of file adc.h.
#define ADC_REF_2560MV_INT ((1 << REFS1)| (1 << REFS0)) |
ref: Internal 2.56V Reference
- Note
- The ADC reference voltage is provided by internal 2.56V
Definition at line 148 of file adc.h.
ref: External Reference Voltage (Aref)
- Note
- The ADC reference voltage is provided by the external reference pin Aref
Definition at line 133 of file adc.h.
Referenced by adc_init().
#define ADC_REF_AVCC (1 << REFS0) |
ref: Supply Voltage Reference (AVcc)
- Note
- The ADC reference voltage is provided by the supply voltage.
Definition at line 138 of file adc.h.
Referenced by key_init(), and temp_get().
#define ADC_SINGLE_CONVERSION 0xFF |
mode: ADC Single Conversion
- Note
- The ADC will make just one conversion cycle (normal use)
Definition at line 72 of file adc.h.
Referenced by adc_init().
#define ADC_TIMER0_COMP_FLAG ((1 << ADTS1) | (1 << ADTS0)) |
mode: Timer0 Compare Flag Trigger
- Note
- Enables the auto trigger mode. The ADC will start a conversion, whenever Timer0 Compare Flag is set.
Definition at line 95 of file adc.h.
#define ADC_TIMER0_OVERFLOW (1 << ADTS2) |
mode: Timer0 Compare Flag Trigger
- Note
- Enables the auto trigger mode. The ADC will start a conversion, whenever Timer0 overflow occurs.
Definition at line 101 of file adc.h.
#define ADC_TIMER1_CAPTURE ((1 << ADTS2) | (1 << ADTS1) | (1 << ADTS0)) |
mode: Timer1 Compare Flag Trigger
- Note
- Enables the auto trigger mode. The ADC will start a conversion, whenever Timer0 Capture Flag is set.
Definition at line 119 of file adc.h.
#define ADC_TIMER1_COMP_FLAG ((1 << ADTS2) | (1 << ADTS0)) |
mode: Timer1 Compare Flag Trigger
- Note
- Enables the auto trigger mode. The ADC will start a conversion, whenever Timer0 Compare Flag is set.
Definition at line 107 of file adc.h.
#define ADC_TIMER1_OVERFLOW ((1 << ADTS2) | (1 << ADTS1)) |
mode: Timer1 Compare Flag Trigger
- Note
- Enables the auto trigger mode. The ADC will start a conversion, whenever Timer0 overflow occurs.
Definition at line 113 of file adc.h.
This function stops all running ADC.
This will disable the adc.
Definition at line 132 of file adc.c.
uint16_t adc_get_value |
( |
void |
| ) |
|
This function returns the ADC data register value.
Use adc_set_mux to preselect the ADC-channel or differential input.
- Returns
- The ADC-value of preselected mux
Definition at line 110 of file adc.c.
Referenced by adc_get_value_from().
uint16_t adc_get_value_from |
( |
uint8_t |
chn | ) |
|
This function returns the ADC data register value of the given ADC channel.
- Parameters
-
chn | The ADC channel (ADC0 ... ADC7) |
- Returns
- The ADC-value
This function is more efficient for the single
conversion mode. Just select the ADC channel (or
differential settings) and get the result.
Definition at line 125 of file adc.c.
References adc_get_value(), and adc_set_mux().
void adc_init |
( |
uint8_t |
mode, |
|
|
uint8_t |
ref |
|
) |
| |
Initialize the ADC module.
- Note
- This routine performes a pre-check whether the AREF pin is connected. It aborts initialization if AREF pin is connected but internal reference is chosen.
- Parameters
-
mode | Select an ADC mode like single conversion or free running, etc. |
ref | The ADC reference voltage source. |
- Return values
-
Definition at line 60 of file adc.c.
References ADC_REF_AREF, and ADC_SINGLE_CONVERSION.
void adc_set_mux |
( |
uint8_t |
mux | ) |
|
With this function you can set the ADX multiplexer.
Here you select the ADC channel or choose differential
value between two ADC-channels with or without gain.
- Parameters
-
mux | Select single ADC channel (ADC_CHANNEL_0 ... ADC_CHANNEL_7) or differential input of various ADC-channels with or without gain |
Definition at line 96 of file adc.c.
Referenced by adc_get_value_from().