www.pudn.com > hx711_LCD5110.rar > hx711.c, change:2015-07-04,size:659b


#include <STC12C5A60S2.H> 
#include <intrins.h>	//内部函数,汇编相关 
#include "hx711.h" 
 
void delay_us(unsigned char t) 
{ 
	while(t) t--; 
} 
unsigned long ReadAD(void) 
{ 
unsigned long Count; 
unsigned char i; 
ADDO=1;			 //很重要,否则会读取数据失败进入死循环 
delay_us(100); 
ADSK=0; //使能AD(PD_SCK 置低) 
 
Count=0; 
 
while(ADDO); //AD转换未结束则等待,否则开始读取 
for (i=0;i<24;i++) 
{ 
ADSK=1; //PD_SCK 置高(发送脉冲) 
 
Count=Count<<1; //下降沿来时变量Count左移一位,右侧补零 
 
ADSK=0; //PD_SCK 置低 
 
if(ADDO) Count++; 
} 
ADSK=1; 
 
Count=Count^0x800000;//第25个脉冲下降沿来时,转换数据 
delay_us(1); 
ADSK=0; 
 
return(Count); 
}