《51单片机AD采样(共4页).doc》由会员分享,可在线阅读,更多相关《51单片机AD采样(共4页).doc(4页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上 51单片机AD转换程序及仿真图 仅供初初学者参考AD程序: #include #include sbit P2_4 = P24; sbit P2_5 = P25; sbit P2_6 = P26; sbit P2_7 = P27; sbit P3_0 = P30; sbit P3_3 = P33; sbit P3_2 = P32; sbit P3_1 = P31; #define ALE P2_4 #define START P2_5 #define OE P2_6 #define EOC P2_7 unsigned char code led_number=0x3
2、f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00 ; /LED灯的数据 unsigned char q; void delay(void) /延时函数 unsigned char a,b,c; for(c=189;c0;c-) for(b=230;b0;b-) for(a=33;a0;a-); void display(unsigned char led1) /数码管动态显示程序 P3 = 0X00; P3 = led_numberled1; unsigned char abc_0
3、808(unsigned char chanel) 、/AD采样函数 unsigned char dd; P2 &= 0XF8; P2 |= chanel; ALE= 1; START= 1; ALE= 0; START = 0; _nop_(); _nop_(); while(EOC = 0); OE= 1; dd= P1; OE= 0; return(dd); main() unsigned char m; unsigned int a = 13; while(1) q=abc_0808(0x01);a=q*20; m = a/1000; display(m);delay();q=abc_0808(0x00);a=q*20; m = a/1000; display(m);delay(); 仿真图:专心-专注-专业