标题: ATtiny13A ADC中断使用 [打印本页]

作者: daiya    时间: 2020-5-30 16:42
标题: ATtiny13A ADC中断使用
//ADC初始化设置
void adc_init(void)
{
    ADCSRA = 0x00;  //disable adc
    ADMUX = 0x03;  //使用VCC作为参考电压,选择ADC3PB3)输入通道
    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
}






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1