#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
bit write=0;
//sbit sda=P2^0;
//sbit scl=P2^1;
sbit sda=P1^0;
sbit scl=P1^1;
sbit CS_DA =P2^4 ; //HJ-3G DAC HL-1不需要,可以关掉
uchar a;
void delay()
{ ; ; }
void init()
{
CS_DA =0 ;
sda=1;
delay();
scl=1;
delay();
}
void start() //开始信号
{
sda=1;
delay();
scl=1;
delay();
sda=0;
delay();
}
void stop() //停止
{
sda=0;
delay();
scl=1;
delay();
sda=1;
delay();
}
void respons() //应答
{
uchar i;
scl=1;
delay();
while((sda==1)&&(i<250))i++;
scl=0;
delay();
}
void write_byte(uchar date)
{
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay();
sda=CY;
delay();
scl=1;
delay();
}
scl=0;
delay();
sda=1;
delay();
}
uchar read_byte()
{
uchar i,k;
scl=0;
delay();
sda=1;
delay();
for(i=0;i<8;i++)
{
scl=1;
delay();
k=(k<<1)|sda;
scl=0;
delay();
}
return k;
}
void write_add(uchar address,uchar date)
{
start();
write_byte(0x90);
respons();
write_byte(address);
respons();
write_byte(date);
respons();
stop();
}
uchar read_add(uchar address)
{
uchar date;
start();
write_byte(0x90);
respons();
write_byte(address);
respons();
start();
write_byte(0x91);
respons();
date=read_byte();
stop();
return date;
}
uchar ad(uchar add) //ad转换输出函数
{
uchar a;
init();
a=read_add(add);
return a;
}
请问“sbit CS_DA =P2^4 ; //HJ-3G DAC HL-1不需要,可以关掉”“CS_DA =0 ;”作用是什么?为什么我把它删掉AD就不能正常工作呢??我用的是慧净HL-1 V8.0 |