Created
January 14, 2015 07:16
-
-
Save lotosbin/6f57d4f2e6847124c65b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /************************************************************** | |
| 24bit HX711参考驱动程序 | |
| 在C中调用: | |
| extern unsigned long ReadAD(void); . . | |
| unsigned long data; | |
| data=ReadAD(); . . | |
| -------------------------------------------------------------*/ | |
| sbit ADDO = P1^5; | |
| sbit ADSK = P0^0; | |
| unsigned long ReadCount(void){ | |
| unsigned long Count; | |
| unsigned char i; | |
| 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个脉冲下降沿来时,转换数据 | |
| ADSK=0; | |
| return(Count); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment