Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CodeVision AVR 1.25.7, user manual.pdf
Скачиваний:
214
Добавлен:
12.08.2013
Размер:
1.22 Mб
Скачать

CodeVisionAVR

5.8 Setting the Analog-Digital Converter

Some AVR chips contain an analog-digital converter (ADC).

By selecting the ADC tab of the CodeWizardAVR, you can specify the ADC configuration.

Checking the ADC Enabled check box enables the on-chip ADC.

On some AVR devices only the 8 most significant bits of the AD conversion result can be used. This feature is enabled by checking the Use 8 bits check box.

Some AVR devices allow the ADC to use a high speed conversion mode, but with lower precision. This feature is enabled by checking the High Speed check box.

If the ADC has an internal reference voltage source, than it can be selected using the Volt. Ref. list box or activated by checking the ADC Bandgap check box.

© 1998-2007 HP InfoTech S.R.L.

Page 196

CodeVisionAVR

Some AVR devices allow the AD conversion to be triggered by an event which can be selected using the Auto Trigger Source list box.

If you want to generate interrupts when the ADC finishes the conversion, then you must check the

ADC Interrupt check box.

If ADC interrupts are used you have the possibility to enable the following functions:

by checking the ADC Noise Canceler check box, the chip is placed in idle mode during the conversion process, thus reducing the noise induced on the ADC by the chip's digital circuitry

by checking the Automatically Scan Inputs Enabled check box, the CodeWizardAVR will generate code to scan an ADC input domain and put the results in an array. The start, respectively the end, of the domain are specified using the First Input, respectively the Last Input, spinedit boxes.

If the automatic inputs scanning is disabled, then a single analog-digital conversion can be executed using the function:

unsigned int read_adc(unsigned char adc_input)

This function will return the analog-digital conversion result for the input adc_input. The input numbering starts from 0.

If interrupts are enabled the above function will use an additional interrupt service routine adc_isr. This routine will store the conversion result in the adc_data global variable.

If the automatic inputs scanning is enabled, the adc_isr service routine will store the conversion results in the adc_data global array. The user program must read the conversion results from this array.

© 1998-2007 HP InfoTech S.R.L.

Page 197

CodeVisionAVR

For some chips, like the Atmega169V/L, there is also the possibility to disable the digital input buffers on the inputs used by the ADC, thus reducing the power consumption of the chip.

This is accomplished by checking the corresponding Disable Digital Input Buffers check boxes.

If the Automatically Scan Inputs option is enabled, then the corresponding digital input buffers are automatically disabled for the ADC inputs in the scan range.

© 1998-2007 HP InfoTech S.R.L.

Page 198

CodeVisionAVR

5.9 Setting the ATmega406 Voltage Reference

Some AVR chips, like the Atmega406, contain a low power precision bang-gap voltage reference, which can be configured by selecting the Voltage Reference tab of the CodeWizardAVR.

Checking the Voltage Reference Enabled check box enables the precision voltage reference.

The Voltage Calibration list box allows for precision adjustment of the nominal value of the reference voltage in 2mV steps.

The Temperature Gradient Adjustment slider allows shifting the top of the VREF versus temperature curve to the center of the temperature range of interest, thus minimizing the voltage drift in this range. The Atmega406 datasheet may be consulted for more details.

© 1998-2007 HP InfoTech S.R.L.

Page 199