ADC0809做AD转换的C程序.docx

上传人:小飞机 文档编号:3152054 上传时间:2023-03-11 格式:DOCX 页数:3 大小:36.90KB
返回 下载 相关 举报
ADC0809做AD转换的C程序.docx_第1页
第1页 / 共3页
ADC0809做AD转换的C程序.docx_第2页
第2页 / 共3页
ADC0809做AD转换的C程序.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《ADC0809做AD转换的C程序.docx》由会员分享,可在线阅读,更多相关《ADC0809做AD转换的C程序.docx(3页珍藏版)》请在三一办公上搜索。

1、ADC0809做AD转换的C程序ADC0809做AD转换的C程序 #include unsigned char code dispbitcode= 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f; unsigned char dispbuf4; unsigned int i; unsigned int j; unsigned char getdata; unsigned int temp; unsigned int temp1; unsigned char count; unsigned char d; sbit ST=P30; sbit

2、 OE=P31; sbit EOC=P32; sbit CLK=P33; sbit P34=P34; sbit P35=P35; sbit P36=P36; sbit P20=P20; sbit P21=P21; sbit P22=P22; sbit P23=P23; sbit P17=P17; void TimeInitial; void Delay(unsigned int i);/ void TimeInitial TMOD=0x10; TH1=(65536-200)/256;/定时时间为2us,亦即CLK周期为0.4us TL1=(65536-200)%256; EA=1; ET1=1

3、; TR1=1; void Delay(unsigned int i)/延时函数 unsigned int j; for(;i0;i-) for(j=0;j125;j+) ; void Display/ P1=dispbitcodedispbuf3;/十位 P20=0; P21=1; P22=1; P23=1; Delay(10); P1=0x00; P1=dispbitcodedispbuf2;/个位 P17=1;/显示小数点 P20=1; P21=0; P22=1; P23=1; Delay(10); P1=0x00; P1=dispbitcodedispbuf1;/十分位 P20=1;

4、P21=1; P22=0; P23=1; Delay(10); P1=0x00; P1=dispbitcodedispbuf0;/百分位 P20=1; P21=1; P22=1; P23=0; Delay(10); P1=0x00; void main/主函数 TimeInitial; while(1) ST=0;/关闭转换 OE=0;/关闭输出 ST=1;/开启转换 ST=0;/关闭转换 P34=0;/选择通道0 P35=0; P36=0; while(EOC=0);/判断是否转换结束:是则执行以下语句,否则等待 OE=1;/开启数据输出允许 getdata=P0;/将数据取走,存放在变量getdata中 OE=0;/关闭输出 temp=getdata*1.0/255*500;/电压值转换,5V作为参考电压,分成256份 dispbuf0=temp%10;/百分位 dispbuf1=temp/10%10;/十分位 dispbuf2=temp/100%10;/个位 dispbuf3=temp/1000;/十位 Display; void t1(void) interrupt 3 using 0/定时器中断服务函数;作用:产生CLK信号 TH1=(65536-200)/256; TL1=(65536-200)%256; CLK=CLK;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号