求助:大佬们能帮我看一下这个DS2438程序有错吗

博主在电路设计中使用了DS2438传感器,但未连接VSEN+和VSEN-,只接了VAD、VDD、GND、DQ,并将DQ引脚接入STM32F10xVET6的GPIOC_PIN4。博客主要内容是寻求帮助,希望大佬能够审查程序是否存在错误。
摘要由CSDN通过智能技术生成

电路图用的这个

没有接VSEN+和VSEN-,引脚仅使用了VAD、VDD、GND、DQ

DQ接的stm32f10xVET6的GPIOC_PIN4引脚

下边是程序,大佬能帮我看看有什么错误吗

#include "stm32f10x.h"
#include "stdio.h"
#include "bsp_usart.h"
#include "yanshi.h" 
#include "hong.h"  


#define  R    0.05

 float A,B,C,D,E,F;
 float I,J;

u8 ds2438_reset(void);
void ds2438_wr_byte(u8 cmd);
u8 ds2438_rd_byte(void);
void ds2438_initcommand(void);
float Read_Current(void);
float Read_Temperature(void);
float Read_Voltage(void);
float Read_ICAcurrent(void);
float Read_CCAcurrent(void);
float Read_DCAcurrent(void);
void ds2438_test(void);





int main(void)
{	

	  GPIO_InitTypeDef GPIO_InitStructure;
	  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
	
	  CH4;
	  delay_ms(10);
	  ds2438_initcommand();
		USART_Config();
	while (1)
	{

		ds2438_test();
		printf("\r\n The current  value = %f  \r\n",C); 
		printf("\r\n The Voltage  value = %f  \r\n",B); 
		delay_ms(1000);
		C=0;
		B=0;
	}
}



u8 ds2438_reset(void)  //由主机发送复位信号,然后用presence去接2438给的应答信号,如果presence接到了0,说明2438有应答
{
    u8 presence;

    
    CL4;
    
    delay_us(500);
   
    CH4;
   
    
	  delay_us(30);
  
	 if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_4)==1) {presence = 1;}
	 if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_4)==0) {presence = 0;}

    delay_us(300);
    return 
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值