首页 AD1674_c语言程序

AD1674_c语言程序

举报
开通vip

AD1674_c语言程序AD1674_c语言程序 #include #include #include // define P1.0 to check STATUS. sbit STATUS = P1^0; unsigned char xdata CTRL _at_ 0x2FFF; unsigned char xdata ADSEL _at_ 0x4FFF; unsigned char hByte; unsigned char lByte; void adc_Convert (void) { // Start ...

AD1674_c语言程序
AD1674_c语言程序 #include #include #include // define P1.0 to check STATUS. sbit STATUS = P1^0; unsigned char xdata CTRL _at_ 0x2FFF; unsigned char xdata ADSEL _at_ 0x4FFF; unsigned char hByte; unsigned char lByte; void adc_Convert (void) { // Start a conversion with A0 and A/$C$ low. // The convesion takes place on rising CE edge. CTRL = 0x00; ADSEL = 0x00; // Wait until we have completed a conversion . while(STATUS==1); // Set R/$C$ with A0 low and read the low byte. CTRL = 0x02; hByte = ADSEL; // Set R/$C$ with A0 high and read the high. CTRL = 0x03; lByte = ADSEL; } void main(void) { unsigned int delay, MSB , LSB, adc_Res; // Initialize serial interface SCON = 0xDA; // SCON: mode 1, 8-bit UART, enable rcvr */ TMOD |= 0x20; // TMOD: timer 1, mode 2, 8-bit reload */ TH1 = 0xFD; // TH1: reload value for 1200 baud @ 12MHz */ TR1 = 1; // TR1: timer 1 run */ TI = 1; // TI: set TI to send first char of UART */ while(1) { adc_Convert(); MSB=(unsigned int)(hByte << 4); LSB=(unsigned int)(lByte >> 4); // adc_Res now has the converted data with 12-bit resolution. adc_Res = MSB + LSB; // Send adc results to the serial interface printf("ADC READINGS: %03Xh\n", adc_Res); // simple delay - it is mcu clock dependent ! for (delay=0; delay<10000; delay++) ; } }
本文档为【AD1674_c语言程序】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_713593
暂无简介~
格式:doc
大小:13KB
软件:Word
页数:2
分类:生活休闲
上传时间:2017-10-10
浏览量:36