adc.c File Reference

#include "adc.h"

Include dependency graph for adc.c:

Go to the source code of this file.

Functions

void ADC_Init (void)
S16 read_acquisition (void)
void Start_ADC (void)

Variables

volatile U8 Flag_IT_ADC = 0


Function Documentation

void ADC_Init ( void   ) 

Initialisation of the ADC

Parameters:
none 
Precondition:
none
Returns:
none /

Definition at line 44 of file adc.c.

Referenced by main().

00045 {
00046 
00047    /* Digital Input Disable Register 0 */
00048    DIDR0 =   (0<<ADC7D) \
00049            | (0<<ADC6D ) \
00050            | (0<<ADC5D ) \
00051            | (0<<ADC4D ) \
00052            | (0<<ADC3D ) \
00053            | (0<<ADC2D ) \
00054            | (0<<ADC1D ) \
00055            | (0<<ADC0D ) \
00056    ;
00057 
00058    /* Digital Input Disable Register 1 */
00059    DIDR1 =   (0<<ACMP0D) \
00060            | (1<<AMP0PD) /* disable digital input on AMP 0 */ \
00061            | (1<<AMP0ND) /* disable digital input on AMP 0 */ \
00062            | (0<<ADC10D) \
00063            | (1<<ADC9D)  \
00064            | (1<<ADC8D)
00065    ;
00066 
00067    /* init amplifier 0 */
00068    AMP0CSR =   (1 <<AMP0EN)  /* Amplifier enable */ \
00069              | (0 <<AMP0IS) \
00070              | (AMP_GAIN_5 <<AMP0G0) \
00071              | (AMP_TRIG_ON_PSC0 <<AMP0TS0) \
00072    ;
00073 
00074    /* init amplifier 1 */
00075    AMP1CSR =   (1 <<AMP1EN)  /* Amplifier enable */ \
00076              | (0 <<AMP1IS) \
00077              | (AMP_GAIN_5 <<AMP1G0) \
00078              | (AMP_TRIG_ON_PSC0 <<AMP1TS0) \
00079    ;
00080 
00081    /* init ADC */
00082    ADMUX =    (ADC_VREF_INTERNAL <<REFS0) \
00083             | (0 <<ADLAR) \
00084             | (ADC_INPUT_AMP1 <<MUX0) /* select input */ \
00085    ;
00086 
00087    ADCSRB =   (1<<ADHSM)  /* High Speed Mode   */ \
00088             | (0<<ADASCR) /* not used on AT90PWM3B */ \
00089             | (ADC_TRIG_SRC_FREE_RUNNING <<ADTS0) \
00090    ;
00091 
00092    ADCSRA =   (1<<ADEN)  /* ADC enable          */ \
00093             | (0<<ADSC)  \
00094             | (0<<ADATE) \
00095             | (1<<ADIE)  /* interrupt enable    */ \
00096             | (ADC_PRESCALER_16 <<ADPS0) \
00097    ;
00098 
00099 }

Here is the caller graph for this function:

S16 read_acquisition ( void   ) 

Get the ADC conversion result

Parameters:
none 
Precondition:
none
Returns:
16 bit result /

Definition at line 128 of file adc.c.

Referenced by main().

00129 {
00130    Union16     resultADC ;
00131 
00132    LSB(resultADC) = ADCL ;  // the ADC output has 10 bit resolution
00133    MSB(resultADC) = ADCH ;
00134 
00135    return (resultADC.w) ;
00136 }

Here is the caller graph for this function:

void Start_ADC ( void   ) 

Start the ADC conversion

Parameters:
none 
Precondition:
none
Returns:
none /

Definition at line 109 of file adc.c.

00110 {
00111    ADCSRA =   (1<<ADEN)  /* ADC enable          */ \
00112             | (1<<ADSC)  /* start conversion */ \
00113             | (0<<ADATE) \
00114             | (1<<ADIE)  /* interrupt enable    */ \
00115             | (ADC_PRESCALER_16 <<ADPS0) \
00116    ;
00117 
00118 }


Variable Documentation

volatile U8 Flag_IT_ADC = 0

Definition at line 33 of file adc.c.

Referenced by main().


Generated on Tue Sep 16 18:11:21 2008 for Atmel BLDC Sinusoidal on ATAVRMC100 by  doxygen 1.5.3