数据始终为0,大神帮忙解答一下。
。
头文件应该是没问题的file:///D:QQPCMgr(1)DocumentsTencentFiles951141617ImageC2C(SGB3@_N(T}KUH5`3C(PH}U.jpgfile:///D:QQPCMgr(1)DocumentsTencentFiles951141617ImageC2C(SGB3@_N(T}KUH5`3C(PH}U.jpg/**ADS1118.c*ADS1118芯片描述:*体积小、低功耗、16位模数转换器*内部含温度可测量电路、PGA(可编程增益放大器)*4个差分输入/单端输入*SPI串行通讯传输*包含单次转换模式(单次转换完成进入低功耗模式)和连续转换模式*输入多路复用**硬件描述:*P6.0---->CS*P6.1---->CLK*P6.2---->IN*P6.3---->OUT****软件描述:保持SCLK低于28ms复位SPI通信接口*****Time:*2017年7月22日**Author:*Touch**/#include#defineADS1118_CSBIT0#defineADS1118_CLKBIT1#defineADS1118_INBIT2#defineADS1118_OUTBIT3#defineADS1118_Port_OUTP6OUT#defineADS1118_Port_DIRP6DIR#defineADS1118_Port_INP6IN#defineADS1118_CS_OUT(ADS1118_Port_DIR
=ADS1118_CS)#defineSET_ADS1118_CS(ADS1118_Port_OUT
=ADS1118_CS)#defineCLR_ADS1118_CS(ADS1118_Port_OUT&=~ADS1118_CS)#defineADS1118_CLK_OUT(ADS1118_Port_DIR
=ADS1118_CLK)#defineSET_ADS1118_CLK(ADS1118_Port_OUT
=ADS1118_CLK)#defineCLR_ADS1118_CLK(ADS1118_Port_OUT&=~ADS1118_CLK)#defineADS1118_OUT_IN(ADS1118_Port_DIR&=~ADS1118_OUT)#defineADS1118_OUT_Val(ADS1118_Port_IN&ADS1118_OUT)#defineADS1118_IN_OUT(ADS1118_Port_DIR
=ADS1118_IN)#defineSET_ADS1118_IN(ADS1118_Port_OUT
=ADS1118_IN)#defineCLR_ADS1118_IN(ADS1118_Port_OUT&=~ADS1118_IN)//复用功能宏定义#defineSSBITF//xUnusedinContinuousconversionmode(Alwaysreadsbackas0)#defineMUX2BITE//1#defineMUX1BITD//1#defineMUX0BITC//1111=AINPisAIN3andAINNisGND#definePGA2BITB//0#definePGA1BITA//0#definePGA0BIT9//1001=FSis±4.096V#defineMODEBIT8//00=Continuousconversionmode#defineFS4.096#defineDR2BIT7//1#defineDR1BIT6//0#defineDR0BIT5//0100=128SPS(default)#defineTS_MODEBIT4//00=ADCmode(default)(1=Temperaturesensormode)#definePULL_UP_ENBIT3//11=Pull-upresistorenabledonDOUT/DRDYpin(default)#defineNOP1BIT2//0#defineNOP0BIT1//101=Validdata,updatetheConfigregister(default)#defineNOT_USEDBIT0//xAlwaysreads'1'#defineControl_Regist(MUX2+MUX1+MUX0+PGA0+DR2+PULL_UP_EN+NOP0)#defineControl_Regist_MSB(MUX2+MUX1+MUX0+PGA0)#defineControl_Regist_LSB(DR2+PULL_UP_EN+NOP0)floatADS1118_Voltage;floatADS1118_Temperature=25.9;voidADS1118_init(void)//端口配置{ADS1118_CS_OUT;ADS1118_CLK_OUT;ADS1118_IN_OUT;ADS1118_OUT_IN;CLR_ADS1118_CS;_NOP();CLR_ADS1118_CLK;_NOP();CLR_ADS1118_IN;_NOP();}//SPI为全双工通信方式,在AD转换函数中调用unsignedcharADS1118_Read(unsignedchardata){unsignedchari,temp,Din;temp=data;for(i=0;i8)));Data_REG_L=ADS1118_Read((unsignedchar)Control_Regist_LSB);Data_REG=(Data_REG_H8)));ADS1118_Read((unsignedchar)Control_Regist_LSB);if(Data_REG>=0x8000){Data_REG=0xFFFF-Data_REG;//把0xFFFF改成0x10000ADS1118_Voltage=(-1.0)*((Data_REG*FS/0x8000));}elseADS1118_Voltage=(1.0)*((Data_REG*FS/32768));}voidADS1118_Get_Temperature(void){unsignedinti=200;unsignedcharData_REG_H,Data_REG_L;unsignedintData_REG;while((ADS1118_OUT_Val)&&(i2)*0.03125;}此帖出自电源技术论坛
楼主解决了吗?我现在在做这个
zBetterManc发表于2017-7-2810:51楼主解决了吗?我现在在做这个
,没呢,你做到什么程度了呢?
UCC28061驱动输出不交错怎么回事?UCC28061做的一款电源,发现两个驱动是同步的,不是交错的,布线和变压器的同名端都是对的,驱动和过零检测脚位也没有错,可是不管怎么调就是不交错工作,现在头大了,请问哪位高手遇到过
|