As far as I understood from the last code that you posted you are explicitly using the NACK after the first transmission. What you want, and what you should need, is the following transmission:
select_device -> ack_from_device -> read_msb ->
ACK -> read_lsb -> NACK.
But looking at the code you send NACK after the msb byte, telling the device to close the transmission.
| Code: : |
/* Read the MSB data byte */
I2C1CONbits.RCEN = 1;
while (I2C1CONbits.RCEN);
I2C1STATbits.I2COV = 0;
data = I2C1RCV & 0x00FF;
_I2C1_CHECK_IDLE();
/* send NACK condition back to the I2C slave indicating master
* received the data byte
*/
I2C1CONbits.ACKDT = 1;
I2C1CONbits.ACKEN = 1;
while (I2C1CONbits.ACKEN); /* wait until NACK sequence is over */
_I2C1_CHECK_IDLE();
|
This is due to the following line
I2C1CONbits.ACKDT = 1;
Try to put 0 (meaning ACK) instead of 1 after reading the msb byte (but keep the last NACK after the lsb byte).
The problem with the scope is more serious (remember you are now using the i2c port 1

).
Did you call the
i2c_init() function before doing everything?
You should at least see the clock line and some transition on the SDA.
Check also the
I2C1BRG = 362; assignment in the init function, since this specify the i2c bus frequency and should match the peripheral specifiication (please refer to the microchip refman for i2c).
I hope this can help somewhat.
I don't mind your code, and above all your English (I'm sorry for the mine

)
Bye!