I made a simple program to use i2c to read the time from a DS3231 slave (client) to a PIC18f46K40 master (host).
The code works fine on a breadboard and contains no delays and/or strange tests on BF bits etc.
I attached a zip file containing:
main.c : the program
main - Commented.lst : a list file with added comments to explain what happens where, at least as far as I understand it. I might be wrong on some details.
DS3231MPMB1/pdf : datasheet of the breakout board of the DS3231 I used.
Breadboard.jpg : picture of the breadboard with the test.
quicksave_1_screen.png : screenshot of the scope showing the reading of 3 registers from the slave (client).
quicksave_2_screen.png : screenshot of the scope showing the reading of 3 registers from the slave (client), 4 seconds later.
(the time in the DS is not set to the correct time of day)
AKAICS a lot of your code is the same, excluding all the while statements. The problem might also be in the display code (that I completely left out) or in other parts of your code that are invisible to me. Anyway, you have a working example now so I hope this helps you to get it going.
As I said earlier, this problem intrigued me. I went a bit overboard on it, but hey, I always learn something along the way. If you have questions just ask, but now I need to point my attention to some money-making activities