新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > Adc0831(模数转化)驱动程序

Adc0831(模数转化)驱动程序

作者: 时间:2016-11-29 来源:网络 收藏

一个这么简单的程序阿飞发了两个小时才搞定。。。。已经测试通过,端口只需直接修改即可使用在你的应用中去.

本文引用地址:https://www.eepw.com.cn/article/201611/323338.htm

驱动波形(一个起始位0 +8个数据位(低先)

#include#define uchar unsigned charsbit cs=P3^4;sbit clk=P3^5;sbit out=P3^7;char adc0831()      //12m  运行270us  size 78byte{char n,dat=0x00;cs=1;clk=1;out=1;cs=0;for(n=0;n<5;n++) ;//延时clk=0;for(n=0;n<5;n++) ;//延时clk=1;for(n=0;n<8;n++){clk=0;;if(out==1) dat=dat|(0x1<<(7-n));else  dat=dat|(0x00<<(7-n)); //这行可省但读高低电平的时间不一样如上图clk=1;;}cs=1;return dat;}main(){while(1){P1=adc0831();}} 


评论


技术专区

关闭