0
我試圖在ATMEGA8上執行以下一段代碼,但ADC似乎沒有工作。ADC不與ATMEGA8一起工作
#include <avr/io.h>
#include "LCD.h"
int main()
{
int val=0;
ADCSRA=0x87;//ADc enabled and prescaler set to fosc/128
ADMUX= 0xC0;//REFS0 and REFS1 set using internal 2.5 volts as Vref
DDRC=0x00;// as input for the adc
PORTC=0x00;
DDRB=0xff;
while (1)
{
ADCSRA |=(1<<ADSC);
while(!(ADCSRA&(1<<ADIF)));
lcd_string("Done Conversion");
val=ADCL;
PORTB=ADCL;
ADCSRA |=(1<<ADIF);//(reseting ADIF to 1)
lcd_print(2,1,val,3);
}
return 0;
}
這是什麼意思「不工作」?請準確。 – ouah 2015-03-25 11:02:20