I am trying to setup a rtc using I2C but am having issues in getting it to work. I used the code that was generated by MPLab 4.01 code config. Using on an EasyPICv7 board with a PIC18F46K22 and mikro click rtc.
If I run the code with the debugger I can see on the scope (picture) that it starts but when I pause the program after no further activity the pc is at line 663 of the i2c1.c file (while(i2c1_state != S_MASTER_IDLE); )
I don’t think that the master is getting an acknowledgment but unsure as to why.
I have tried to provide all the info but if I missed something forgive me.
When ever I use I2C in the debug environment it hangs due to it being interrupted mid transmission. So, in my init routine I check for the data line being held low and send clock pulses until it is released.
Here's my init code,
In my experience, Interrupts on I2C and SPI are not really necessary.. Especially at high speeds..
I read / write the clock very quickly and it doesn't affect program flow much at all... Clocks only need to be read once / twice a second as they only store seconds...