void main(){
PORTB = 0;
TRISB = 0; // Configure PORTB as output
while(1)
{
I2C1_Init(100000); // initialize I2C communication \
I2C1_Start(); // issue I2C start signal
I2C1_Wr(0xd0); // send byte via I2C (device address + W) // device identifer is 1101 and MCP3422 has no external Address line + write (0)
// 1101 000 0 = 0xD0
//I2C1_Wr(0x55); // send byte (data address) // no idea what to put here.. i am usig same format as i did for eeprom
// i see no regiser address to read or write
I2C1_Repeated_Start(); // issue I2C signal repeated start
I2C1_Wr(0xd1); // send byte (device address + R) write address +1
PORTB = I2C1_Rd(1u); // Read the data // no idea how to read more than 8 bits. ???
PORTB = I2C1_Rd(1u); // have to read 3 bytes of data from module
PORTB = I2C1_Rd(1u);
I2C1_Stop(); // issue I2C stop signal
delay_ms(1);
}
}