用的 atmel studio6.0
主频 8M
每次走到while 就停住了
/*
* ADC.c
*
* Created: 2012/6/18 16:13:15
* Author: Administrator
*/
#include
#include
unsigned int Adc_Val;
unsigned int sum;
void ADC_Init()
{ ADCSRA =0X00;
ADMUX = 0X00; //3.3v电源基准,PA0口输入转换
DIDR0 = 0XFF;
ADCSRA = _BV(ADEN) | _BV(ADIF);
}
int ADC_Val()
{
ADCSRA = _BV(ADSC);
while((ADCSRA & 0x10)==0x00);
Adc_Val = ADCH;
Adc_Val <<=8;
Adc_Val = Adc_Val + ADCL;
return Adc_Val;
}
int main(void)
{
ADC_Init();
DDRA = 0X00;
PORTA = 0X00;
DDRB = 0XFF;
PORTB = 0XFF;
ADC_Val();
while(1)
{
//TODO:: Please write your application code
}
}