欢迎来到天天文库
浏览记录
ID:6934440
大小:46.50 KB
页数:5页
时间:2018-01-31
《ad(模数)转换范例》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、AD(模数)转换范例./***************************************************AVRADC使用范例**************策划、整理与测试:阿莫(armok)*******代码编写:HJJourAVR*******编译器:WINAVR20050214**************http://www.ouravr.com/2005.8.30**************************************************//*本程序简单的示范了如何使用ATMEGA16的ADC模数转换器普通的单端输入差分输入及校准基准电压的校准
2、查询方式中断方式数据格式的变换出于简化程序考虑,各种数据没有对外输出,学习时建议使用JTAGICE硬件仿真器*/#include#include#include#include/*宏INTERRUPT的用法与SIGNAL类似,区别在于SIGNAL执行时全局中断触发位被清除、其他中断被禁止INTERRUPT执行时全局中断触发位被置位、其他中断可嵌套执另外avr-libc提供两个API函数用于置位和清零全局中断触发位,它们是经常用到的。分别是:voidsei(void)和voidcli(vo
3、id)由interrupt.h定义*///管脚定义#definein_Single0//PA0(ADC0)#definein_Diff_P3//PA3(ADC3)#definein_Diff_N2//PA2(ADC2)//常量定义//单端通道,不放大#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_
4、ADC60x06//ADC6#defineAD_SE_ADC70x07//ADC7//差分通道ADC0作负端,10/200倍放大#defineAD_Diff0_0_10x0x08//ADC0+ADC0-,10倍放大,校准用#defineAD_Diff1_0_10x0x09//ADC1+ADC0-,10倍放大#defineAD_Diff0_0_200x0x0A//ADC0+ADC0-,200倍放大,校准用#defineAD_Diff1_0_200x0x0B//ADC1+ADC0-,200倍放大//差分通道ADC2作负端,10/200倍放大#defineAD_Diff2_2_10x0x0C//AD
5、C2+ADC2-,10倍放大,校准用#defineAD_Diff3_2_10x0x0D//ADC3+ADC2-,10倍放大#defineAD_Diff2_2_200x0x0E//ADC2+ADC2-,200倍放大,校准用#defineAD_Diff3_2_200x0x0F//ADC3+ADC2-,200倍放大//差分通道ADC1作负端,不放大#defineAD_Diff0_1_1x0x10//ADC0+ADC1-#defineAD_Diff1_1_1x0x11//ADC1+ADC1-,校准用#defineAD_Diff2_1_1x0x12//ADC2+ADC1-#defineAD_Diff3_
6、1_1x0x13//ADC3+ADC1-#defineAD_Diff4_1_1x0x14//ADC4+ADC1-#defineAD_Diff5_1_1x0x15//ADC5+ADC1-#defineAD_Diff6_1_1x0x16//ADC6+ADC1-#defineAD_Diff7_1_1x0x17//ADC7+ADC1-//差分通道ADC2作负端,不放大#defineAD_Diff0_2_1x0x18//ADC0+ADC2-#defineAD_Diff1_2_1x0x19//ADC1+ADC2-#defineAD_Diff2_2_1x0x1A//ADC2+ADC2-,校准用#define
7、AD_Diff3_2_1x0x1B//ADC3+ADC2-#defineAD_Diff4_2_1x0x1C//ADC4+ADC2-#defineAD_Diff5_2_1x0x1D//ADC5+ADC2-//单端通道,不放大#defineAD_SE_VBG0x1E//VBG内部能隙1.22V电压基准,校准用#defineAD_SE_GND0x1F//接地校准用//注://差分通道,如果使用1x或10
此文档下载收益归作者所有