CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Comunicating 2 Pic via I2C

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SkamneR
Guest







Comunicating 2 Pic via I2C
PostPosted: Mon Nov 29, 2004 10:16 am     Reply with quote

I´m trying to get started with the I2C protocol in order to comunicate two Pic microcontrollers, one as Master and the other as Slave. I have been checking this forum, and I´ve noticed that almost everybody uses a very low level programming (near to the ASM, as they program diferent bits on registers) at the moment of programing the Slave Microcontroller. My question is:

Does anybody have a piece of code which shows how to configure the slave microcontroller? (I mean, without going down into the register level?)
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 10:25 am     Reply with quote

Take a look at "ex_slave.c" example. It shows a PIC being emulated as an eeprom. What you want to do it very similar. An eeprom you write the address and then read back the data. What you are probably going to do is send a command (like the eeprom's address) and read back some data.
Ken Macfarlane



Joined: 04 Oct 2004
Posts: 12
Location: Glasgow, Scotland

View user's profile Send private message

PostPosted: Tue Nov 30, 2004 3:13 am     Reply with quote

I tried to use ex_slave a while ago, and never could get the slave pic to see the msg although the interrupt did trigger for the incoming address byte, so I gave up and used a parallel interface to the chips, and had to use a bigger pic with more i/o lines.

All of the other examples that I could find were about getting a pic to talk to an i2c eeprom or a pcf8574 i/o expander i.e. there don't seem to be any master/slave pic to pic examples. Please let us know if you get one to work!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Nov 30, 2004 7:08 am     Reply with quote

Yep, works just fine. Did you put pullups on the I2C lines?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Nov 30, 2004 8:59 am     Reply with quote

Also remember not to change the address. It needs to be even.
I forgot who mentioned this. But the example works.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group