I2C is a bi-directional bus with at least one master and one slave. Your program on the Raspberry Pi should provide I2C master functions, and the program on the PIC slave functions. The I2C master always initiates data exchanges.
To exchange data with the slave the master sends a byte containing the slave’s address and whether it is going to send more bytes or wait to receive. When the slave receives that byte it should respond accordingly by sending or receiving.
Only when the master (RPi) puts a byte on the bus following an I2C start condition that contains the slave’s address, will an interrupt be triggered on the slave (PIC).
The interrupt service routine must process the received byte and prepare for the next. The read/write bit determines the response and next action, along with housekeeping to prepare for the next interrupt. The exact steps performed by the slave must match what the master expects and vice-versa.
talkto your device). The interrupt handler in turn tries to call a function that you have to provide yourself. These functions get called with a parameter so you know which data is being requested. You then respond with the appropriate byte. I'd start by watching the i2c bus lines with a scope to see if the RPI is sending something, verify you have the right pins etc. Alternatively insert something in the ISR (switch a LED on) so you can see activity. - E. van Putten