I2C: BitBanging Read/Write Issue with Pic16f877A ( OSC = 11.0592MHz )

i2cmplabxpic

Referring [This Link] (I2C: Unable to Read Multiple Byte using Bit-Banging method).

I created an I2C BitBanging library for Pic16f877A. But I am unable to Read/Write the EEPROM.

My Pin Configuration are :

SCK : RB0
SDATA_OUT : RB1
SDATA_IN : RB2

Rest code remains the same.

Possibly, The issue could be of the delay function as I am using OSC = 11.0592 MHZ with Pic16f877A.
but tried increasing the delay by 2 times. Issue remains the same.

Also,

#pragma config  FOSC    =   HS

Can any one help me with Possible issues and way to rectify the issue.

Note: Code remains the same as the link says. Only Pin and its required registers are changed for Pic16f877A.

Best Answer

If all the code is exactly the same you have a mistake here :

#define Crystal_Value       8          // MHz

you should replace this line by:

#define Crystal_Value       11          // MHz

at the condition 11MHz is really the value of your system oscillator and not the only the one of your crystal oscillator.