野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 20772|回复: 1

hx711芯片关于dt不出数据

[复制链接]
发表于 2017-5-4 14:10:58 | 显示全部楼层 |阅读模式
5火花

#define DT GPIO_Pin_1
#define SCK GPIO_Pin_12
void HX711_init()
{ GPIO_InitTypeDef  GPIO_InitStructure;
       
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);             
GPIO_InitStructure.GPIO_Pin = DT|SCK;                  
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;         
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
};

unsigned long ReadCount(void)
        {
    unsigned long Count;
    int i;
    GPIO_ResetBits(GPIOB,SCK);
    Count=0;
    while(GPIO_ReadInputDataBit(GPIOB,DT)==1);
    for (i=0;i<24;i++)
  {
    GPIO_SetBits(GPIOB,SCK);
    Count=Count<<1;
    GPIO_ResetBits(GPIOB,SCK);
   if(GPIO_ReadInputDataBit(GPIOB,DT)==1)
         { Count++;
          }
   }
   GPIO_SetBits(GPIOB,SCK);
   Count=Count^0x800000;
   GPIO_ResetBits(GPIOB,SCK);
   return(Count);
  }

回复

使用道具 举报

 楼主| 发表于 2017-5-4 14:13:13 | 显示全部楼层
GPIO_ReadInputDataBit(GPIOB,DT)
就这句代码中 DT一直是0,到底是我代码错了还是硬件连接有误?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-6-16 01:05 , Processed in 0.045737 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表