Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] Can you have split ADC usage

2013-05-14 by Dave McLaughlin

This is the init code. I have a licensed copy of Codevision so I took some of the init code from that to build the AVR GCC programme. I needed 64 bit long for the Zigbee to work and right now, Codevision does not support it :)

 

#define ADC_VREF_TYPE ((0<<REFS1) | (1<<REFS0) | (0<<ADLAR))

 

Here is the init code for the ADC

 

       // ADC initialization

       // ADC Clock frequency: 250.000 kHz

       // ADC Voltage Reference: AVCC pin

       // ADC Auto Trigger Source: ADC Stopped

       // Digital input buffers on ADC0: On, ADC1: Off, ADC2: Off, ADC3: On

       // ADC4: On, ADC5: On, ADC6: On, ADC7: On

       DIDR0=(0<<ADC7D) | (0<<ADC6D) | (0<<ADC5D) | (0<<ADC4D) | (0<<ADC3D) | (1<<ADC2D) | (1<<ADC1D) | (0<<ADC0D);

       ADMUX=ADC_VREF_TYPE;

       ADCSRA=(1<<ADEN) | (0<<ADSC) | (0<<ADATE) | (0<<ADIF) | (0<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (0<<ADPS0);

       ADCSRB=(0<<ADTS2) | (0<<ADTS1) | (0<<ADTS0);

 

 

Then this is used to read the ADC

 

unsigned int ReadADC(unsigned char adc_input)

{

       ADMUX=adc_input | ADC_VREF_TYPE;

       // Delay needed for the stabilization of the ADC input voltage

       _delay_us(10);

       // Start the AD conversion

       ADCSRA|=(1<<ADSC);

       // Wait for the AD conversion to complete

       while ((ADCSRA & (1<<ADIF))==0);

       ADCSRA|=(1<<ADIF);

       return ADCW;

}

 

 

Dave…

 

From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of enkitec@gmail.com
Sent: 14 May 2013 18:28
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Can you have split ADC usage

 

  


Did you start up the ADC?

Mark

On 14-May-13 04:56, Cat C wrote:
> Did you set up the MUX?
> Cat





[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.