unsigned int AD_convert(unsigned char num) { unsigned int i; SREG=0x00; ADMUX=(0x40|(num&0x1f)); ADCSRA=(1<<ADEN)|(1<<ADSC)|(1<<ADATE)|(1<<ADPS2)|1<<ADPS1);//64 for(i=0;i<1024;i++) { while(!(ADCSRA&0x10)); Ad_cj=ADCL; Ad_cj=(((ADCH<<8)|Ad_cj)&0x3ff); ADCSRA=0xE6; } ADCSRA=0x86; SREG=0x80; return i; }
|