Atmel Software Framework

adc_oversampling.h File Reference

XMEGA ADC oversampling header file for ADC source code This file contains the function prototypes.

Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.

Macros

#define ASCII_BUFFER_SIZE   9
 
#define NUMBER_OF_DIGITS_IN_ADCCOUNT   5
 
#define NUMBER_OF_DIGITS_IN_RESULT   6
 

Functions

static int8_t adc_offset_get_signed (void)
 Function to get the offset of ADC. More...
 
void adc_oversampled (void)
 Function to process sampled ADC values. More...
 
static void convert_to_ascii (uint8_t *buf_index, uint64_t dec_val)
 Function to convert decimal value to ASCII. More...
 
void display_adccount (uint64_t adc_rawcount, uint8_t x_cordinate, uint8_t sign_flag)
 Function to display raw ADC count on LCD. More...
 
void init_adc (void)
 Function to initialize the ADC. More...
 

Variables

volatile bool adc_oversampled_flag
 Static variable/flag to indicate that one set of oversampling is done for start processing. More...
 

#define ASCII_BUFFER_SIZE   9

Referenced by adc_oversampled().

#define NUMBER_OF_DIGITS_IN_ADCCOUNT   5

Referenced by display_adccount().

#define NUMBER_OF_DIGITS_IN_RESULT   6

Referenced by convert_to_ascii().

static int8_t adc_offset_get_signed ( void  )
static

Function to get the offset of ADC.

void adc_oversampled ( void  )

Function to process sampled ADC values.

Function to process sampled ADC values.

  • Offset error compensation is applied on accumulated ADC value
  • After, scaling is done with scaled factor.
  • Finally, Analog value at ADC input pin is calculated
  • Reset all variable used in ADC ISR and enable ADC interrupt to start next oversampling Process.

References abs, ADC_CH0, adc_ch_conf, adc_offset, adc_offset_one_sample, adc_result_accum_processed, adc_result_accumulator, adc_result_one_sample, adc_result_one_sample_processed, adc_samplecount, adcch_enable_interrupt(), ADCCH_MODE_COMPLETE, adcch_set_interrupt_mode(), adcch_write_configuration(), ASCII_BUFFER_SIZE, convert_to_ascii(), display_adccount(), gfx_mono_draw_string(), sysfont, v_input, v_input_ascii_buf, and v_input_one_sample.

Referenced by main().

static void convert_to_ascii ( uint8_t *  buf_index,
uint64_t  dec_val 
)
static

Function to convert decimal value to ASCII.

void display_adccount ( uint64_t  adc_rawcount,
uint8_t  x_cordinate,
uint8_t  sign_flag 
)

Function to display raw ADC count on LCD.

Function to display raw ADC count on LCD.

  • It will extract each digit from ADC count and convert to ASCII
  • Use GFX service for displaying each character
    Parameters
    adc_rawcountADC raw count value to be displayed.
    x_cordinateX-coordinate where display should end.
    sign_flagSign of ADC count.If negative sign_flag is set.

References gfx_mono_draw_char(), NUMBER_OF_DIGITS_IN_ADCCOUNT, and sysfont.

Referenced by adc_oversampled().

void init_adc ( void  )

Function to initialize the ADC.

Function to initialize the ADC.

  • ADCB-CH0 is configured in 12bit, signed differential mode without gain
  • To read ADC offset, ADCB-Pin3(PB3) used as both +ve and -ve input
  • After reading ADC offset,to start oversampling,ADCB +ve and -ve input are configured

References ADC_CH0, adc_ch_conf, adc_conf, adc_disable(), adc_enable(), adc_handler(), adc_offset, adc_offset_get_signed(), adc_offset_one_sample, adc_read_configuration(), ADC_REF_AREFB, ADC_RES_12, adc_set_callback(), adc_set_clock_rate(), adc_set_conversion_parameters(), adc_set_conversion_trigger(), ADC_SIGN_ON, ADC_TRIG_FREERUN_SWEEP, ADC_TRIG_MANUAL, adc_write_configuration(), adcch_enable_interrupt(), ADCCH_MODE_COMPLETE, ADCCH_NEG_PIN3, ADCCH_POS_PIN3, adcch_read_configuration(), adcch_set_input(), adcch_set_interrupt_mode(), and adcch_write_configuration().

Referenced by main().

volatile bool adc_oversampled_flag

Static variable/flag to indicate that one set of oversampling is done for start processing.

Static variable/flag to indicate that one set of oversampling is done for start processing.

Referenced by adc_handler(), and main().