您好,欢迎访问三七文档
参考驱动程序(汇编)/*-------------------------------------------------------------------在ASM中调用:LCALLReaAD可以在C中调用:externunsignedlongReadAD(void);unsignedlongdata;data=ReadAD();----------------------------------------------------------------------*/PUBLICReadADHX711ROMsegmentcodersegHX711ROMsbitADDO=P1.5;sbitADSK=P0.0;/*--------------------------------------------------OUT:R4,R5,R6,R7R7=LSB如果在C中调用,不能修改R4,R5,R6,R7---------------------------------------------------*/ReadAD:CLRADSK//使能AD(PD_SCK置低)SETBADDO//51CPU准双向I/0输入使能JBADDO,$//判断AD转换是否结束,若未结束则等待否则开始读取MOVR4,#24ShiftOut:SETBADSK//PD_SCK置高(发送脉冲)NOPCLRADSK//PD_SCK置低MOVC,ADDO//读取数据(每次一位)XCHA,R7//移入数据RLCAXCHA,R7XCHA,R6RLCAXCHA,R6XCHA,R5RLCAXCHA,R5DJNZR4,ShiftOut//判断是否移入24BITSETBADSKNOPCLRADSKRETEND参考C程序:SbitADDO=P1^5;SbitADSK=P0^0;UndsignedlongReadCount(void){UnsignedlongCount;Unsignedchari;ADDO=1;ADSK=0;Count=0;While(ADDO);for(i=0;i24;i++){ADSK=1;Count=Count1;ADSK=0;if(ADDO)Count++;}ADSK=1;Count=Count^0x800000;ADSK=0;return(Count);}
本文标题:HX711驱动程序
链接地址:https://www.777doc.com/doc-2877363 .html