PIC16F877A EEPROM I2C CCS PIC C problem

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,362
I am trying to write a simple variable to 1 address and then read it, but the program gets stuck and never move for some reason. After I am finished with 1 eeprom, I will try with 2 on a bus.

It gets stuck on "i2c_start ()" in the driver and never moves on.

Code:
BOOLEAN ext_eeprom_ready() {
   int1 ack;
   i2c_start();            // If the write command is acknowledged,
   ack = i2c_write(0xa0);  // then the device is ready.
   i2c_stop();
   return !ack;
}
main.txt - main program
2432.txt - driver
i2c eeprom.png - circuit
 

Attachments

jayanthd

Joined Jul 4, 2015
945
I know the method, I read the datasheet. I just need to see whats going on here and why doesnt it works.
What Compiler are you using ? What is the MCU Clock frequency and what is I2C Clock frequency ?

Have you connected 4.7k pull-up resistors on I2C lines ?

Show the code of i2C functions.

If testing only in Proteus then R1 and R2 should be 4.7k for 100 KHz I2C Clock and they should be set as DIGITAL resistors.

Proteus has I2C debugger. You can see where it is stucking.

Why RC5 directly connected to GND ? If you configure it as digital Output pin and set it to High then PIC will short to ground.
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,362
Code:
What Compiler are you using ? What is the MCU Clock frequency and what is I2C Clock frequency ?
CCS PIC C 5.61 from custom computer services, 8MHz external clock, the frequency is the hardware frequency with a 5ms write period.

Code:
Have you connected 4.7k pull-up resistors on I2C lines ?
I have connected 4k resistors.

Code:
Show the code of i2C functions.
They are in the driver in the first post.

Code:
If testing only in Proteus then R1 and R2 should be 4.7k for 100 KHz I2C Clock and they should be set as DIGITAL resistors.
How do I do this? I will look in google.

Code:
Proteus has I2C debugger. You can see where it is stucking.
How do I do this? I will look in google.

Most of these things are in the first post and thread title.
 

Thread Starter

ArakelTheDragon

Joined Nov 18, 2016
1,362
Thank you very much for the help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It was the resistor, I needed to use a digital pullup of this type:
"digital resistor pullup" :D. I am happy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

If you need something tell me!
 

jayanthd

Joined Jul 4, 2015
945
Thank you very much for the help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It was the resistor, I needed to use a digital pullup of this type:
"digital resistor pullup" :D. I am happy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

If you need something tell me!
Now you can add more I2C devices with different addresses and communicate with them.
 
Top