Main Page | File List | Globals

# main.c File Reference

## Detailed Description

Atmel Corporation

File : main.c Compiler : IAR EWAAVR 2.28a/3.10c Revision :

Revision
  1.1

Date :

Date
  Wednesday, July 13, 2005 10:43:44 UTC

Updated by :

Author
  omella

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

## Function Documentation

__interrupt void ADCinterrupt | ( | void |  | ) |

| Definition at line 41 of file main.c. References accumulator, and samples.

void init_adc | ( | void |  | ) |

| Definition at line 54 of file main_uart.c. Referenced by main().

void init_counter | ( | void |  | ) |

| Definition at line 78 of file main_uart.c. Referenced by main().

void oversampled | ( | void |  | ) |

| Definition at line 160 of file main_uart.c. References accumulator, samples, temp, vin(), write_16bit(), and write_space(). Referenced by main().

## Variable Documentation

double accumulator = 0

| < Including header file Including header file Definition at line 29 of file main.c. Referenced by ADCinterrupt(), oversampled(), vin(), and write_16bit().

short samples = 0

| Definition at line 32 of file main.c. Referenced by ADCinterrupt(), main(), and oversampled().

short temp = 0

| Definition at line 31 of file main.c. Referenced by oversampled().

double Vin = 0

| Definition at line 30 of file main.c. Referenced by vin().