一个这么简略的程序阿飞发了两个小时才搞定。。。。现已测试通过,端口只需直接修正即可运用在你的使用中去.
驱动波形(一个开始位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();}}