Need help to write program for ADC in avr studio.

Status
Not open for further replies.
here is the ADC code for ATmega* in AVR studio.....



hope this helpful for u................
 

Attachments

  • ATmega8 ADC Example.doc
    25.5 KB · Views: 302

I've done ADC successfully, only using this simple code.

// program_ADC

unsigned int adc_rd;

void main()
{

DDRD = 0xFF; // Set PORTD as output
DDRB = 0x03; // Set PORTB 0&1 as output

while (1) {
adc_rd = ADC_Read(2); // get ADC value from 2nd channel
PORTD = adc_rd; // display adc_rd[7..0]
PORTB = Hi(adc_rd); // display adc_rd[9..8]
}
}


its on 'mikroC pro' .
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…