u8 ReadData(u8 command) { u8 temp=0; IIC_Start(); IIC_Send_Byte(0xaa); IIC_Wait_Ack(); IIC_Send_Byte(command); SDA_OUT(); IIC_SCL=0; IIC_SDA=1; Delay_us(100); IIC_Start(); IIC_Send_Byte(0xab); SDA_OUT(); IIC_SCL=0; IIC_SDA=0; Delay_us(140); temp=IIC_Read_Byte(0); IIC_Stop(); return temp; } void WriteData(u8 command, u8 DataToWrite) { IIC_Start(); IIC_Send_Byte(0xaa); IIC_Wait_Ack(); IIC_Send_Byte(command); IIC_Wait_Ack(); SDA_OUT(); IIC_SCL=0; IIC_SDA=1; Delay_us(100); IIC_Send_Byte(DataToWrite); SDA_OUT(); IIC_SCL=0; IIC_SDA=1; Delay_us(140); IIC_Wait_Ack(); IIC_Stop(); Delay_ms(1); } int main(void) { u8 data[2] ; while(1) { WriteData(0x00,0x08); Delay_ms(1); WriteData(0x01,0x00); Delay_ms(1); data[0] = ReadData(0x00) ; Delay_ms(1); data[1] = ReadData(0x01) ; Delay_ms(10); printf("data0: 0x%x , data1: 0x%x \r\n",data[0],data[1]); } }
I read the pdf "bq34z100 DF access pictures.pdf" which Tom Provide , and so I Write the code ,but I cann't get 0x04 and 0x08 ,there's something wrong with the code , so can anyone show it to me ?