problem in i2c communication using pic 16f886

Status
Not open for further replies.

Abhilashhegde94

Member level 1
Joined
Apr 19, 2015
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
India
Activity points
276
Hey guys ....

I am using 1 pic16f886 as a master and another pic16f886 as a slave communicating each other by means of an i2c bus..

The idea is to send a simple text from 1 master to many slaves but I have limited my code to test for just a single slave only.
The message is first recieved by a data reg through UART from the PC.From this data register the data is sent bit by bit via a i2c bus

The Problem i think is with the write function of i2c in my master code but I am not able to debug properly.

Also I am using UART along with i2c for message printing etc.

Pls check in my master and my slave code disregarding the functionality of UART since it works fine,but my i2c is a no-go.(also forget the switch case used to send to many slaves).

The 2 master and slave C files are attached .

View attachment project_code.zip
 

Also I forgot to mention that the c code is written for xc8 compiler.
 

Hi;

I tried checking your code(though i dont code in C but atleast i can read some of it) but what i can see though i might be wrong, in your code for the slave i cant see where an address is defined for the slave, and how its going to know that its the one to receive the message and act on it.

i think you check very well and act on it.

and again since you did not post any circuit here i hope you attached pullup resistors on the lines (sclk and sdata).

Hope this helps

tunde
 

Hey ,

I tinkered a bit about i2c and changed my code .
Also I changed the addressing part of my slave as u had pointed out.
I have attached my code in a zipped file and also the image of the circuit.

Thanks
 

Attachments

  • codes.zip
    5.9 KB · Views: 106
  • MCBoard1.pdf
    26.5 KB · Views: 125

Please zip and post your complete MPLAB X XC8 project files for master and slave.
 

I check that already. It contains only .c files. I nned the complete MPLAB X projects for master and slave so that I can make changes to the code and make it work. I have done I2C master and slave comm in CCS C and mikroC PRO PIC.
 

Hey guys thanks but I got this ...I resolved the errors in my code bow it's working as expected.
 

Ok good.

Can you share the result of your success? so that I and everyone can also benefit?

@Milan please can you post a sample code for this a pic - pic i2c communication, thanks

tunde.
 

sure il do that ..i am kinda busy for 2 days getting things done here but ill upload by tomorrow
 

@Milan, great work you ve done out there. I dont write codes in C. I use protonbasic but i sure will try porting it to basic.

thanks.
 

Here is the attached zipped code containing all the codes etc.Sorry for the delay
 

Attachments

  • i2c_codes.zip
    35.3 KB · Views: 87

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…