Re: PIC16LF1509 I2C not working / SDA and SCL same signal
Some more comments in your code, explaining what you are trying to do, would be VERY useful.
This line is just plain wrong.
The correct procedure is to wait for the transfer to finish (check the R/W bit), then read the ACKSTAT bit once.
It will be low for an ACK, or high for a NAK.
and "return 1" should NOT be at the end of your main function.
What is the point of "#define XC_HEADER_TEMPLATE_H" ?