带有atmega32的ADC代码

时间:2010-05-10 18:02:47

标签: atmega16

uint read_adc(uchar adc_input)

{

ADMUX=adc_input | (0x00 & 0xff);

delay_us(10);

ADCSRA|=0x40;     //START THE CONVERSION

while ((ADCSRA & 0x10)==0);     // wait for the conversion to complete

ADCSRA|=0x10;   //clear the ADC flag

return ADCW;

}

问:“ADMUX = adc_input |(0x00& 0xff)”是什么意思?我们在这里选择了哪个输入频道?

1 个答案:

答案 0 :(得分:1)

0x00 & 0xFF是荒谬的,因为它总是会评估为0.您可以将该行重写为ADCMUX = adc_input;

您选择的频道将是adc_input

中存储的值