欢迎来到天天文库
浏览记录
ID:47037136
大小:30.50 KB
页数:3页
时间:2019-07-03
《AVR中AD转换程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、defineAD_SE_ADC00x00//ADC0#defineAD_SE_ADC10x01//ADC1#defineAD_SE_ADC20x02//ADC2#defineAD_SE_ADC30x03//ADC3#defineAD_SE_ADC40x04//ADC4#defineAD_SE_ADC50x05//ADC5#defineAD_SE_ADC60x06//ADC6//常量定义#defineVref2650//mV/*********AD转换函数******************///AD转换函数//ADC_PORT为输入的端口/**************
2、************************/uint16_tMeasured_Vol_INT(unsignedcharADC_PORT){ uint16_tM_Volt=0; //变换后的电压mV uint32_ttemp32; uint8_ti; ADMUX=0xC0
3、ADC_PORT; //片内基准电压,单端输入./* ADMUX(ADCMultiplexerSelectRegister) bit7 bit6 REFS1REFS
4、0 参考电压选择 0 0 AREF,内部Vref关闭 0 1 AVCC,AREF引脚外加滤波电容 1 0 保留 1 1 2.56V的片内基准电压源,AREF引脚外加滤波电容 bit5 ADC结果左对齐选择1=左对齐 0=右对齐 bit4~0 选择32通道 */ ADCSRA=(1<5、(06、<7、(0<8、(1<9、(1<10、(1<11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
5、(0
6、<7、(0<8、(1<9、(1<10、(1<11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
7、(0<8、(1<9、(1<10、(1<11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
8、(1<9、(1<10、(1<11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
9、(1<10、(1<11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
10、(1<11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
11、 bit2:0ADC预分频选择位111=128时钟分频*/ asm("sleep"); for(i=0;i<24;i++) { ADCSRA
12、=(1<13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
13、=(1<14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
14、=~(1<15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
15、)ADC*Vref; M_Volt+=(uint16_t)(temp32/1023); } ADCSRA&=~(1<16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
16、液晶模块初始化*/ myprintf("mV%"); while(1) { DelayMs(500); /*延时500ms*/ col=0;row=2; myprintf(" %"); col=60;row=2; show_long((unsignedlong)Measured_Vol_INT(AD_SE_ADC0));//获取端口PA0的转换数据}}
此文档下载收益归作者所有