avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] How to use AT90S4433 A/D-Inputs?


From: Bernt Hustad Hembre
Subject: Re: [avr-gcc-list] How to use AT90S4433 A/D-Inputs?
Date: Sun, 1 Apr 2001 23:46:03 +0200 (CEST)

On Sun, 1 Apr 2001, Andreas Schwarz wrote:

> how can I use the A/D-Inputs of the AT90S4433 from Gcc?

Here's a simple example:

/* reurns the analog input channel ch */
int     readADC(unsigned char ch){
        if(ch<=7) outp(ch,ADMUX);

        outp((((1<<ADEN)|(1<<ADSC))+7),ADCSR); /* Sets ADEN and ADSC and
                              selects the slowest AD-conversation rate */

        while((unsigned char)(inp(ADCSR)&& (1<<ADSC))){
                /* wait for the ADC to do it's stuff.*/
                asm volatile ("nop");
        }
        return (ADCL+(ADCH*256));
}

This routine is not at all efficient (ie. you could either do something
usefull during the AD conversation or enter sleepmode to save power and
reduce noise). But it is a starting point. For any modification please
read the datasheet for the part you are using. (check out
www.avrfreaks.net).


Bernie
Tlf.: 92648923
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]