7709AD转换数据不能更新
时间:10-02
整理:3721RD
点击:
我用15单片机控制7709AD转换芯片,数据不能更新是啥情况,求指教?
这是我写的7709的驱动程序
#include<reg52.h>
#include<tm1628.h>
#include<display.h>
#define uint unsigned int
#define uchar unsigned char
sbit DIO1=P3^3;
sbit SCLK=P3^4;
sbit DRDY=P3^5;
uchar read[3];
void start()
{
SCLK=1;
DIO1=1;
delay(1);
DIO1=0;
}
void stop()
{
SCLK=1;
DIO1=0;
delay(1);
DIO1=1;
}
void write_byte(uchar byte)
{
uchar i;
for(i=8;i>0;i--)
{
SCLK=0;
DIO1=byte&0x80;
delay(1);
SCLK=1;
byte=byte<<1;
}
}
void read_byte(uchar byte)
{
uchar i,j,k=0x80;
DIO1=1;
for(i=0;i<byte;i++)
{
read[i]=0;
for(j=0;j<8;j++)
{
SCLK=1;
read[i]=read[i]|k;
k=k>>1;
SCLK=0;
}
}
DIO1=0;
}
void read_DRDY()
{
start();
write_byte(0x3f);
DIO1=1;
read_byte(1);
stop();
}
void shezhi()
{
start();
write_byte(0xbf);
write_byte(0x00);
stop();
}
void read_shuju()
{
while(DRDY)
{
start();
write_byte(0x7f);
DIO1=1 ;
read_byte(3);
stop();
}
}
这是我写的7709的驱动程序
#include<reg52.h>
#include<tm1628.h>
#include<display.h>
#define uint unsigned int
#define uchar unsigned char
sbit DIO1=P3^3;
sbit SCLK=P3^4;
sbit DRDY=P3^5;
uchar read[3];
void start()
{
SCLK=1;
DIO1=1;
delay(1);
DIO1=0;
}
void stop()
{
SCLK=1;
DIO1=0;
delay(1);
DIO1=1;
}
void write_byte(uchar byte)
{
uchar i;
for(i=8;i>0;i--)
{
SCLK=0;
DIO1=byte&0x80;
delay(1);
SCLK=1;
byte=byte<<1;
}
}
void read_byte(uchar byte)
{
uchar i,j,k=0x80;
DIO1=1;
for(i=0;i<byte;i++)
{
read[i]=0;
for(j=0;j<8;j++)
{
SCLK=1;
read[i]=read[i]|k;
k=k>>1;
SCLK=0;
}
}
DIO1=0;
}
void read_DRDY()
{
start();
write_byte(0x3f);
DIO1=1;
read_byte(1);
stop();
}
void shezhi()
{
start();
write_byte(0xbf);
write_byte(0x00);
stop();
}
void read_shuju()
{
while(DRDY)
{
start();
write_byte(0x7f);
DIO1=1 ;
read_byte(3);
stop();
}
}