//ADC初始化设置 void adc_init(void) { ADCSRA = 0x00; //disable adc ADMUX = 0x03; //使用VCC作为参考电压,选择ADC3(PB3)输入通道 ACSR = 0x80; //禁用模拟比较器,降低功耗 ADCSRB = 0x00; //ADC连续转换模式 ADCSRA = 0xEA; //使能ADC开始转换,自动触发使能,使能转换结束中断,4分频 } // ADC interrupt service routine interrupt [ADC_INT] void adc_isr(void) { unsigned int adc_data; // Read the AD conversion result adc_data=ADCW; // Place your code here }
|