hey it s me again :)
i'm trying to make an I2c communication between the bq24160 and a microcontroller 16f
the microcontroller is a master and the bq is a slave
so i want to know for example if the alimentation is from an USB or IN
so i write this code
can u chek it for me plz
#include <16F.h>
#include <lcd.c>
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES PROTECT //Code protected from reads
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=20M)
#use i2c(MASTER, sda=*** ,scl=*** ,force_hw )/
int data
main ()
{
while (1)
{
//lcd_init() ;
i2c_start(); // start i2c
i2c_write(0x70) ; // adress of the slave device REG_STATUS_STAT_MASK
data=i2c_read(); // read the status of the mask
if (data=0x03)
{
lcd_gotoxy(1,1);
lcd_putc("\charging from IN \n");
}
else if (data=0x04)
{
lcd_gotoxy(1,1);
lcd_putc("\charging from USB \n");
}
else if (data=0x05)
{
lcd_gotoxy(1,1);
lcd_putc("\charge done \n");
}
i2c_stop();
}
}