您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 项目/工程管理 > 电源监测芯片ISL28022中文资料
llllllllllllllllllll1START2STOP3DATACHANGE4DATASTBALE1I2C29ACKll121341lA1A07GNDGND1000000GNDVCC1000001GNDSDA1000010GNDSCL1000011VCCGND1000100VCCVCC1000101VCCSDA1000110VCCSCL1000111SDAGND1001000SDAVCC1001001SDASDA1001010SDASCL1001011SCLGND1001100SCLVCC1001101SCLSDA1001110SCLSCL10011110111111STM8S003F6ISL28022I2C#defineSlaveAddr0x80//#defineConfigReg0x00//#defineShuntVReg0x01//#defineBusVReg0x02//#defineCalibReg0x03//#defineCurrentReg0x04//#definePowerReg0x05//#defineShuntVTReg0x06//#defineBusVTReg0x07//#defineInterTReg0x08//#defineAuxCReg0x09//#ifndefBIT#defineBIT(x)(1U(x))#endifs16BatRealVoltage=0;//s16BatRealCurrent=0;////I2CvoidI2C_Config(void){I2C-FREQR=0x10;//I2C16MHz62.5nsI2C-CCRH=0x00;//I2C50%I2C-CCRL=0x50;//0x50-80*62.5ns=5000us(SCL=100KHz)I2C-TRISER=0x11;//SCL62.5nsI2C-CR1|=0x01;//I2CI2C-CR2|=BIT(2);//1I2C-CR2|=BIT(8);//I2C}//voidI2C_Start(void){while((I2C-SR3&BIT(1))==1);//I2C-CR2|=BIT(0);//while((I2C-SR1&BIT(0))==0);//}//voidI2C_Stop(void){I2C-CR2|=BIT(1);}//voidI2C_Ack(void){I2C-CR2|=BIT(2);}//voidI2C_NAck(void){I2C-CR2&=~BIT(2);}//voidI2C_SendAddr(u8addr){I2C-DR=addr;////while((I2C_SR1&BIT(1))==0);//while((I2C-SR3&BIT(1))==1);}//voidI2C_SendData(u8data){I2C-DR=data;////while((I2C-SR3&BIT(1))==1);//while((I2C-SR1&BIT(7))==0);}//u8I2C_RcvData(void){u8data;//1while((I2C-SR1&BIT(6))==0);data=I2C-DR;//returndata;}//voidISL28022_Write(u8slave,u8addr,u16data){I2C_Start();//I2C_SendAddr(slave);//I2C_SendData(addr);//I2C_SendData((u8)(data8));//8I2C_SendData((u8)(data&0xFF));//8I2C_Stop();//}//u16ISL28022_Read(u8slave,u8addr){u16data=0;u8arr[2];I2C_Ack();//1I2C_Start();//I2C_SendAddr(slave);//I2C_SendData(addr);//I2C_Start();//I2C_SendAddr(slave+1);//arr[0]=I2C_RcvData();//8I2C_NAck();//1I2C_Stop();//arr[1]=I2C_RcvData();//8data=((u16)arr[0]8)|(u16)(arr[1]&0xFF);returndata;}//voidISL28022_Init(void){//+-40mV60V//15bit1508us//ISL28022_Write(SlaveAddr,ConfigReg,0x619F);ISL28022_Write(SlaveAddr,CalibReg,0x0000);ISL28022_Write(SlaveAddr,ShuntVTReg,0x7F81);ISL28022_Write(SlaveAddr,BusVTReg,0xFF00);ISL28022_Write(SlaveAddr,InterTReg,0x0000);ISL28022_Write(SlaveAddr,AuxCReg,0x0000);}voidI2C_Loop(void){u16temp;s16databuf=0;s32data=0L;temp=ISL28022_Read(SlaveAddr,BusVReg);//databuf=(s16)(temp2);//2//60000=60/0.00160V/1mV//ADC14bit2^14=16384data=((s32)databuf*60000)/16384;BatRealVoltage=(s16)data;temp=ISL28022_Read(SlaveAddr,ShuntVReg);//databuf=(s16)temp;//40000=40/0.001+-40mV/1uV//ADC12bit2^12=4096//11mV1A1uV=1mAdata=((s32)databuf*40000)/4096;BatRealCurrent=(s16)data;}ZWD
本文标题:电源监测芯片ISL28022中文资料
链接地址:https://www.777doc.com/doc-7085052 .html