File : main.c Compiler : IAR EWAAVR 2.28a/3.10c Revision :
Support mail : avr@atmel.com
Supported devices : All devices with a ADC can be used. The example is written for ATmega16
AppNote : AVR121 - Enhancing ADC resolution by oversampling
Description : Example of how to use oversampling to increase the resolution This code shows an example of how to increase the ADCs resolution from 10-bit to 16-bit. It might be usefull to write every single ADC result to UART, to ensure that LSB toggles
Definition in file main.c.
#include <iom16.h>
#include <inavr.h>
Go to the source code of this file.
Functions | |
__interrupt void | ADCinterrupt (void) |
ADC interrupt routine. | |
void | init_adc (void) |
Enables ADC, Interrupt enabled, ADC-clock=125kHz, VREF=AREF. | |
void | init_counter (void) |
Fast PWM, Clk / 64, Clear OC2 on compare match, 50% duty cycle. | |
void | oversampled (void) |
Compensate errors, scaling result, round up, increase averaged result. | |
Variables | |
double | accumulator = 0 |
Accumulated 10-bit samples. | |
short | samples = 0 |
Number of conversions. | |
short | temp = 0 |
Temporary variable. | |
double | Vin = 0 |
16-bit float number result |
|
Definition at line 41 of file main.c. References accumulator, and samples. |
|
Definition at line 54 of file main_uart.c. Referenced by main(). |
|
Definition at line 78 of file main_uart.c. Referenced by main(). |
|
Definition at line 160 of file main_uart.c. References accumulator, samples, temp, vin(), write_16bit(), and write_space(). Referenced by main(). |
|
< Including header file Including header file Definition at line 29 of file main.c. Referenced by ADCinterrupt(), oversampled(), vin(), and write_16bit(). |
|
Definition at line 32 of file main.c. Referenced by ADCinterrupt(), main(), and oversampled(). |
|
Definition at line 31 of file main.c. Referenced by oversampled(). |
|
Definition at line 30 of file main.c. Referenced by vin(). |